-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
44 lines (41 loc) · 1.23 KB
/
index.html
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
<html>
<head>
<script type="text/javascript" src="lib/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="js/Point.js"></script>
<script type="text/javascript" src="js/Square.js"></script>
<script type="text/javascript" src="js/Plateau.js"></script>
<script type="text/javascript" src="js/Ship.js"></script>
<script type="text/javascript" src="js/Missile.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var alpha = plateau($("body"));
var playerShip = ship(alpha);
function fireWrapper () {
playerShip.fire();
var pew = $("<span>", {
html: "pew ",
style: "display: none; background: black; color: #00ffff"
});
$("body").append(pew);
pew.show("slow");
}
$(window).keypress(function(event) {
var movementPerKeyCode = {
'37': playerShip.moveLeft,
'39': playerShip.moveRight,
'38': fireWrapper
};
var movement = movementPerKeyCode[event.keyCode];
movement && movement();
});
function gameLoop() {
alpha.update();
setTimeout(gameLoop, 10);
}
gameLoop();
});
</script>
</body>
</html>