-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
106 lines (92 loc) · 2.29 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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html>
<head>
<title>Asteroids!</title>
</head>
<body>
<div class="cf">
<div id="content">
</div>
<div id="legend">
<b>Arrow keys</b>: move<br>
<b>Space</b>: fire<br>
<br>
<span id="footer">Made by <a href="http://app-academy-kyungmin.tumblr.com">Kyungmin Kim</a></span>
</div>
</div>
<style type"text/css">
body {
font-family: "Arial";
}
#content {
width: 600px;
height: 600px;
float: left;
}
#legend {
float: left;
width: 400px;
margin-left: 10px;
padding: 10px;
font-weight: 200;
font-size: 16px;
color: #333;
background: #f7f7f7
}
#legend b{
font-weight: 400;
}
#footer {
font-size: 12px;
color: #444;
}
.cf:before, cf:after {
content: " ";
display: table;
}
.cf:after {
clear: both;
}
#restart {
position: absolute;
top: 350px;
left: 285px;
color: #fff;
text-decoration: underline;
}
#restart:hover {
cursor: pointer;
}
</style>
<script type="application/javascript" src="./util.js"></script>
<script type="application/javascript" src="./moving_object.js"></script>
<script type="application/javascript" src="./asteroid.js"></script>
<script type="application/javascript" src="./game.js"></script>
<script type="application/javascript" src="./ship.js"></script>
<script type="application/javascript" src="./bullet.js"></script>
<script type="application/javascript" src="./keymaster.js"></script>
<script>
var canvas = document.createElement("canvas");
var canvasLeft = canvas.offsetLeft;
var canvasTop = canvas.offsetTop;
canvas.setAttribute("id", "canvas");
canvas.setAttribute("width", "600");
canvas.setAttribute("height", "600");
var content = document.getElementById("content");
content.appendChild(canvas);
var ctx = canvas.getContext("2d");
var bg = document.createElement('img');
bg.onload = function () {
ctx.drawImage(bg, 0, 0);
}
bg.src = 'bg.jpg';
new Asteroids.Game(ctx, bg).start();
function restart() {
var content = document.getElementById('content');
var restartLink = document.getElementById('restart');
content.removeChild(restartLink);
new Asteroids.Game(ctx, bg).start();
}
</script>
</body>
</html>