Path: blob/main/static/src/gs/public/hexgl/launch.coffee
1325 views
$ = (_) -> document.getElementById _12init = (controlType, quality, hud, godmode) ->3hexGL = new bkcore.hexgl.HexGL(4document: document5width: window.innerWidth6height: window.innerHeight7container: $ 'main'8overlay: $ 'overlay'9gameover: $ 'step-5'10quality: quality11difficulty: 012hud: hud is 113controlType: controlType14godmode: godmode15track: 'Cityscape'16)17window.hexGL=hexGL1819progressbar = $ 'progressbar'20hexGL.load(21onLoad: ->22console.log 'LOADED.'23hexGL.init()24$('step-3').style.display = 'none'25$('step-4').style.display = 'block'26hexGL.start()27onError: (s) ->28console.error "Error loading #{ s }."29onProgress: (p, t, n) ->30console.log("LOADED "+t+" : "+n+" ( "+p.loaded+" / "+p.total+" ).")31progressbar.style.width = "#{ p.loaded / p.total * 100 }%"32)3334u = bkcore.Utils.getURLParameter3536defaultControls = if bkcore.Utils.isTouchDevice() then 1 else 03738s = [39['controlType', ['KEYBOARD', 'TOUCH', 'LEAP MOTION CONTROLLER',40'GAMEPAD'], defaultControls, defaultControls, 'Controls: ']41['quality', ['LOW', 'MID', 'HIGH', 'VERY HIGH'], 3, 3, 'Quality: ']42['hud', ['OFF', 'ON'], 1, 1, 'HUD: ']43['godmode', ['OFF', 'ON'], 0, 1, 'Godmode: ']44]4546for a in s47do(a)->48a[3] = u(a[0]) ? a[2]49e = $ "s-#{a[0]}"50(f = -> e.innerHTML = a[4]+a[1][a[3]])()51e.onclick = -> f(a[3] = (a[3]+1)%a[1].length)52$('step-2').onclick = ->53$('step-2').style.display = 'none'54$('step-3').style.display = 'block'55init s[0][3], s[1][3], s[2][3], s[3][3]56$('step-5').onclick = ->57window.location.reload()58$('s-credits').onclick = ->59$('step-1').style.display = 'none'60$('credits').style.display = 'block'61$('credits').onclick = ->62$('step-1').style.display = 'block'63$('credits').style.display = 'none'6465hasWebGL = ->66gl = null67canvas = document.createElement('canvas');68try69gl = canvas.getContext("webgl")70if not gl?71try72gl = canvas.getContext("experimental-webgl")73return gl?7475if not hasWebGL()76getWebGL = $('start')77getWebGL.innerHTML = 'WebGL is not supported!'78getWebGL.onclick = ->79window.location.href = 'http://get.webgl.org/'80else81$('start').onclick = ->82$('step-1').style.display = 'none'83$('step-2').style.display = 'block'84$('step-2').style.backgroundImage = "url(css/help-#{s[0][3]}.png)"858687