Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yitonghe00/4a232dd2f9e7c815469136808ba39899 to your computer and use it in GitHub Desktop.
Save yitonghe00/4a232dd2f9e7c815469136808ba39899 to your computer and use it in GitHub Desktop.
<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