Skip to content

Instantly share code, notes, and snippets.

@Srushtika
Last active June 9, 2020 20:34
Show Gist options
  • Save Srushtika/e229d98dbca3851ebc9c9099b592262f to your computer and use it in GitHub Desktop.
Save Srushtika/e229d98dbca3851ebc9c9099b592262f to your computer and use it in GitHub Desktop.
Code snippet 19 - For multiplayer space invaders article
function startShipAndBullets() {
gameOn = true;
world = new p2.World({
gravity: [0, -9.82],
});
shipBody = new p2.Body({
position: [shipX, shipY],
velocity: [calcRandomVelocity(), 0],
});
world.addBody(shipBody);
startMovingPhysicsWorld();
for (let playerId in players) {
startDownwardMovement(playerId);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment