FPS is 60, how do i make my player move slower than 60 pixels per second?

so i have my fps set to 60 for a racing game im making. its going to be a side scroller where you have to dodge objects coming at you. but as of right now my player moves wayyyyy to fast. how can i make my player move 60 pixels in 4ish seconds without lowering fps?

Using the everyXFrames() function is one way of doing this.

1 Like

So if i wanted my player to move 59 pixels per second after how many fraes do i want to move? is there ans easy way to do this?

@MLXXXps answer is the easiest if you want to move your player every 2, 3 or x frames.

Otherwise, you can use some floating point (even better, @Pharap’s FixedPoint library) to move the players ‘x’ value 59/60th of a pixel each frame. Of course, when you render the images, you will have to convert the ‘x’ value back to an integer and you may notice the player ‘pausing’ occasionally where subsequent ‘x’ values are converted to the same integer.

2 Likes

@STRAYDOG0626, in case you want to research this technique, it’s called delta timing.

Here’s a demonstration using float:

Press the arrow keys to move.
Hold A and press up and down to adjust the framerate.
Press B to toggle the stat display.

Notice that whatever the framerate is,
the character (pun intended) appears to move at roughly the same rate.

1 Like