Created
May 22, 2022 21:49
-
-
Save yitonghe00/4a232dd2f9e7c815469136808ba39899 to your computer and use it in GitHub Desktop.
This file contains 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
<link rel="stylesheet" href="css/game.css"> | |
<body> | |
<script> | |
// The old runGame function. Modify it... | |
async function runGame(plans, Display, lives) { | |
for (let level = 0; level < plans.length && lives > 0;) { | |
console.log(`You have ${lives} lives`); | |
let status = await runLevel(new Level(plans[level]), | |
Display); | |
if (status === "won") { | |
level++; | |
} else if (status === "lost") { | |
lives--; | |
} | |
} | |
if (lives > 0) { | |
console.log("You've won!"); | |
} else { | |
console.log("Game over"); | |
} | |
} | |
runGame(GAME_LEVELS, DOMDisplay, 3); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment