-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgame.html
65 lines (61 loc) · 1.64 KB
/
game.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jackdaw</title>
<link rel="stylesheet" type="text/css" href="./resources/game.css">
</head>
<body>
<h1>Jackdaw</h1>
<canvas id="stage" width="800" height="400"></canvas>
<div id="elapsed">not started</div>
<script>
// configure curl
curl = {
apiName: 'require',
baseUrl: './lib',
pluginPath: '../lib/amd',
paths: {
curl: 'curl/src/curl',
'dollar': 'vendor/jquery-1.7',
tests: '../tests',
}
};
</script>
<script src="./lib/curl/src/curl.js"></script>
<script>
require([
'index', 'dom', 'lang'
]).then(function(game, dom, lang){
window.game = game;
function parseQueryString(str) {
var pairs = str.split(/&/),
params = {},
nv = null;
while((nv = pairs.shift())) {
nv = nv.split('=');
params[nv[0]] = nv[1];
}
return params;
}
var sinceNode = dom.byId("elapsed"),
qsConfig = parseQueryString(location.search ? location.search.substring(1) : ""),
gameConfig = lang.mixin({
canvasNode: dom.byId('stage')
}, qsConfig);
game.start( gameConfig ).then(function(){
game.emit('log', "and we're off...");
});
game.listen("update", function(time){
sinceNode.innerHTML = "delta: ${dt}, now: ${ts}".replace(/\$\{([^\}]+)\}/g, function(m, p){
return time[p];
});
});
setTimeout(function(){
// load assets, then
game.emit("loaded");
}, 500);
});
</script>
</body>
</html>