Skip to content

Instantly share code, notes, and snippets.

@Srushtika
Created June 9, 2020 20:44
Show Gist options
  • Save Srushtika/f2cc1f7027077e2abf9b8e1557ea9289 to your computer and use it in GitHub Desktop.
Save Srushtika/f2cc1f7027077e2abf9b8e1557ea9289 to your computer and use it in GitHub Desktop.
Code snippet 21 - For multiplayer space invaders article
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