-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·77 lines (66 loc) · 2.18 KB
/
index.html
File metadata and controls
executable file
·77 lines (66 loc) · 2.18 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
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Missile Command</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Missile Command</h1>
<p>Press space to start, pause and resume the game.</p>
<a href='#' id="sound-control">Turn off sound</a>
<canvas id="canvas"></canvas>
<p class="reference"><em>A <a href="http://www.theodinproject.com/courses/javascript-and-jquery/lessons/building-games-with-canvas">JavaScript project</a> by <strong>David Chapman</strong> in partial fulfillment of <a href="http://www.theodinproject.com/">The Odin Project</a></em></p>
<p class="reference">Audio files borrowed from <a href="https://www.html5rocks.com/en/tutorials/canvas/notearsgame/">here</a> and <a href="hhttp://soundbible.com/">here</a></p>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-3.1.1.min.js"></script>
<script>
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='/js/jquery-3.1.1.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<script src="jquery.hotkeys.js"></script>
<script src="game.js"></script>
<script>
var explosionSound = new Audio('sounds/explosion.wav');
var shootSound = new Audio('sounds/shoot.wav');
var bombDropSound = new Audio('sounds/bomb-drop.mp3');
var bombExplodeSound = new Audio('sounds/bomb-explosion.mp3');
function setup(starting) {
initCities();
initBases();
initPlayerMissiles();
initEnemyMissiles();
initUFOs();
initPlanes();
if(starting) {
listen();
}
}
function gameLoop() {
updateGame();
if(game.state === 'playing') {
updatePlanes();
updateUFOs();
updateCities();
updateBases();
updateFiredMissiles();
updateExplosions();
}
drawBackground(c);
drawOverlay(c);
drawBases(c);
drawCities(c);
drawFiredMissiles(c);
drawExplosions(c);
drawUFOs(c);
drawPlanes(c);
drawCrosshairs(c);
}
$(document).ready(function() {
setup(true);
setInterval(gameLoop,1000/FPS);
});
</script>
</body>
</html>