-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
227 lines (191 loc) · 5.29 KB
/
index.html
File metadata and controls
227 lines (191 loc) · 5.29 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
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
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Volcanox</title>
<style type="text/css">
body {
font-family: sans-serif;
text-align: center;
}
embed {
display: block;
}
textarea {
width: 550px;
height: 300px;
}
body {
margin-top: 40px;
background: #eee;
}
#quick_list li {
text-decoration: underline;
cursor: pointer;
color: #333;
}
.box {
vertical-align: top;
background: white;
padding: 8px;
margin: 8px;
display: inline-block;
box-shadow: 0px 0px 8px rgba(0,0,0, 0.3);
}
#editor:not(.visible) {
display: none;
}
.list {
display: inline-block;
}
#editor .buttons {
text-align: right;
}
.err {
color: #FF7575;
}
.console {
text-align: left;
background: #333;
color: white;
padding: 12px;
margin; 4px;
width: 550px;
}
.footer {
font-size: 11px;
color: #444;
}
a {
color: #666;
}
#game {
position: relative;
}
#editor:not(.visible) {
display: none;
}
</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-136625-7']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div>
<div id="game_container" class="box"></div>
<div id="editor" class="box">
<textarea id="input"></textarea>
<div class="buttons">
<span class="loading">Loading...</span>
<button id="run" disabled="disabled">Execute</button>
<button id="clear_code" disabled="disabled">Clear Code</button>
<button id="clear_console" disabled="disabled">Clear Console</button>
</div>
<pre class="console" id="output">
</pre>
</div>
</div>
<div class="footer">
<div>
Volcanox was created by <a href="http://leafo.net">leafo</a> for Ludum Dare 22
</div>
<div>
Written in <a href="http://moonscript.org/">MoonScript</a>, running on
<a href="http://leafo.net/aroma">Aroma</a>
</div>
<div>
<a href="https://github.com/leafo/ludum-dare-22">Source</a>.
<a href="#" id="toggle_console">Toggle Console</a>
</div>
</div>
<script type="text/javascript" src="js/aroma.js"></script>
<script type="text/javascript">
(function() {
$ = function(name) { return document.getElementById(name); }
A = function(thing) { return Array.prototype.slice.apply(thing) };
var output = $("output");
function escape_html(str) {
return str.replace(/</g, "<").replace(/>/g, ">");
}
game = new Aroma($("game_container"), 800, 400, {
loaded: function() {
A(document.querySelectorAll(".loading")).map(function(e) {
e.style.display = "none";
});
A(document.querySelectorAll(".buttons button")).map(function(b) {
b.disabled = false;
});
run();
},
std_out: function(str) {
output.innerHTML += escape_html(str) + "\n";
},
std_err: function(str) {
output.innerHTML += "<span class='err'>" +
escape_html(str) + "</span>\n";
}
});
function e(items) {
items = items.map(function(i) {
return '"' + i + '"';
});
return items.join(",\n");
}
var code = [
"background.lua", "collide.lua", "conf.lua", "enemy.lua", "main.lua",
"map.lua", "particle.lua", "player.lua", "spriter.lua", "ui.lua"
];
var images = [
"images/bg1.png", "images/bg2.png", "images/enemy.png",
"images/map1.png", "images/player.png", "images/tiles.png",
"images/title.png",
];
var sound = [
"sound/hit_me.wav", "sound/hit_monster.wav", "sound/hit_wall.wav",
"sound/jump.wav", "sound/shot.wav", "sound/start.wav",
];
var music = [
"sound/theme.ogg",
];
$("toggle_console").onclick = function(e) {
var editor = $("editor");
if (editor.className.match(/visible/)) {
editor.className = editor.className.replace(/visible/, "");
} else {
editor.className += " visible";
}
};
$("input").value = [
'nacl.prefetch {',
e(code),
',image = {' + e(images) + '}',
',sound = {' + e(sound) + '}',
// ',music = {' + e(music) + '}',
'}',
'nacl.track_event("Volcanox", "load", "time", aroma.timer.getTime())',
'require "main"',
'aroma.load()',
].join("\n");
function run() {
var code = $("input").value;
output.innerHTML = "";
game.execute(code);
}
$("run").onclick = run;
$("clear_code").onclick = function() {
$("input").value = "";
}
$("clear_console").onclick = function() {
$("output").innerHTML = "";
};
})();
</script>
</body>
</html>