vendredi 6 juillet 2018

How to set a random speed in a canvas

I'm trying to make the balls falling at a random speed but the speed is changing only when I reload the page/script, I would like to get a random speed dynamically, one ball comes at 5, the next one 1.4, next 2.6 and so on...

https://codepen.io/Le-future/pen/gKNoEE

I tried to use the following :

// set how fast the objects will fall
var spawnRateOfDescent = Math.random() * (5 - 0.5) + 0.5;




Aucun commentaire:

Enregistrer un commentaire