-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
152 lines (141 loc) · 4.29 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
<!doctype html>
<html prefix="og: http://ogp.me/ns#">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=320, user-scalable=0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta property="og:image" content="og.gif" />
<title>SUBLEERUNKER</title>
<link rel="shortcut icon" type="image/icon" href="favicon.ico" />
<style type="text/css">
@import url('https://fonts.googleapis.com/css?family=Share+Tech+Mono');
html {
height: 100%;
}
body {
position: relative;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #000;
/* Diable selection */
user-select: none;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
.bezel {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
outline: 1px solid #333;
}
</style>
<script src="lib/jquery-3.2.1.min.js"></script>
<script src="lib/pixi-4.5.1.min.js"></script>
<script src="lib/classy-1.4.min.js"></script>
<script src="lib/seedrandom-2.4.3.min.js"></script>
<script src="lib/js.cookie-3.0.0-rc.0.min.js"></script>
<script src="godreal.js"></script>
<script src="subleerunker.js"></script>
</head>
<body>
<div class="bezel"></div>
<script>
// Parse querystring.
function parseQuerystring(querystring) {
var query = {};
var parts = querystring.slice(1).split('&');
$.each(parts, function(i, part) {
var words = part.split('=');
var key = decodeURIComponent(words[0]);
var value = decodeURIComponent(words[1] || '');
query[key] = value;
});
return query;
}
var QUERY = {};
$.extend(QUERY, parseQuerystring(location.search));
$.extend(QUERY, parseQuerystring(location.hash));
// Setup context and init debug mode.
var ctx = {
debug: (QUERY.debug !== undefined),
triggerEvents: true,
randomSeed: parseInt(QUERY.seed, 16)
};
if (ctx.debug) {
$(document.head).append('<script src="lib/stats-r17.min.js">');
var stats = new Stats();
stats.flames = stats.addPanel(new Stats.Panel('flames', '#ff8', '#221'));
stats.showPanel(0);
$(document.body).append(stats.dom);
}
// Disable anti-aliasing.
PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST;
// Use WebGL if queried.
if (QUERY.webgl !== undefined) {
Subleerunker.prototype.rendererClass = PIXI.WebGLRenderer;
}
// Limit cookie scope.
var cookies = Cookies.withAttributes({
path: location.pathname,
secure: true,
sameSite: 'none'
});
// Set a champion URL.
if (/^https:\/\/sublee.github.io/.exec(location.href)) {
ctx.championURL = 'https://subleerunker-166907.appspot.com/champion';
}
// Init the game.
var game = Subleerunker(ctx);
game.elem().appendTo('.bezel');
game.watch(window, document, {
resize: function(scale) {
$(document.body).css({
minWidth: this.width * scale,
minHeight: this.height * scale
});
}
});
// Enable stats.js.
if (ctx.debug) {
function countFlames(game) {
var numFlames = 0;
$.each(game.children, function(i, child) {
if (child instanceof Subleerunker.Flame) numFlames++;
});
return numFlames;
}
var before = function(time) { stats.begin(); };
var after = function(time) {
stats.end();
stats.flames.update(countFlames(this), 100);
};
}
// Set replay.
if (QUERY.replay) {
var replay = Replay.decode(QUERY.replay);
game.loadReplay(replay);
}
// Run the game.
var fps = QUERY.fps && Number(QUERY.fps);
game.run(fps, before, after);
// Report replay URL on console.
$(window).on('gameOver', function(e, score, replay) {
if (window.console === undefined) {
return;
}
var encodedReplay = Replay.encode(replay);
var replayQuerystring = '?replay=' + encodeURIComponent(encodedReplay);
var replayURL = location.href.replace(/(\?.*)?$/, replayQuerystring);
console.log(replayURL);
});
</script>
<script src="ga.js"></script>
</body>
</html>