# Controlling game speed

Hi

I am just wondering what the recommended way to control game speed would be?

So for example as the player gets a higher score I want the speed of the game to increase.

I know you can adjust the frame rate and there is an EveryxFrames function but what is the recommended option?

Thanks

I do not think using the frame rate as a speed control is a good practice, just modify your game parameters, if a ball moves vx and vy every frame, then increment vx and vy.

1 Like

What you suggest is how I have done it in game engines in the past but given the Arduboys resolution I need it to always be 1 pixel movement.

So for example at the start the speed is 1 pixel every 1 seconds and then every 0.8, 0.5, etc…

Basically so the player gradually has less time to react but with the player object only moving 1 pixel each time.

I have not tried it yet but knowing the frame rate is staying constant I think using the every x frame option would allow me to still capture the users input and act on the latest one when it gets to frame x.

You could consider doing your calculations using fixed point binary arithmetic, where the lower bits of an integer represent a fraction of pixels, frames, etc.

You store and calculate using fixed point binary and then right shift out the fractional part (with rounding, if necessary) and then use the resulting integer as an offset, frame count or whatever.

You can look at my version of FlappyBall as an example. I used fixed point math to calculate acceleration due to gravity, for smoother, more realistic movement.

1 Like

I used this fixed point binary arithmetic for Mystic Balloon as well.

1 Like

Sounds good, I will do some reading.

Thanks! If you’re going to use fixed point maths then I recommend these articles:

They helped me quite a bit when writing some fixed point maths recently.

Note that there are other solutions too, like using the `everyXFrames` function (e.g. on the first run, make something happen every 30 frames, then next time make it every 25 frames etc).