Skip to content

Instantly share code, notes, and snippets.

@Srushtika
Created June 9, 2020 20:44
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