-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
66 lines (58 loc) · 1.99 KB
/
index.html
File metadata and controls
66 lines (58 loc) · 1.99 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="ru">
<head>
<title>Box World</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="css/style.css" />
<script src="js/bw.js"></script>
</head>
<body>
<div id="wrapper">
<p id="menu">
<a id="newGame" href="#">New game</a>
<a id="restart" href="#">Restart (F2)</a>
<a id="undo" href="#">Undo (Ctrl+Z)</a>
</p>
<canvas id="boxWorldScreen" width="760" height="600">
<img id="boxWorldTiles" src="img/tiles.png" alt="tiles" />
</canvas>
<p id="stats">
Level: <b id="levelId"></b>,
Boxes in place: <b id="boxesInPlace"></b> from <b id="boxCount"></b>,
Moves: <b id="moves"></b>
</p>
</div>
<script>
BoxWorld.victory = function() {
this.game.status = false;
setTimeout(function() {
alert('You are awesome! :3 All levels completed.');
BoxWorld.loadLevel(0);
BoxWorld.game.status = true;
}, 1000);
}
BoxWorld.afterRedraw = function() {
document.getElementById('levelId').innerHTML = BoxWorld.level.id + 1;
document.getElementById('boxesInPlace').innerHTML = BoxWorld.level.boxesInPlace;
document.getElementById('boxCount').innerHTML = BoxWorld.level.boxCount;
document.getElementById('moves').innerHTML = BoxWorld.level.moves;
document.getElementById('undo').style.display = BoxWorld.level.undoData.length == 0 ? 'none' : 'inline';
}
document.getElementById('newGame').onclick = function(e) {
e.preventDefault();
BoxWorld.loadLevel(0);
};
document.getElementById('restart').onclick = function(e) {
e.preventDefault();
BoxWorld.loadLevel(BoxWorld.level.id);
};
document.getElementById('undo').onclick = function(e) {
e.preventDefault();
BoxWorld.undo();
};
window.addEventListener('load', function() {
BoxWorld.init();
});
</script>
</body>
</html>