Jump to content
  • Advertisement
Sign in to follow this  

Timer question (SDL)

This topic is 4079 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

I have made a simple tetris game and know I want to add some more functionality, among other things do so one can move the figure down faster. Right now I have a SDL_Timer which call a function every 600:ed millisecond. But when the down button is down I want it to reduce to 300:e milliseconds. How shall I do that?

Share this post


Link to post
Share on other sites
Advertisement
sounds like your just starting out.
might i recommend time based animation instead? then you can manipulate the speed of your game. e.g. if you want your entire game to slow by 50%, simply tell your update function that n/2 frames have passed, instead of n frames.

maintaining a constant framerate is awkward. I learned this the hard way.
very few games use a fixed frame rate, mainly because you can never be sure exactly how long one frame will take.

also, many more advanced options are available to you such as capping the framerate, which can save system resources substantially,. I usually cap my frames per second to 48, which means my laptop battery lasts alot faster when im running my game engine.


<n.b.> sorry, modified post because the first paragraph was confusing.

[Edited by - speciesUnknown on March 19, 2007 11:13:03 PM]

Share this post


Link to post
Share on other sites
Instead of speeding up the function calls, you should only speed up the movement of the item. Then, other things can go on in the function without acting weird.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!