Advertisement Jump to content


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


Make time functions

This topic is 5396 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. Well, i made a game without time control, and if i run it in fullscreen it really goes fast. So i decide to implement time functions. Thats something like frames-per-second-FPS. I tried something with the logo of my game and it works, it paints the logo and leave it there for 5 seconds. Anyway. I have a lot of functions for painting enemies, mainship, background, etc and i woul like to make something so i dont have to make a great mass modification in the code. Can you give me some information about time functions and FPS Thanks

Share this post

Link to post
Share on other sites
Basically the key to getting everything to go at the speed you want it regardless of how fast you can render everything is time based movement. In time based movement you move everything based on the time since you last moved it. So for a simple example instead of having

player_x += 1;

every frame you'd have

player_x += 1 * time_elapsed;

every frame.

So the player will always move at the same rate regardless of the FPS. Of course this is a very simple example, but it should give you an idea of how it works. As for time functions it depends on what language you're using and the platform you're coding on. I'll take a shot in the dark and say you're using C or C++ on windows. In which case you'll want to look into high resolution windows timers. Google should be able to give you more information.

[edited by - Monder on April 13, 2004 6:01:49 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!