Created
June 9, 2020 20:44
-
-
Save Srushtika/f2cc1f7027077e2abf9b8e1557ea9289 to your computer and use it in GitHub Desktop.
Code snippet 21 - For multiplayer space invaders article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calcRandomVelocity() { | |
let randomShipXVelocity = Math.floor(Math.random() * 200) + 20; | |
randomShipXVelocity *= Math.floor(Math.random() * 2) == 1 ? 1 : -1; | |
return randomShipXVelocity; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment