Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mamayaya1
GitHub Repository: mamayaya1/game
Path: blob/main/projects/HexGL/launch.js
4626 views
1
// Generated by CoffeeScript 1.7.1
2
(function() {
3
var $, a, defaultControls, getWebGL, hasWebGL, init, s, u, _fn, _i, _len;
4
5
$ = function(_) {
6
return document.getElementById(_);
7
};
8
9
init = function(controlType, quality, hud, godmode) {
10
var hexGL, progressbar;
11
hexGL = new bkcore.hexgl.HexGL({
12
document: document,
13
width: window.innerWidth,
14
height: window.innerHeight,
15
container: $('main'),
16
overlay: $('overlay'),
17
gameover: $('step-5'),
18
quality: quality,
19
difficulty: 0,
20
hud: hud === 1,
21
controlType: controlType,
22
godmode: godmode,
23
track: 'Cityscape'
24
});
25
window.hexGL = hexGL;
26
progressbar = $('progressbar');
27
return hexGL.load({
28
onLoad: function() {
29
console.log('LOADED.');
30
hexGL.init();
31
$('step-3').style.display = 'none';
32
$('step-4').style.display = 'block';
33
return hexGL.start();
34
},
35
onError: function(s) {
36
return console.error("Error loading " + s + ".");
37
},
38
onProgress: function(p, t, n) {
39
console.log("LOADED " + t + " : " + n + " ( " + p.loaded + " / " + p.total + " ).");
40
return progressbar.style.width = "" + (p.loaded / p.total * 100) + "%";
41
}
42
});
43
};
44
45
u = bkcore.Utils.getURLParameter;
46
47
defaultControls = bkcore.Utils.isTouchDevice() ? 1 : 0;
48
49
s = [['controlType', ['KEYBOARD', 'TOUCH', 'LEAP MOTION CONTROLLER', 'GAMEPAD'], defaultControls, defaultControls, 'Controls: '], ['quality', ['LOW', 'MID', 'HIGH', 'VERY HIGH'], 3, 3, 'Quality: '], ['hud', ['OFF', 'ON'], 1, 1, 'HUD: '], ['godmode', ['OFF', 'ON'], 0, 1, 'Godmode: ']];
50
51
_fn = function(a) {
52
var e, f, _ref;
53
a[3] = (_ref = u(a[0])) != null ? _ref : a[2];
54
e = $("s-" + a[0]);
55
(f = function() {
56
return e.innerHTML = a[4] + a[1][a[3]];
57
})();
58
return e.onclick = function() {
59
return f(a[3] = (a[3] + 1) % a[1].length);
60
};
61
};
62
for (_i = 0, _len = s.length; _i < _len; _i++) {
63
a = s[_i];
64
_fn(a);
65
}
66
67
$('step-2').onclick = function() {
68
$('step-2').style.display = 'none';
69
$('step-3').style.display = 'block';
70
return init(s[0][3], s[1][3], s[2][3], s[3][3]);
71
};
72
73
$('step-5').onclick = function() {
74
return window.location.reload();
75
};
76
77
hasWebGL = function() {
78
var canvas, gl;
79
gl = null;
80
canvas = document.createElement('canvas');
81
try {
82
gl = canvas.getContext("webgl");
83
} catch (_error) {}
84
if (gl == null) {
85
try {
86
gl = canvas.getContext("experimental-webgl");
87
} catch (_error) {}
88
}
89
return gl != null;
90
};
91
92
if (!hasWebGL()) {
93
getWebGL = $('start');
94
getWebGL.innerHTML = 'WebGL is not supported!';
95
getWebGL.onclick = function() {
96
return window.location.href = 'http://get.webgl.org/';
97
};
98
} else {
99
$('start').onclick = function() {
100
$('step-1').style.display = 'none';
101
$('step-2').style.display = 'block';
102
return $('step-2').style.backgroundImage = "url(css/help-" + s[0][3] + ".png)";
103
};
104
}
105
106
}).call(this);
107
108