Created
June 9, 2020 20:15
-
-
Save Srushtika/a659d69b0273e0f50b99eebbd4ce63f0 to your computer and use it in GitHub Desktop.
Code snippet 16 - 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 startDownwardMovement(playerId) { | |
let interval = setInterval(() => { | |
if (players[playerId] && players[playerId].isAlive) { | |
players[playerId].y += PLAYER_VERTICAL_INCREMENT; | |
players[playerId].score += PLAYER_SCORE_INCREMENT; | |
if (players[playerId].y > SHIP_PLATFORM) { | |
finishGame(playerId); | |
clearInterval(interval); | |
} | |
} else { | |
clearInterval(interval); | |
} | |
}, PLAYER_VERTICAL_MOVEMENT_UPDATE_INTERVAL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment