Game loop structure
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.
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.
August 30, 2000 02:17 AM
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.
August 30, 2000 02:18 AM
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.
August 30, 2000 02:19 AM
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.
August 30, 2000 02:22 AM
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.
August 30, 2000 02:23 AM
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.
August 30, 2000 02:29 AM
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
Popular Topics
Advertisement
Recommended Tutorials
Advertisement