-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
209 lines (203 loc) · 4.26 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Space Invaders</title>
<script src="highscore.js"></script>
<style type="text/css" media="screen">
body {
background: #000;
}
.invader-template,
.player-template {
display: none;
}
#game-wrap {
border: 3px double #666;
display: inline-block;
position: relative;
}
#code {
color: #fff;
}
@font-face {
font-family: "8bitoperator_jve";
src: url("fonts/8bitoperator_jve.eot");
src: local("☺"), url("fonts/8bitoperator_jve.woff") format("woff"),
url("fonts/8bitoperator_jve.ttf") format("truetype"),
url("fonts/8bitoperator_jve.svg") format("svg");
font-weight: normal;
font-style: normal;
}
</style>
</head>
<body>
<canvas id="canvas" style="display: none;"></canvas>
<textarea
id="invader-blueprint"
name="invader"
rows="10"
cols="10"
style="display: none;"
>
000010010000
100111111001
101111111101
101111111101
101111111101
111111111111
000011110000
000111111000
001001100100
</textarea
>
<div id="code"></div>
<div id="game-wrap">
<canvas id="game"></canvas>
</div>
<script src="spaceinvaders.js"></script>
<script>
document.addEventListener(
"DOMContentLoaded",
function () {
// Space Invader creation stuff
var canvas = document.getElementById("canvas"),
ctx = canvas.getContext("2d"),
color = "255,0,0",
PIXEL_SIZE = 10,
MAX_PIXEL = 12;
canvas.width = MAX_PIXEL * PIXEL_SIZE;
canvas.height = MAX_PIXEL * PIXEL_SIZE;
var invader = new SpaceInvaders.Invader(canvas, {
blueprint: document.getElementById("invader-blueprint").value,
color: color,
maxWidth: MAX_PIXEL,
maxHeight: MAX_PIXEL,
pixelSize: PIXEL_SIZE,
x: 0,
y: 0,
});
var codeDiv = document.getElementById("code");
document
.getElementById("invader-blueprint")
.addEventListener("keyup", function () {
ctx.clearRect(0, 0, canvas.width, canvas.height);
invader.blueprint = document.getElementById(
"#invader-blueprint"
).value;
invader.redraw();
codeDiv.html(EightBit.encode(invader.blueprint));
});
new SpaceInvaders("game", {
highscore: "http://localhost:8181",
});
},
false
);
</script>
<textarea class="invader-template" id="invader1">
000100001000
000010010000
001111111100
001111111100
111111111111
101111111101
101111111101
000010010000
000100001000
</textarea
>
<textarea class="invader-template" id="invader6">
000011110000
011111111110
111111111111
111001100111
111111111111
000111111000
001101101100
110000000011
</textarea
>
<textarea class="invader-template" id="invader2">
000011110000
001111111100
111111111111
111001100111
111111111111
111111111111
000101101000
001010010100
010001100010
</textarea
>
<textarea class="invader-template" id="invader3">
000010010000
100111111001
101101101101
101111111101
111111111111
000011110000
000111111000
001001100100
010000000010
</textarea
>
<textarea class="invader-template" id="invader4">
0000110000
0001111000
0011111100
0110110110
0111111110
0001111000
0010000100
0100000010
</textarea
>
<textarea class="invader-template" id="invader7">
00100000100
10010001001
10111111101
11101110111
01111111110
01111111110
00100000100
01000000010
</textarea
>
<textarea class="invader-template" id="invader5">
10100101
01011010
00111100
00100100
</textarea
>
<textarea class="invader-template" id="invader8">
00100000100
00010001000
00111111100
01101110110
11111111111
10111111101
10100000101
00011011000
</textarea
>
<textarea class="invader-template" id="mothership">
000011000
0011111100
1111111111
1100110011
0111111110
</textarea
>
<textarea class="player-template" id="player-template">
00000100000
00001110000
01111111110
11111111111
11111111111
11111111111
</textarea
>
</body>
</html>