Adjusting speed of sprites based on variable size of canvas

Hi all, i think this is my first post here - been a reader for a few months though! Here is my question!!

I want to make a game that plays the same no matter what screen size a user has. The canvas will be a % of the screen and the imagesprite sizes will be canvas h/w multiplied by a decimal - so all of that is fine!

But… my issue is making the speed of the sprites appear the same no matter what screen size. On previous games, ive used a global variable for speed and triggered the moves with a timer - but this makes the game far easier to play on a tablet, as the speed appears much slower on a bigger screen.

Hope my query makes sense and id appreciate any ideas you have :slight_smile:

Make the speed = canvas.width x 0.05

This way it will move 5% of the canvas width for the Interval you have set.

Of course 0.05 is just a suggestion so use whatever percentage makes most sense.

This is what I use in my games and it works.

1 Like

Thanks for your suggestion @Romnigames :). I wasn’t sure if you’d be allowed to have a decimal figure for speed, but this will make a huge difference now :slight_smile:

1 Like