Advertisement

Game loop structure

Started by August 29, 2000 02:08 PM
6 comments, last by Interference 24 years, 3 months ago
Hi Everyone! I''m a graduate computer science student and have some programming skills with C, C++ and Java. Recently I''ve got interested in game programming, but I''ve never programmed any real-time interactive application like a game, so I have some questions about it and guessed you could help me: How do I control the speed of a game? I mean not changing the gameplay speed, regardless of the power of the machine it''s running on (not playing in "slow-motion" on a slow machine). Does game programming need any use of threads? Thanks, lchavier
There are two major ways to deal with time.

1) You could lock the frame rate at a minimum, say 25 or 30 fps.

2) You could put in all your velocities as fractions (pixels per millisecond) and use a timer to keep the time difference from one frame to the next, and multiply all motion by the time. This is the best, IMHO, because it will run more smoothly on faster computers, but still run at the correct speed on slower ones.

And yes, threads are used sometimes.
Advertisement
Regarding the second approach, instead of expressing velocities as pixels per millisecond you might instead express it in terms of world units per a certain interval of time. Using world units allows for a dynamic relationship between space (actual object size) and pixels. Using time intervals larger than milliseconds allows you to more conveniently express slower velocities.
Regarding the second approach, instead of expressing velocities as pixels per millisecond you might instead express it in terms of world units per a certain interval of time. Using world units allows for a dynamic relationship between space (actual object size) and pixels. Using time intervals larger than milliseconds allows you to more conveniently express slower velocities.
Regarding the second approach, instead of expressing velocities as pixels per millisecond you might instead express it in terms of world units per a certain interval of time. Using world units allows for a dynamic relationship between space (actual object size) and pixels. Using time intervals larger than milliseconds allows you to more conveniently express slower velocities.
Regarding the second approach, instead of expressing velocities as pixels per millisecond you might instead express it in terms of world units per a certain interval of time. Using world units allows for a dynamic relationship between space (actual object size) and pixels. Using time intervals larger than milliseconds allows you to more conveniently express slower velocities.
Advertisement
Regarding the second approach, instead of expressing velocities as pixels per millisecond you might instead express it in terms of world units per a certain interval of time. Using world units allows for a dynamic relationship between space (actual object size) and pixels. Using time intervals larger than milliseconds allows you to more conveniently express slower velocities.
Damn it! Happy trigger finger of mine. I''m sorry for the quintuplicate post. It was unintentional (server looked like it wasn''t responding so I used the stop button, four times too many).

This topic is closed to new replies.

Advertisement