-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
214 lines (214 loc) · 14 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
210
211
212
213
214
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<title>Robot Coder</title>
<meta name="viewport" content="width=device-width">
<link rel="icon" href="f.png">
<link href="style.css" rel="stylesheet">
<script src="storage.js" defer></script>
<script src="display.js" defer></script>
<script src="sound.js" defer></script>
<script src="info.js" defer></script>
<script src="code-input.js" defer></script>
<script src="map.js" defer></script>
<script src="robot.js" defer></script>
<script src="run.js" defer></script>
<script src="level.js" defer></script>
<script src="level-collection.js" defer></script>
<script src="editor.js" defer></script>
<script src="game.js" defer></script>
</head><body>
<svg style="display:none">
<!--Icons derived from Google's Material Design Icons-->
<symbol id="back">
<path d="M16.62,2.99L16.62,2.99c-0.49-0.49-1.28-0.49-1.77,0l-8.31,8.31c-0.39,0.39-0.39,1.02,0,1.41l8.31,8.31c0.49,0.49,1.28,0.49,1.77,0h0c0.49-0.49,0.49-1.28,0-1.77L9.38,12l7.25-7.25C17.11,4.27,17.11,3.47,16.62,2.99z"/>
</symbol>
<symbol id="note-on">
<path d="M12,5v8.55c-0.94-0.54-2.1-0.75-3.33-0.32C7.33,13.71,6.3,14.9,6.06,16.3c-0.46,2.74,1.86,5.08,4.59,4.65c1.96-0.31,3.35-2.11,3.35-4.1L14,7h2c1.1,0,2-0.9,2-2v0c0-1.1-0.9-2-2-2h-2C12.9,3,12,3.9,12,5z"/>
</symbol>
<symbol id="note-off">
<path d="M14,9.61V7h2c1.1,0,2-0.9,2-2c0-1.1-0.9-2-2-2h-3c-0.55,0-1,0.45-1,1v3.61L14,9.61z"/>
<path d="M5.12,3.56c-0.39-0.39-1.02-0.39-1.41,0c-0.39,0.39-0.39,1.02,0,1.41L12,13.27v0.28c-0.94-0.54-2.1-0.75-3.33-0.32C7.33,13.71,6.3,14.9,6.06,16.3c-0.46,2.74,1.86,5.08,4.59,4.65c1.96-0.31,3.35-2.11,3.35-4.1v-1.58l5.02,5.02 c0.39,0.39,1.02,0.39,1.41,0v0c0.39-0.39,0.39-1.02,0-1.41L5.12,3.56z"/>
</symbol>
<symbol id="go">
<path d="M8,6.82v10.36c0,0.79,0.87,1.27,1.54,0.84l8.14-5.18c0.62-0.39,0.62-1.29,0-1.69L9.54,5.98C8.87,5.55,8,6.03,8,6.82z"/>
</symbol>
<symbol id="cancel">
<path d="M18.3,5.71L18.3,5.71c-0.39-0.39-1.02-0.39-1.41,0L12,10.59L7.11,5.7c-0.39-0.39-1.02-0.39-1.41,0l0,0c-0.39,0.39-0.39,1.02,0,1.41L10.59,12L5.7,16.89c-0.39,0.39-0.39,1.02,0,1.41h0c0.39,0.39,1.02,0.39,1.41,0L12,13.41l4.89,4.89 c0.39,0.39,1.02,0.39,1.41,0l0,0c0.39-0.39,0.39-1.02,0-1.41L13.41,12l4.89-4.89C18.68,6.73,18.68,6.09,18.3,5.71z"/>
</symbol>
<symbol id="reset">
<path d="M12,5V2.21c0-0.45-0.54-0.67-0.85-0.35L7.35,5.65c-0.2,0.2-0.2,0.51,0,0.71l3.79,3.79C11.46,10.46,12,10.24,12,9.79V7c3.73,0,6.68,3.42,5.86,7.29c-0.47,2.27-2.31,4.1-4.57,4.57c-3.57,0.75-6.75-1.7-7.23-5.01C5.99,13.37,5.57,13,5.08,13h0c-0.6,0-1.08,0.53-1,1.13c0.62,4.39,4.8,7.64,9.53,6.72c3.12-0.61,5.63-3.12,6.24-6.24C20.84,9.48,16.94,5,12,5z"/>
</symbol>
<symbol id="lock">
<path d="M18,8h-1V6c0-2.76-2.24-5-5-5S7,3.24,7,6v2H6c-1.1,0-2,0.9-2,2v10c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V10 C20,8.9,19.1,8,18,8z M9,8V6c0-1.66,1.34-3,3-3 s3,1.34,3,3v2H9z"/>
</symbol>
<symbol id="ok">
<path d="M9,16.2l-3.5-3.5c-0.39-0.39-1.01-0.39-1.4,0l0,0c-0.39,0.39-0.39,1.01,0,1.4l4.19,4.19c0.39,0.39,1.02,0.39,1.41,0L20.3,7.7c0.39-0.39,0.39-1.01,0-1.4l0,0c-0.39-0.39-1.01-0.39-1.4,0L9,16.2z"/></symbol>
<symbol id="star">
<path d="M12,17.27l4.15,2.51c0.76,0.46,1.69-0.22,1.49-1.08l-1.1-4.72l3.67-3.18c0.67-0.58,0.31-1.68-0.57-1.75l-4.83-0.41l-1.89-4.46c-0.34-0.81-1.5-0.81-1.84,0L9.19,8.63L4.36,9.04c-0.88,0.07-1.24,1.17-0.57,1.75l3.67,3.18l-1.1,4.72c-0.2,0.86,0.73,1.54,1.49,1.08L12,17.27z"/>
</symbol>
<symbol id="star-2">
<use x="-4" y="-4" xlink:href="#star"/><use x="4" y="4" xlink:href="#star"/>
</symbol>
<symbol id="left">
<path d="M19,11H7.83l4.88-4.88c0.39-0.39,0.39-1.03,0-1.42l0,0c-0.39-0.39-1.02-0.39-1.41,0l-6.59,6.59c-0.39,0.39-0.39,1.02,0,1.41l6.59,6.59c0.39,0.39,1.02,0.39,1.41,0l0,0c0.39-0.39,0.39-1.02,0-1.41L7.83,13H19c0.55,0,1-0.45,1-1 v0C20,11.45,19.55,11,19,11z"/>
</symbol>
<symbol id="right">
<path d="M5,13h11.17l-4.88,4.88c-0.39,0.39-0.39,1.03,0,1.42l0,0c0.39,0.39,1.02,0.39,1.41,0l6.59-6.59c0.39-0.39,0.39-1.02,0-1.41L12.71,4.7c-0.39-0.39-1.02-0.39-1.41,0l0,0c-0.39,0.39-0.39,1.02,0,1.41L16.17,11H5c-0.55,0-1,0.45-1,1v0C4,12.55,4.45,13,5,13z"/>
</symbol>
<symbol id="minus">
<path d="M18,13H6c-0.55,0-1-0.45-1-1v0c0-0.55,0.45-1,1-1h12c0.55,0,1,0.45,1,1v0C19,12.55,18.55,13,18,13z"/></symbol>
<symbol id="plus">
<path d="M18,13h-5v5c0,0.55-0.45,1-1,1h0c-0.55,0-1-0.45-1-1v-5H6c-0.55,0-1-0.45-1-1v0c0-0.55,0.45-1,1-1h5V6c0-0.55,0.45-1,1-1h0c0.55,0,1,0.45,1,1v5h5c0.55,0,1,0.45,1,1v0C19,12.55,18.55,13,18,13z"/></symbol>
<symbol id="del">
<path d="M22,3H7C6.31,3,5.77,3.35,5.41,3.88l-5.04,7.57c-0.22,0.34-0.22,0.77,0,1.11l5.04,7.56C5.77,20.64,6.31,21,7,21h15 c1.1,0,2-0.9,2-2V5C24,3.9,23.1,3,22,3z M18.3,16.3L18.3,16.3c-0.39,0.39-1.02,0.39-1.41,0L14,13.41l-2.89,2.89c-0.39,0.39-1.02,0.39-1.41,0h0c-0.39-0.39-0.39-1.02,0-1.41L12.59,12L9.7,9.11c-0.39-0.39-0.39-1.02,0-1.41l0,0c0.39-0.39,1.02-0.39,1.41,0L14,10.59l2.89-2.89c0.39-0.39,1.02-0.39,1.41,0v0c0.39,0.39,0.39,1.02,0,1.41L15.41,12l2.89,2.89 C18.68,15.27,18.68,15.91,18.3,16.3z"/></symbol>
<symbol id="code-x">
<path d="M19.29,12.7c-0.39-0.39-1.02-0.39-1.41,0L16,14.59L14.11,12.7c-0.39-0.39-1.02-0.39-1.41,0c-0.39,0.39-0.39,1.02,0,1.41L14.59,16l-1.89,1.89c-0.39,0.39-0.39,1.02,0,1.41c0.39,0.39,1.02,0.39,1.41,0L16,17.41l1.89,1.89c0.39,0.39,1.02,0.39,1.41,0 c0.39-0.39,0.39-1.02,0-1.41L17.41,16l1.89-1.89C19.68,13.73,19.68,13.09,19.29,12.7z"/>
</symbol>
<symbol id="code-left">
<path d="M6.56,7.98L6.56,7.98C6.1,7.52,5.31,7.6,5,8.17c-0.28,0.51-0.5,1.03-0.67,1.58C4.14,10.38,4.64,11,5.29,11h0.01c0.43,0,0.82-0.28,0.94-0.7c0.12-0.4,0.28-0.79,0.48-1.17C6.94,8.76,6.87,8.29,6.56,7.98z M5.31,13H5.29c-0.65,0-1.15,0.62-0.96,1.25c0.16,0.54,0.38,1.07,0.66,1.58c0.31,0.57,1.11,0.66,1.57,0.2l0,0c0.3-0.31,0.38-0.77,0.17-1.15c-0.2-0.37-0.36-0.76-0.48-1.16C6.13,13.28,5.74,13,5.31,13z M8.16,19.02c0.51,0.28,1.04,0.5,1.59,0.66c0.62,0.18,1.24-0.32,1.24-0.96v-0.03c0-0.43-0.28-0.82-0.7-0.94c-0.4-0.12-0.78-0.28-1.15-0.48c-0.38-0.21-0.86-0.14-1.16,0.17l-0.03,0.03C7.5,17.92,7.59,18.71,8.16,19.02z M13,4.07V3.41c0-0.89-1.08-1.34-1.71-0.71L9.17,4.83C8.77,5.23,8.77,5.87,9.17,6.26l2.13,2.08C11.93,8.96,13,8.51,13,7.62V6.09c2.84,0.48,5,2.94,5,5.91c0,2.73-1.82,5.02-4.32,5.75C13.27,17.87,13,18.26,13,18.69 v0.02c0,0.65,0.61,1.14,1.23,0.96C17.57,18.71,20,15.64,20,12C20,7.92,16.95,4.56,13,4.07z"/>
</symbol>
<symbol id="code-right">
<path d="M14.83,4.83l-2.13-2.13C12.08,2.08,11,2.52,11,3.41v0.66C7.06,4.56,4,7.92,4,12c0,3.64,2.43,6.71,5.77,7.68c0.62,0.18,1.23-0.32,1.23-0.96v-0.03c0-0.43-0.27-0.82-0.68-0.94C7.82,17.03,6,14.73,6,12c0-2.97,2.16-5.43,5-5.91v1.53c0,0.89,1.07,1.33,1.7,0.71l2.13-2.08C15.23,5.87,15.23,5.23,14.83,4.83z M19.67,9.76c-0.16-0.55-0.38-1.08-0.66-1.59c-0.31-0.57-1.1-0.66-1.56-0.2l-0.01,0.01c-0.31,0.31-0.38,0.78-0.17,1.16c0.2,0.37,0.36,0.76,0.48,1.16c0.12,0.42,0.51,0.7,0.94,0.7h0.02C19.36,11,19.86,10.38,19.67,9.76z M13,18.68v0.02c0,0.65,0.62,1.14,1.24,0.96c0.55-0.16,1.08-0.38,1.59-0.66c0.57-0.31,0.66-1.1,0.2-1.56l-0.02-0.02c-0.31-0.31-0.78-0.38-1.16-0.17c-0.37,0.21-0.76,0.37-1.16,0.49C13.28,17.86,13,18.25,13,18.68z M17.44,16.03L17.44,16.03c0.46,0.46,1.25,0.37,1.56-0.2c0.28-0.51,0.5-1.04,0.67-1.59c0.18-0.62-0.31-1.24-0.96-1.24h-0.02c-0.44,0-0.82,0.28-0.94,0.7c-0.12,0.4-0.28,0.79-0.48,1.17 C17.06,15.25,17.14,15.73,17.44,16.03z"/></symbol>
<symbol id="code-up">
<path d="M13,19V7.83l4.88,4.88c0.39,0.39,1.03,0.39,1.42,0l0,0c0.39-0.39,0.39-1.02,0-1.41l-6.59-6.59c-0.39-0.39-1.02-0.39-1.41,0L4.7,11.29c-0.39,0.39-0.39,1.02,0,1.41l0,0c0.39,0.39,1.02,0.39,1.41,0L11,7.83V19c0,0.55,0.45,1,1,1h0C12.55,20,13,19.55,13,19z"/></symbol>
<symbol id="code-down">
<path d="M11,5v11.17l-4.88-4.88c-0.39-0.39-1.03-0.39-1.42,0l0,0c-0.39,0.39-0.39,1.02,0,1.41l6.59,6.59c0.39,0.39,1.02,0.39,1.41,0l6.59-6.59c0.39-0.39,0.39-1.02,0-1.41l0,0c-0.39-0.39-1.02-0.39-1.41,0L13,16.17V5c0-0.55-0.45-1-1-1 h0C11.45,4,11,4.45,11,5z"/></symbol>
<symbol id="code-go">
<use xlink:href="#right"/>
</symbol>
<symbol id="code-repeat">
<path d="M9,16H9.3c2.35,0,4.45-1.71,4.68-4.05C14.24,9.27,12.13,7,9.5,7H7c-0.55,0-1-0.45-1-1v0c0-0.55,0.45-1,1-1H9.5c3.86,0,6.96,3.4,6.44,7.36C15.52,15.64,12.57,18,9.27,18H9z M9,14.91c0-0.89-1.08-1.34-1.71-0.71L5.17,16.33C4.77,16.73,4.77,17.37,5.17,17.76l2.13,2.08C7.93,20.46,9,20.01,9,19.12z"/></symbol>
<symbol id="code-2">
<path d="M8,18h-3v-2h2c1.1,0,2-0.9,2-2V12 c0-1.1-0.9-2-2-2h-3c-0.55,0-1,0.45-1,1v0c0,0.55,0.45,1,1,1h3v2h-2c-1.1,0-2,0.9-2,2v3c0,0.55,0.45,1,1,1h4c0.55,0,1-0.45,1-1v0C9,18.45,8.55,18,8,18z"/>
<use xlink:href="#code-x"/>
</symbol>
<symbol id="code-3">
<path d="M9,18v-1.5c0-0.83-0.67-1.5-1.5-1.5 c0.83,0,1.5-0.67,1.5-1.5V12c0-1.1-0.9-2-2-2h-3c-0.55,0-1,0.45-1,1v0c0,0.55,0.45,1,1,1h3v2h-1c-0.55,0-1,0.45-1,1v0c0,0.55,0.45,1,1,1h1v2h-3c-0.55,0-1,0.45-1,1v0c0,0.55,0.45,1,1,1h3C8.1,20,9,19.1,9,18z"/>
<use xlink:href="#code-x"/>
</symbol>
<symbol id="code-4">
<path d="M8,20L8,20c0.55,0,1-0.45,1-1V11c0-0.55-0.45-1-1-1h0c-0.55,0-1,0.45-1,1v3h-2V11c0-0.55-0.45-1-1-1h0 c-0.55,0-1,0.45-1,1v4c0,0.55,0.45,1,1,1h3v3C7,19.55,7.45,20,8,20z"/>
<use xlink:href="#code-x"/>
</symbol>
<symbol id="code-5">
<path d="M9,18v-2c0-1.1-0.9-2-2-2h-2V12h3c0.55,0,1-0.45,1-1v0c0-0.55-0.45-1-1-1h-4c-0.55,0-1,0.45-1,1v4c0,0.55,0.45,1,1,1h3v2h-3c-0.55,0-1,0.45-1,1v0c0,0.55,0.45,1,1,1h3C8.1,20,9,19.1,9,18z"/>
<use xlink:href="#code-x"/>
</symbol>
<symbol id="code-6">
<path d="M5,20h2c1.1,0,2-0.9,2-2v-2 c0-1.1-0.9-2-2-2h-2V12h3c0.55,0,1-0.45,1-1v0c0-0.55-0.45-1-1-1h-3c-1.1,0-2,0.9-2,2v6C3,19.1,3.9,20,5,20z M5,16h2v2h-2V16z"/>
<use xlink:href="#code-x"/>
</symbol>
<symbol id="code-7">
<path d="M5.25,19.51l3.58-7.17 C8.94,12.12,9,11.87,9,11.62v0C9,10.72,8.28,10,7.38,10H4c-0.55,0-1,0.45-1,1v0c0,0.55,0.45,1,1,1h3l-3.36,6.71c-0.3,0.59,0.13,1.29,0.8,1.29h0.01C4.79,20,5.1,19.81,5.25,19.51z"/>
<use xlink:href="#code-x"/>
</symbol>
<symbol id="code-8">
<path d="M5,20h2c1.1,0,2-0.89,2-2v-1.5 c0-0.83-0.67-1.5-1.5-1.5c0.83,0,1.5-0.67,1.5-1.5V12c0-1.11-0.9-2-2-2h-2c-1.1,0-2,0.89-2,2v1.5c0,0.83,0.67,1.5,1.5,1.5c-0.83,0-1.5,0.67-1.5,1.5V18C3,19.11,3.9,20,5,20z M5,12h2v2h-2V12z M5,16h2v2h-2V16z"/>
<use xlink:href="#code-x"/>
</symbol>
<symbol id="code-9">
<path d="M7,10h-2c-1.1,0-2,0.9-2,2v2 c0,1.1,0.9,2,2,2h2v2h-3c-0.55,0-1,0.45-1,1v0c0,0.55,0.45,1,1,1h3c1.1,0,2-0.9,2-2V12C9,10.9,8.1,10,7,10z M7,14h-2V12h2V14z"/>
<use xlink:href="#code-x"/>
</symbol>
<!--not based on Material Design Icons-->
<symbol id="map-item-a">
<circle cx="12" cy="12" r="6" fill="#d33"/>
</symbol>
<symbol id="map-item-b">
<circle cx="12" cy="12" r="6" fill="#36c"/>
</symbol>
<symbol id="map-item-c">
<circle cx="12" cy="12" r="6" fill="#282"/>
</symbol>
<symbol id="map-item-d">
<circle cx="12" cy="12" r="6" fill="#fc3"/>
</symbol>
<symbol id="map-item-e">
<circle cx="12" cy="12" r="6" fill="#80e"/>
</symbol>
<symbol id="map-tile-a">
<rect x="0" y="0" width="24" height="24" fill="#d33"/>
</symbol>
<symbol id="map-tile-b">
<rect x="0" y="0" width="24" height="24" fill="#36c"/>
</symbol>
<symbol id="map-tile-c">
<rect x="0" y="0" width="24" height="24" fill="#282"/>
</symbol>
<symbol id="map-tile-d">
<rect x="0" y="0" width="24" height="24" fill="#fc3"/>
</symbol>
<symbol id="map-tile-e">
<rect x="0" y="0" width="24" height="24" fill="#80e"/>
</symbol>
<symbol id="map-tile-f">
<rect x="0" y="0" width="24" height="24" fill="#000"/>
</symbol>
<symbol id="map-tile-g">
<rect x="0" y="0" width="24" height="24" fill="#aaa"/>
</symbol>
<symbol id="map-r0">
<rect x="3" y="9" width="18" height="9" fill="#000"/>
<rect x="6" y="9" width="12" height="12" fill="#aaa"/>
<circle cx="12" cy="9" r="6" fill="#aaa"/>
<path d="M9,12L12,9L15,12" fill="none" stroke="#000"/>
</symbol>
<symbol id="map-r1">
<use xlink:href="#map-r0" transform="rotate(90,12,12)"/>
</symbol>
<symbol id="map-r2">
<use xlink:href="#map-r0" transform="rotate(180,12,12)"/>
</symbol>
<symbol id="map-r3">
<use xlink:href="#map-r0" transform="rotate(270,12,12)"/>
</symbol>
</svg>
<div id="wrapper">
<header>
<button id="abort-button" class="button" hidden title="Back"><svg><use xlink:href="#back"/></svg></button>
<span>
<input type="checkbox" id="sound-checkbox">
<label for="sound-checkbox" class="button"><svg class="on" title="Sound off"><use xlink:href="#note-on"/></svg><svg class="off" title="Sound on"><use xlink:href="#note-off"/></svg></label>
</span>
<h1 id="title"></h1>
</header>
<div id="level-menu">
</div>
<div id="level-wrapper" hidden>
<div id="editor-area" hidden>
Size: <input id="width-input" type="number" min="1" max="10">x<input id="height-input" type="number" min="1" max="10">
<button id="play-button">Play level</button>
<div id="radio-input"></div>
</div>
<div id="map"></div>
<div id="run-area">
<div id="code"></div>
<button id="insert-go" data-key="_" class="button" title="Advance one step"></button>
<button id="insert-left" data-key="<" class="button" title="Turn left"></button>
<button id="insert-right" data-key=">" class="button" title="Turn right"></button>
<button id="insert-up" data-key="," class="button" title="Take item"></button>
<button id="insert-down" data-key="." class="button" title="Drop item"></button>
<button id="insert-repeat" data-key="2)" class="button" title="Repeat code"></button>
<br>
<button id="button-left" class="button" data-key="left" title="Cursor left"><svg><use xlink:href="#left"/></svg></button>
<button id="button-right" class="button" data-key="right" title="Cursor right"><svg><use xlink:href="#right"/></svg></button>
<button id="button-minus" class="button" data-key="minus" title="Decrement number of repetitions"><svg><use xlink:href="#minus"/></svg></button>
<button id="button-plus" class="button" data-key="plus" title="Increment number of repetitions"><svg><use xlink:href="#plus"/></svg></button>
<button id="button-del" class="button" data-key="del" title="Delete char"><svg><use xlink:href="#del"/></svg></button>
<br>
<button id="run-button" class="button" title="Start robot"><svg class="go"><use xlink:href="#go"/></svg></button>
<button id="cancel-button" class="button" title="Abort robot"><svg class="cancel"><use xlink:href="#cancel"/></svg></button>
<button id="reset-button" class="button" title="Reset robot"><svg class="reset"><use xlink:href="#reset"/></svg></button>
<input id="pause-input" type="range" min="0" max="8" value="4" autocomplete="off">
<div id="error"></div>
</div>
</div>
</div>
<aside id="overlay">
<div>
<div id="info-box"></div>
<button id="info-close">OK</button>
</div>
</aside>
</body></html>