Skip to main content
gamedev.net
🔒 Locked

Timer question (SDL)

Started by Adam4444 Mar 17, 2007 at 8:35 AM 1 replies 1k views
Original Post
Adam4444
Adam4444
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?
speciesUnknown
speciesUnknown
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.


sorry, modified post because the first paragraph was confusing.

[Edited by - speciesUnknown on March 19, 2007 11:13:03 PM]
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
Foot Soldier
Foot Soldier
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.
Sure is a big 'ol world.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.