Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
228 lines (191 sloc) 5.29 KB
<!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, "&lt;").replace(/>/g, "&gt;");
}
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>