Results 1 to 6 of 6

Thread: Game Loops

  1. #1

    Thread Starter
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    I've been using Game Loops for my programs - the Do Until loops that run endlessly, moving stuff and BitBlting sprites forever and ever til the end of the program - you know the stuff. I send the games to people over the internet, and they say the game is running waaay too fast. It runs fine for me, but my computer is old and runs slower. So, how can I keep the game loop running at a rate that makes everyone happy!?
    To understand recursion, one must first understand the concept of recursion.

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Use the GetTickCount API (declaration of it will be in API viewer, I can't remember it off the top of my head). It returns the number of milliseconds since system startup. Use a global variable for the tick count last time through your loop and each subsequent time through the loop, check if the tickcount is a certain amount more than it was last time you did your loop stuff. So, for 50 frames per second, go through the loop every 20 milliseconds. Get the idea?
    Harry.

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    So GetTickCount gets a number of milliseconds that is uneffected by computer speed and should be the same every time the program is run no matter how fast the loop is running?? That sounds good, I think that will solve my problemz, thankz.
    To understand recursion, one must first understand the concept of recursion.

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Yep, that's about it. No problem
    Harry.

    "From one thing, know ten thousand things."

  5. #5
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    ...but remember: you may slow down your game by waiting for 50ms each loop, but you won't speed it up if the computer's too slow

  6. #6

    Thread Starter
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    LOL, well I don't know anyone with a really slow computer. Except maybe me...maybe that's why I'm having problems in the first place... . o O ( Stewpid, cheap computer ) **kicks the CPU and sees Window crash again**

    NOOOOOOO NOT AGAIN!!!!
    To understand recursion, one must first understand the concept of recursion.

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