forked from marijnh/Eloquent-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15_1_game_over.html
More file actions
32 lines (29 loc) · 791 Bytes
/
15_1_game_over.html
File metadata and controls
32 lines (29 loc) · 791 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
30
31
32
<!doctype html>
<base href="http://eloquentjavascript.net/">
<script src="code/game_levels.js"></script>
<script src="code/chapter/15_game.js"></script>
<link rel="stylesheet" href="css/game.css">
<body>
<script>
function runGame(plans, Display) {
function startLevel(n, lives) {
runLevel(new Level(plans[n]), Display, function(status) {
if (status == "lost") {
if (lives > 0) {
startLevel(n, lives - 1);
} else {
console.log("Game over");
startLevel(0, 3);
}
} else if (n < plans.length - 1) {
startLevel(n + 1, lives);
} else {
console.log("You win!");
}
});
}
startLevel(0, 3);
}
runGame(GAME_LEVELS, DOMDisplay);
</script>
</body>