forked from marijnh/Eloquent-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16_1_game_over.html
More file actions
29 lines (26 loc) · 767 Bytes
/
16_1_game_over.html
File metadata and controls
29 lines (26 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!doctype html>
<base href="https://eloquentjavascript.net/">
<script src="code/levels.js"></script>
<script src="code/chapter/16_game.js"></script>
<link rel="stylesheet" href="css/game.css">
<body>
<script>
// The old runGame function. Modify it...
async function runGame(plans, Display) {
let lives = 3;
for (let level = 0; level < plans.length && lives > 0;) {
console.log(`Level ${level + 1}, lives: ${lives}`);
let status = await runLevel(new Level(plans[level]),
Display);
if (status == "won") level++;
else lives--;
}
if (lives > 0) {
console.log("You've won!");
} else {
console.log("Game over");
}
}
runGame(GAME_LEVELS, DOMDisplay);
</script>
</body>