Path: blob/main/static/src/gs/public/hexgl/launch.js
1324 views
// Generated by CoffeeScript 1.7.11(function() {2var $, a, defaultControls, getWebGL, hasWebGL, init, s, u, _fn, _i, _len;34$ = function(_) {5return document.getElementById(_);6};78init = function(controlType, quality, hud, godmode) {9var hexGL, progressbar;10hexGL = new bkcore.hexgl.HexGL({11document: document,12width: window.innerWidth,13height: window.innerHeight,14container: $('main'),15overlay: $('overlay'),16gameover: $('step-5'),17quality: quality,18difficulty: 0,19hud: hud === 1,20controlType: controlType,21godmode: godmode,22track: 'Cityscape'23});24window.hexGL = hexGL;25progressbar = $('progressbar');26return hexGL.load({27onLoad: function() {28console.log('LOADED.');29hexGL.init();30$('step-3').style.display = 'none';31$('step-4').style.display = 'block';32return hexGL.start();33},34onError: function(s) {35return console.error("Error loading " + s + ".");36},37onProgress: function(p, t, n) {38console.log("LOADED " + t + " : " + n + " ( " + p.loaded + " / " + p.total + " ).");39return progressbar.style.width = "" + (p.loaded / p.total * 100) + "%";40}41});42};4344u = bkcore.Utils.getURLParameter;4546defaultControls = bkcore.Utils.isTouchDevice() ? 1 : 0;4748s = [['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: ']];4950_fn = function(a) {51var e, f, _ref;52a[3] = (_ref = u(a[0])) != null ? _ref : a[2];53e = $("s-" + a[0]);54(f = function() {55return e.innerHTML = a[4] + a[1][a[3]];56})();57return e.onclick = function() {58return f(a[3] = (a[3] + 1) % a[1].length);59};60};61for (_i = 0, _len = s.length; _i < _len; _i++) {62a = s[_i];63_fn(a);64}6566$('step-2').onclick = function() {67$('step-2').style.display = 'none';68$('step-3').style.display = 'block';69return init(s[0][3], s[1][3], s[2][3], s[3][3]);70};7172$('step-5').onclick = function() {73return window.location.reload();74};7576$('s-credits').onclick = function() {77$('step-1').style.display = 'none';78return $('credits').style.display = 'block';79};8081$('credits').onclick = function() {82$('step-1').style.display = 'block';83return $('credits').style.display = 'none';84};8586hasWebGL = function() {87var canvas, gl;88gl = null;89canvas = document.createElement('canvas');90try {91gl = canvas.getContext("webgl");92} catch (_error) {}93if (gl == null) {94try {95gl = canvas.getContext("experimental-webgl");96} catch (_error) {}97}98return gl != null;99};100101if (!hasWebGL()) {102getWebGL = $('start');103getWebGL.innerHTML = 'WebGL is not supported!';104getWebGL.onclick = function() {105return window.location.href = 'http://get.webgl.org/';106};107} else {108$('start').onclick = function() {109$('step-1').style.display = 'none';110$('step-2').style.display = 'block';111return $('step-2').style.backgroundImage = "url(css/help-" + s[0][3] + ".png)";112};113}114115}).call(this);116117118