Results 1 to 22 of 22

Thread: Assistance Needed

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    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
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Zaei
    Guest
    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,

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I'm not sure I undestand what you mean, and I have no experience with BitBlt. Can you provide some kind of example?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  5. #5
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    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]
    -----------------------------------------

  6. #6

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  7. #7
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    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.

  8. #8

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  9. #9
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  10. #10
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  11. #11

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  12. #12

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    VB Code:
    1. If Population < 4 Then
    2.   Population = Population + int(Population / 2)
    3. ElseIf Population < 36 Then
    4.   Population = Population + int(Population /4)
    5. End If

    is what I have so far.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  13. #13

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  14. #14
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Maybe it would be cool if the blobs could do something... instead of just being there
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  15. #15

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  16. #16
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Maybe you could just place it there... yes, you'll need a graphic for food

    It would be really cool if you had it in the system's tray, and turned on all the time - sorta like a Tamagotchi or something
    People would like that
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  17. #17
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    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.

  18. #18
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    No offense, but you sound like Kedaman
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  19. #19
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Hobo, you can simplify
    int(x / y)
    to
    x \ y

    It is a seemingly unique VB operator (the \ , that is).
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  20. #20
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    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.
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  21. #21

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  22. #22
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    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
  •  



Click Here to Expand Forum to Full Width