|
-
Nov 1st, 2001, 02:08 PM
#1
Thread Starter
Stuck in the 80s
Assistance Needed
I'm in need of a little help/advice with a simulation/game that I'm working on.
Basically, with the simulation, you're a scientist that discovered a new life form. You must contain these lifeforms and provide their needs as they multiply and evolve.
I need help with a few things.
1) I'm using the image control to display the creatures. I'm trying to find a better way to make them move around within their tank and such so they don't all group up in the same spot. Also when there's so many of them (see #2), it runs really slow because I'm using a For statement.
2) I need a better way to come up with how they multiply. Right now it just doubles everytime the counter is run. I need a way so that there's only 2 or 3 each time it goes around, and gets slightly higher depending on the population.
Please take a look at the project and see if you can provide any assistance or suggestions. Thanks
-
Nov 1st, 2001, 02:50 PM
#2
Instead of image controls, simply create a UDT for the position of each thing. Load the icon into a picture box, and use BitBlt to paint them onto the screen. This should solve your speed problem.
For the multiplication thing, you could use a hacked version of the distance formula (dont do a square root, and square the distance you are checking), for speed, and if two things are within a few twips of each other (maybe 200), merge them into a new life form (make a red icon that looks like two of the blue ones merged, for example).
Z,
-
Nov 1st, 2001, 04:48 PM
#3
Thread Starter
Stuck in the 80s
I'm not sure I undestand what you mean, and I have no experience with BitBlt. Can you provide some kind of example?
-
Nov 1st, 2001, 05:04 PM
#4
Good Ol' Platypus
Wow.. this reminds me fully of an old game I made called Slugs... I can't post it here because of the limits, but if you want to see the source give me your email.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Nov 1st, 2001, 05:57 PM
#5
PowerPoster
For a population algorithm, you just need to decide how many new things you want each 'round'. Say, for each 2 amoebas, a new one is 'born'.
newPop = oldPop \ 2 + oldPop
Something like that. Note that I meant to use the '\' operator here, it wasn't a typo.
But you just need to decide how many you want to evolve each turn. You could introduce random numbers, say:
Randomize
n = 5 * Rnd + 1
newPop = oldPop \ n + oldPop
Just make an appropriate algorithm.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Nov 1st, 2001, 06:15 PM
#6
Thread Starter
Stuck in the 80s
Thanks for all the help so far!
Does anyone have a better idea on how to draw the creatures on the picture box better than placing a bunch of different picture boxes on the form?
Any examples I can look at?
-
Nov 2nd, 2001, 01:47 PM
#7
Hyperactive Member
bazillions of examples if you search bitblt (look into stretch blt too for growing).What it does essencially is lets you take pics and operate on them for different affects such as transparency and invert and it lets you send the picture to another control - even forms without a clunky picturebox in the main screen (gotta hide them). You can look into "sprites" to create animation by combining multiple pictures also. Incidently you can also use <objectname>.paintpicture and get the same affects using the vb constants for oppcodes. It's a little easier and will be easier to tame without crashing.
-
Nov 2nd, 2001, 03:16 PM
#8
Thread Starter
Stuck in the 80s
I've already decided to go with paintpicture. The only reason I didn't in the first place was because I wanted to be able to click each picture box and get information on each 'creature.' is there anyway I can do this with paintpicture?
-
Nov 2nd, 2001, 03:48 PM
#9
Good Ol' Platypus
In my Slugz game you'll find that I tried to do this with Bitblt, it was working at one point in time but I don't know where that's gone now...
Here, you can look at my BitBlt tutorial:
http://vbden.tripod.com/articles/invmask.htm
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Nov 2nd, 2001, 06:10 PM
#10
Frenzied Member
Hey, I have an idea: Have a picture of the biggest blob the game can have. Then use PaintPicture to paint it with a smaller size for smaller blobs etc
-
Nov 2nd, 2001, 11:40 PM
#11
Thread Starter
Stuck in the 80s
Originally posted by rjlohan
For a population algorithm, you just need to decide how many new things you want each 'round'. Say, for each 2 amoebas, a new one is 'born'.
I need help working on this. I want it to go something like this.
If the population is < 4, a new one is born for every 2.
If the population is < 36, a new one is born for every 4.
If the population is < 100, a new one is born for every 5.
If the population is < 200, a new one is born for every 10.
If the population is > 200, a new one is born for every 20.
I tried working on this, but I'm not getting anywhere fast.
-
Nov 2nd, 2001, 11:44 PM
#12
Thread Starter
Stuck in the 80s
VB Code:
If Population < 4 Then
Population = Population + int(Population / 2)
ElseIf Population < 36 Then
Population = Population + int(Population /4)
End If
is what I have so far.
-
Nov 2nd, 2001, 11:55 PM
#13
Thread Starter
Stuck in the 80s
Nevermind, that works. I'm too tired to think.
Now I just have to incorporate some kind of morale and environmental effects on breeding so that the population isn't the only thing that detiremines how many new ones are born.
-
Nov 3rd, 2001, 10:52 AM
#14
Frenzied Member
Maybe it would be cool if the blobs could do something... instead of just being there
-
Nov 3rd, 2001, 06:02 PM
#15
Thread Starter
Stuck in the 80s
I wanna find a way to place food every "week" in the game, and have them randomly pick it up and move it or eat it. But I'm not very sure how I'd do that. I guess I'd have to make separate graphics for each.
-
Nov 3rd, 2001, 06:23 PM
#16
Frenzied Member
-
Nov 5th, 2001, 01:02 PM
#17
Hyperactive Member
Paintpicture can paint stuff to the form where you want. Record the upper left corner position and all subsequent clicks on the region should subtract this position from the present position. If both the original picture you copied from and the screen you copied to are the same scalemode (use pixels) then the result will be the same as where the pixels in the original pic are.
You can test for masks by using if mask#?.position = vbblack then give the info. If more than one mask exists you'll have to add a region indicator to the condition too.
-
Nov 5th, 2001, 01:09 PM
#18
Frenzied Member
No offense, but you sound like Kedaman
-
Nov 5th, 2001, 03:05 PM
#19
PowerPoster
Hobo, you can simplify
int(x / y)
to
x \ y
It is a seemingly unique VB operator (the \ , that is).
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Nov 6th, 2001, 06:37 PM
#20
Fanatic Member
This sort of project really needs BitBlt to function.... Or at least DrawPixel 
And for the clicking of objects, a simple collision detection of objects could do 
since each object has a width, height, top, left that could be the bounding box...
It just started crapppping out on me after I passed 1024 population, thats not good because population goes well beyond that...
Also, to make a unique population that could go upto or more than 9BILLION, you would have to use Double, if that's not enough or if you want to be able to use significant digits, just put the number into a string, and convert it piece by piece or create ur own type like this:
Type udtLonger
theNum as string
end type
And basically create a function or sub that does:
Function ShowLonger(num as udtLonger)
ShowLonger = CDbl(val(num.theNum))
End function
Hmm, this gets interesting... but im not sure why you want to be able to click on the dots because theyre so small.
-
Nov 6th, 2001, 09:07 PM
#21
Thread Starter
Stuck in the 80s
The pictures aren't small dots any longer, that was just a temporary graphic. I want to display information on each creature when you click them, such as their health, age, etc. to make it interesting.
-
Nov 6th, 2001, 09:49 PM
#22
PowerPoster
You may need to use UDTs.
eg
Type tCreature
X as Int...
Y as Int...
DC as hDC
Age as Int...
:
:
etc.
End Type
BitBlt will just make a single layer picture, although it may appear differently.
When you click on the main picture box (or whatever control you are BitBlt onto) you can use that X,Y combo to check which tCreature was clicked on, and then you can get its data.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|