Results 1 to 7 of 7

Thread: Game Loop

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2002
    Location
    US
    Posts
    46

    Unhappy Game Loop

    I'm making a game and the game loop has a lot of loops in it which are slowing the game down. Does anyone know a way to have the game loop continue while the Loop inside to Game Loop is running?

  2. #2
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    paste the other loop code into the first loop instead...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2002
    Location
    US
    Posts
    46
    That's what I'm doing.
    What I want to do is let the game loop continue while the loop inside it is running.

  4. #4
    Hyperactive Member
    Join Date
    Jun 2002
    Posts
    299
    ... you will need two seperate game loops running simultaneously to accomplish this. but the DoEvents you would need to put in both to have it work would defeat the purpose. do what cyborg says and combine them - or make the inside loops VERY SHORT. sorry I can't be of more help.
    If I agree with you today, don't get used to it.

  5. #5

    Thread Starter
    Member
    Join Date
    Dec 2002
    Location
    US
    Posts
    46
    I think what I need to do is create a new thread, but I don't think I can do that in VB.

  6. #6
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    hey....your code probably look something like this

    VB Code:
    1. While blah
    2.     'Some Code
    3.     While blah2
    4.         'Some Other Code
    5.         DoEvents
    6.     Wend
    7.     DoEvents
    8. Wend
    9.  
    10. 'Change This to
    11.  
    12. While blah
    13.     'Some Code
    14.     'Some Other Code
    15.     DoEvents
    16. Wend

    if you dont want the other "loop" to run at the same rate, just create a variable and use it to check if its time to do the code!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  7. #7
    Member anjulpa's Avatar
    Join Date
    Aug 2001
    Location
    india
    Posts
    43
    I know what you mean.

    Well, your query to the creating a new thread is allright u can do that by calling the API :
    SHCreatenewthread
    look it up will u

    But what i suggest is that you make movement quantised and not in loops.

    For eg. (in ref to mario) :
    mario must run with the keyboard movements now an enemy creature is moving across the screen and we need that when mario jumps, the creature must move at its normal rate while mario is in the jump.
    If i place all the jump code in one hefty while loop, creature can't move until i have completed the jump. So...... i quantize the jump.
    I allow mario to go only one step(depending on speed and gravity) upwards along the jump and with each step i also allow the creature to move, clouds to deform, birds to fly, system to breathe.... etc etc etc !
    I think you get the point.

    Hope it helps

    ppl saw this
    Die, ***** Die !

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