Sort by time | Sort by thread (beta)

Link to this comment:

Share to:
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

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

  • Comment removed

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

  • @LusikkaMage

    Your website is screwed up and wont work

  • awesome tutorials lusikka

  • Another important feature of a timer is that it regulates the amount of CPU utilisation your program causes.

    If your program runs without a timer, it calculates as many frames as possible, resulting in a 100% utilisation of the CPU, slowing every other program down (may also cause problems on certain systems if the OS doesn't get enough calculation time to handle it's message queue).

    As long as your games don't get too complex, they shouldn't use 100% of the CPU and therefore use a timer.

  • seriously just use the turbo key...

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

  • just press the turbo button! :P

    ( if you get that joke.. )

  • ...leik, in zsnes? o_o

  • on old computers they use to have a "turbo" key, google it

  • Hey, I made a best guess, not a "durr, wut iz turb0 kee?"

  • lol, sorry if I seemed mean, just hoping to offer a bit of humor :D

    ( tbh, I don't entirely know if the turbo button speeds up/slows the pc or whatever, but I think it does )

  • I remember the turbo button that used to be on PCs, lol. With it turned off, your PC's CPU would only run at about 75%.

  • Haha, yeah, I had a pc with one of those. Back when cpus made absurd amount of heat we didn't quite know what to do with yet.

  • Its titled Part 7 B Regulating FPS is Allegro not SDL. Besides that, good tutorial! Took me a long time to find anything on this.

  • Oops x_X

  • Why don't you show how to make framerate independent movement ?

  • I don't understand what this would achieve, and how it'd be different from not having the timer at all.

  • Well the game would run at the same speed whatever the framerate is. It would allow people to have a higher framerate. (or lower)

  • I'll look into it for the future, but for now, this is Pickin' Sticks. Let's keep it simple. :)

  • If for example you have a networked program, where both computers need to keep in sync. If one cannot keep up with a regulated framerate, it will go out of sync with the other pretty fast and cause difficulty.

  • Basically you want to use frame rate regulation. Or you and up using 100% CPU. And doing frame rate independent movement is very easy. You just calculate how much is the time passed since the last frame, and use it in the movement calculations. From then it's just physics and math.

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