Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Interference

Game loop structure

This topic is 6563 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!