Advertisement Jump to content
Sign in to follow this  

Please help! I have problem with FPS

This topic is 2837 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 guys.

I am working on my game called Retro Invaders it's like Space Invaders.

And I have problem with FPS...

Well I have found some functions for FPS for example on and these functions are used only in movement of entities...

Well it looks well, but my computer uses during the game 100% CPU. And if I use SDL_Delay in the end of the loop, the computer uses 12-15% of CPU.

This is also well, but the game looks like it runs and halts and runs and halts.

Also surfaces are not blitted properly

My question is... any idea how to solve this problem please?

Share this post

Link to post
Share on other sites
Don't worry about it; all game loops use 100% CPU and this is both normal and desirable. The whole point of a game loop is that the game code can respond to input and events as fast as possible, and the only way to do that is by keeping the CPU constantly going. Start introducing delays, especially delays where there is imprecision and uncertaintly, and you lose this response.

For your specific case, check the documentation for SDL_Delay:

This function waits a specified number of milliseconds before returning. It waits at least the specified time, but possible longer due to OS scheduling. The delay granularity is at least 10 ms. Some platforms have shorter clock ticks but this is the most common.[/quote]

You're not sleeping for the amount of time you think you are; you're actually sleeping for an indefined and unknown-in-advance longer time, which is causing the jerky behaviour you've observed.

Use vsync if you want to block processing to a certain speed instead.

Share this post

Link to post
Share on other sites
Thanx, but I know a lot of games which are not using 100% of CPU and it works perfecktly... I brought my "game" to school and when I ran it a thought I will burn out that computer... Cooling was literally screaming...

I hope I said it well... (My English)

And one stupid question... what is it vsync?

Share this post

Link to post
Share on other sites
vsync: http://en.wikipedia...._tearing#V-sync

There are a few reasons why a game might not use 100% CPU.
  • Vsync as mentioned would cause each frame to block until the monitor was ready for a redraw; depending on the driver this might cause CPU usage to ease off.
  • The game might be GPU-bound rather than CPU-bound. Remember that any modern game will have at least two processors running in parallel - the GPU and the CPU. If the GPU is the bottleneck then the CPU won't be as busy.
  • You might be looking at a multicore system; with 4 cores a single threaded program will only ever show 25% usage max, for example.Any halfway decent CPU should be able to take 100% usage by the way. Windows 95 and 98 were incapable of suspending the CPU and they certainly didn't burn out CPUs on a regular basis. Quite possible that your school's PC just needs it's fans cleaned out.

Share this post

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

  • 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!