Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Beginner's Guide to Game Programming Ep1 Part 7-B Regulating FPS in SDL

Loading...

Sign in or sign up now!
5,440
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jul 24, 2009

The Beginner's Guide to Game Programming:
A Problem Solving Approach
Episode 1: Makin' Pickin' Sticks
Part 7: Regulating FPS

This is a written and video tutorial created to teach the basics of Allegro and SDL as well as game programming in general, while encouraging the newbie to code it out themselves.

Tells you how to create a function to regulate FPS in your SDL game.

You can get the written version and other things at my site:
http://www.moosader.com

Playlist link:
http://www.youtube.com/view_play_list?p=B9C8BC6F495BD17E

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (LusikkaMage)

  • Hi I´m a beginner to programming so I could be wrong. But is the code in SDL_Delay right? Shouldnt it be:

    SDL_Delay( ((1000/MAX_FPS) - (SDL_GetTicks() - currentTick) ) ); or am I totally wrong? :)

  • oh you might be right, I'll have to look at it again.

  • seriously just use the turbo key...

  • For what? Sonic runs _too fast_ on my newer computers.

see all

All Comments (25)

Sign In or Sign Up now to post a comment!
  • problem with my game is that the fps slowly lower

  • @LusikkaMage

    Your website is screwed up and wont work

  • Your a life saver I didn't know why my player was moving so fast i had it set to sprite.x +=1; and it was still fast but this should work

  • Why dont write the game framerate indepent?

  • cool

  • 0:38 - or you could set a tickrate for the game. Then it will only update after a interval of time. That way you can have a high or low fps without changing gameplay speed.

  • In the section where you give code for regulating fps, it should be SDL_Delay((int)((1000/FPS)-SDL­_GetTicks()+currentTick); , not -currentTick. Took me ages to catch that one - it would freeze the game because SDL_Delay's parameter was negative.

  • Holy Grail of beginner game dev

    right here.

  • you should make more of these with with openGL

  • Your random numbers tutorial seems to be private, leading me here!

Loading...

0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more