Created
April 6, 2011 20:29
-
-
Save jeffgca/906457 to your computer and use it in GitHub Desktop.
Unpacked JS source from http://cycleblob.com/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function webGLStart() { | |
cJ = document.getElementById("game-canvas"); | |
!cD(cJ) || (cK = document.getElementById("ctrl-canvas"), cL = cK.getContext("2d"), cP(null, !0), cN.showStartScreen(cL), cE.init($("#shadersFrame").contents().find("#phong-fs"), $("#shadersFrame").contents().find("#phong-vs")), window.onresize = cP, $("#fpsui").text("FPS: 0"), cl("models/bikePlayer2.json", "inlined", "bike", ck), cl("models/lifeWheel.json", "indexed", "life", ck), cb.explode = { | |
ring: {} | |
}, Y(cb.explode), bY(), WebGLUtils.requestAnimationFrame(cJ, cA), setInterval(cB, 1e3)) | |
} | |
function cP(a, b) { | |
var c = 20; | |
drawDiv = document.getElementById("canvas-container"); | |
var d = Math.round(drawDiv.offsetWidth / c) * c; | |
if (d !== cJ.width || !! b) { | |
d < 600 && (d = 600), cC.viewportWidth = cJ.width = cK.width = d; | |
var e = d * .7; | |
drawDiv.style.height = e + "px", cC.viewportHeight = cJ.height = cK.height = e, cN.resizeAdjust(cK.width, cK.height), cm("canvas resized: " + cJ.width + " x " + cJ.height) | |
} | |
} | |
function cO(a) { | |
a !== cM && (a ? (cM = !0, cy = 0) : (cC.viewport(0, 0, cJ.width, cJ.height), cC.clear(cC.COLOR_BUFFER_BIT | cC.DEPTH_BUFFER_BIT), cM = !1)) | |
} | |
function cD(a) { | |
cC = WebGLUtils.setupWebGL(a, { | |
antialias: !0, | |
stencil: !1, | |
alpha: !0 | |
}); | |
if (!cC) return !1; | |
cC.viewportWidth = a.width, cC.viewportHeight = a.height, cC.clearColor(0, 0, 0, 1), cC.clearDepth(1), cC.blendFunc(cC.SRC_ALPHA, cC.ONE_MINUS_SRC_ALPHA), cC.enable(cC.DEPTH_TEST), cC.depthFunc(cC.LEQUAL), h("init"); | |
return !0 | |
} | |
function cB() { | |
if (!(!cF.ready || !cb._ready || !cM || bN.isPaused())) { | |
var a = cF.bonuses.length > 0 ? .2 : 3; | |
g(a) && bi() | |
} | |
} | |
function cA() { | |
WebGLUtils.requestAnimationFrame(cJ, cA); | |
var a = (new Date).getTime(), | |
b = 0; | |
if (cy != 0) b = a - cy; | |
else { | |
cm("RESET time"), cy = a; | |
return | |
} | |
cy = a, K(cG), cN.has3dContent && cN.draw3d(b); | |
if (!(!cF.ready || !cb._ready || !cM)) { | |
var c = cw(b); | |
cM && cu(), bL.printFps && cx(b) | |
} | |
} | |
function cw(a) { | |
var b = !1, | |
c = []; | |
for (var d = 0; d < cH.length; ++d) { | |
var e = cH[d]; | |
if (e.alive) { | |
var f = 0; | |
bN.isPaused() || (f = cF.model.scale.BASE_SPEED * a), e.dNow2Last += f, e.dNow2Point -= f, e.lastMadeMoves = 0; | |
while (e.dNow2Point < 0) { | |
e.ai && e.ai.moveControl(cF); | |
var g = cv(e); | |
e.dNow2Last = -e.dNow2Point, e.dNow2Point += g.dist, e.lastMvDist = g.dist, b = !0, ++e.lastMadeMoves; | |
if (g.collide) break | |
} | |
e.alive && !bN.isPaused() && (e.curStepFrac = e.dNow2Last / e.lastMvDist), cI.moveUpdate(e), e.lastMadeMoves > 1 && cm("made " + e.lastMadeMoves + " moves elapsed=" + a) | |
} | |
for (var h in e.sfx) e.sfx[h] && (e.sfx[h].advance(a), b = !0) | |
} | |
for (var h in cF.staticDraw) cF.staticDraw[h].advance(a); | |
for (var i in cF.bonuses) cF.bonuses[i].advance(a); | |
return b | |
} | |
function cv(a) { | |
var b = a.point, | |
c = a.selDir.move.call(a), | |
d = cF.map[a.point]; | |
if (d !== undefined) if (d < 0) { | |
var e = d + 100; | |
cF.bonuses[e] && cF.bonuses[e].action(a) | |
} else bT(a, d); | |
cF.map[b] = a.id + 100, d === undefined && (cF.map[a.point] = a.id); | |
return { | |
dist: c, | |
collide: d | |
} | |
} | |
function cu() { | |
cC.viewport(0, 0, cC.viewportWidth, cC.viewportHeight), cC.clear(cC.COLOR_BUFFER_BIT | cC.DEPTH_BUFFER_BIT), ++cz, o.perspective(45, cJ.width / cJ.height, .1 + cI.addNearClip, 100), ct(), n.loadIdentity(); | |
for (var a in cF.staticDraw) cF.staticDraw[a].render(); | |
var c = cI.getCamera(); | |
n.multMatrix(d.lookAt(c.eye, c.toPoint, c.upDir)), bL.debug && n.multMatrix(B.rotationMatrix), cE.setColor(1, 1, 1), cE.setTwoSided(c.twoSided), cq(cF.model); | |
for (var e = 0; e < cH.length; ++e) { | |
cE.setTwoSided(!1); | |
var f = cH[e]; | |
if (f.wall.standing) { | |
var g = f.alive && f.wall.fracExtend(f), | |
h = f.trailColor; | |
if (f.sfx.wall_decent) { | |
var i = f.sfx.wall_decent.brightness * .6; | |
h = b.nadd(h, [i, i, i]) | |
} | |
cE.setColorv(h), cE.setMatrixUniforms(), f.wall.vtxBuf.bind(), cC.vertexAttribPointer(cE.vertexPositionAttribute, f.wall.vtxBuf.itemSize, cC.FLOAT, !1, 0, 0), cC.bindBuffer(cC.ARRAY_BUFFER, null), f.wall.normalsBuf.bind(), cC.vertexAttribPointer(cE.vertexNormalAttribute, f.wall.normalsBuf.itemSize, cC.FLOAT, !1, 0, 0), f.wall.idxRbuf.bind(), cC.drawElements(cC.TRIANGLE_STRIP, f.wall.idxRbuf.numItems, cC.UNSIGNED_SHORT, 0), f.wall.idxLbuf.bind(), cC.drawElements(cC.TRIANGLE_STRIP, f.wall.idxLbuf.numItems, cC.UNSIGNED_SHORT, 0), f.wall.idxTbuf.bind(), cC.drawElements(cC.TRIANGLE_STRIP, f.wall.idxTbuf.numItems, cC.UNSIGNED_SHORT, 0), g && f.wall.backtrackRawPoint() | |
} | |
f.alive && (cE.setTwoSided(!0), n.pushMatrix(), cs(f), f.alive && (n.rotateX(-90), cI.bikeFlip && n.rotateY(180), n.scale(cF.model.scale.BIKE_SCALE), n.translate([0, 2, 1.3]), cq(f.model, f.modelColor)), n.popMatrix()) | |
} | |
for (var e = 0; e < cH.length; ++e) { | |
var f = cH[e]; | |
f.sfx.explode && (n.pushMatrix(), cs(f), f.sfx.explode.draw(), n.popMatrix()) | |
} | |
for (var j in cF.bonuses) cF.bonuses[j].draw() | |
} | |
function ct() { | |
var a = !0; | |
cE.setUseLight(a); | |
if (a) { | |
var b = { | |
rgb: [.2, .2, .2] | |
}; | |
cC.uniform3f(cE.ambientColorUniform, b.rgb[0], b.rgb[1], b.rgb[2]); | |
var c = cI.getLight(); | |
cC.uniform3f(cE.pointLightingLocationUniform, c[0], c[1], c[2]); | |
var d = { | |
rgb: [.8, .8, .8] | |
}; | |
cC.uniform3f(cE.pointLightingDiffuseColorUniform, d.rgb[0], d.rgb[1], d.rgb[2]) | |
} | |
} | |
function cs(a) { | |
var c = a.curStepFrac, | |
d = b.linearMix(cF.model.vtx[a.point], cF.model.vtx[a.last.point], c); | |
n.translate(d); | |
var e = a.getBikeOrient(), | |
f = cr(a.rightHand, e.normal, e.forward); | |
n.multMatrix(f) | |
} | |
function cr(a, b, d) { | |
var e = c.create([a[0], a[1], a[2], b[0], b[1], b[2], d[0], d[1], d[2]]); | |
return c.toMat4(e) | |
} | |
function cq(a, b) { | |
a.vertexBuffer && (a.vertexBuffer.bind(), cC.vertexAttribPointer(cE.vertexPositionAttribute, a.vertexBuffer.itemSize, cC.FLOAT, !1, 0, 0)), a.vNormalBuffer && (a.vNormalBuffer.bind(), cC.vertexAttribPointer(cE.vertexNormalAttribute, a.vNormalBuffer.itemSize, cC.FLOAT, !1, 0, 0)), cE.setMatrixUniforms(), cp(a); | |
if (a.groups) for (var c in a.groups) cp(a.groups[c], b) | |
} | |
function cp(a, b) { | |
a.triangles && (a.triangles.bind(), cC.drawElements(cC.TRIANGLES, a.triangles.numItems, a.triangles.type, 0)), a.triangleStrip && (a.triangleStrip.bind(), cC.drawElements(cC.TRIANGLE_STRIP, a.triangleStrip.numItems, a.triangleStrip.type, 0)), a.lines && (cC.lineWidth(3), a.lines.bind(), cC.drawElements(cC.LINES, a.lines.numItems, a.lines.type, 0)), a.trianglesInline && (a.diffuseColor ? cE.setColor(a.diffuseColor[0], a.diffuseColor[1], a.diffuseColor[2]) : b && cE.setColorv(b), a.vertexBuffer.bind(), cC.vertexAttribPointer(cE.vertexPositionAttribute, a.vertexBuffer.itemSize, cC.FLOAT, !1, 0, 0), a.vNormalBuffer.bind(), cC.vertexAttribPointer(cE.vertexNormalAttribute, a.vNormalBuffer.itemSize, cC.FLOAT, !1, 0, 0), cC.drawArrays(cC.TRIANGLES, 0, a.vertexBuffer.numItems)) | |
} | |
function cl(a, b, c, d, e) { | |
cd(c, "loading"); | |
var f = $.getJSON(a, {}, function(a) { | |
if (b === "indexed") { | |
var f = {}; | |
N(a, f), d( | |
c, f, e) | |
} else if (b === "inlined") { | |
var f = {}; | |
O(a, f), d(c, f, e) | |
} else if (b === "none") d(c, a, e); | |
else | |
throw "unknown load method" | |
}) | |
} | |
function ck(a, b) { | |
cb[a] = b, cd(a, null), cb.life && cb.bike && (cb._ready = !0, h("rcsinit")) | |
} | |
function cj(a, b, c) { | |
var d = bK[a]; | |
if (d === undefined) throw new Error("level not found"); | |
if (cb[d.worldModel] !== undefined && cb[d.worldModel].model !== undefined) c && c(); | |
else { | |
var e = !0; | |
for (var f = 0; f < a; ++f) cg(bK[f].worldModel); | |
for (var f = a + b; f < bK.length; ++f) cg(bK[f].worldModel); | |
for (var f = 0; f < b; ++f) ci(a + f, !0, e); | |
c && ce(c) | |
} | |
} | |
function ci(a, b, c) { | |
if ( !! bK[a]) { | |
var d = bK[a].worldModel; | |
if (cb[d] === undefined || cb[d].input === undefined) { | |
cl(worldModels[d].file, "none", d, ch, { | |
gridProc: b, | |
async: c | |
}); | |
return | |
} | |
cb[d].model === undefined && b && cf(d, c) | |
} | |
} | |
function ch(a, b, c) { | |
var d = { | |
input: b, | |
name: a | |
}; | |
cb[a] = d, c.gridProc ? cf(a, c.async) : cd(a, null) | |
} | |
function cg(a) { !! cb[a] && !! cb[a].model && (cm("deleting " + a), delete cb[a].model) | |
} | |
function cf(a, b) { | |
cd(a, "processing"); | |
var c = cb[a], | |
d = {}, | |
e = (new Date).getTime(); | |
cm("start " + a), S(c.input, d), Q(d, b, function() { | |
c.model = d, cm("done " + a + " " + ((new Date).getTime() - e)), cd(a, null) | |
}, function(a) { | |
if (cc.onprogress) return cc.onprogress(a); | |
return !0 | |
}) | |
} | |
function ce(a) { | |
if (Object.keys(cc.items).length === 0) a(); | |
else { | |
cN.loadingScreen(0), cc.ondone = | |
a; | |
var b = -1; | |
cc.onprogress = function(a) { | |
cN.loadingScreen(a); | |
return !1 | |
} | |
} | |
} | |
function cd(a, b) { | |
b === null ? (delete cc.items[a], cc.ondone && Object.keys(cc.items).length === 0 && (cc.onprogress = null, cc.ondone(), cc.ondone = null)) : cc.items[a] = b | |
} | |
function ca(a) { | |
if ( !! bN.soundEnabled) { | |
var b = a === cG ? 1 : .2; | |
bX.bonus.play(b) | |
} | |
} | |
function b_(a) { | |
if ( !! bN.soundEnabled) { | |
var b = a === cG ? 1 : .2; | |
bX.crash.play(b) | |
} | |
} | |
function b$() { | |
!bN.soundEnabled || bX.start.play(.4) | |
} | |
function bZ(a) { | |
!bN.soundEnabled || bX.turn.play(1) | |
} | |
function bY() { | |
bX = {}, bX.turn = new bW($("#turnSound1")[0], 5), bX.start = new bW($("#powerupSound")[0], 1), bX.crash = new bW($("#crashSound")[0], 2), bX.bonus = new bW($("#coinUp")[0], 1) | |
} | |
function bW(a, b) { | |
this.numChannels = b, this.curChannel = 0, this.players = [], this.players[0] = a; | |
for (var c = 1; c < this.numChannels; ++c) { | |
var d = new Audio; | |
d.src = a.src, d.load(), this.players[c] = d | |
} | |
} | |
function bV() { | |
var a, b, c = 0, | |
d; | |
do { | |
if (c++ > 10) return [null]; | |
a = f(0, cF.model.vtx.length - 1); | |
if (cF.map[a] !== undefined) continue; | |
d = cF.model.nei[a].t, b = !0; | |
for (var e in d) b |= cF.map[d[e]] === undefined | |
} while (!b); | |
var g = [a]; | |
for (var e in d) g.push(d[e]); | |
return g | |
} | |
function bU(a, b) { | |
var c; | |
if (b >= 100) { | |
var d = b - 100; | |
d === a.id ? c = a.prettyName() + " collided with its own wall" : c = a.prettyName() + " collided with wall of " + cH[d].prettyName() | |
} else { | |
var d = b; | |
c = a.prettyName() + " collided with " + cH[d].prettyName() | |
} | |
cN.addMessage(c), cm(c + " on " + a.point) | |
} | |
function bT(a, b) { | |
be(a, b), b_(a), bU(a, b); | |
if (!bL.disableDeath) { | |
a.curStepFrac = 1, a.wall.deathEnd(a), a.alive = !1, bh(a); | |
if (a === cG)--bN.userLivesCount, bQ.called === !1 && (bQ = { | |
handler: bR, | |
called: !1 | |
}); | |
else { | |
var c = 0; | |
for (var d = 0; d < cH.length; ++d) cH[d].alive && ++c; | |
c === 1 && bQ.called === !1 && (bQ = { | |
handler: bS, | |
called: !1 | |
}) | |
} | |
} | |
} | |
function bS() { | |
bQ.called = !0; | |
bL.disableEndLevel || (bN.setAbsPaused(!0), cN.levelComplete(bN.currentLevelNum, bN.currentLevel)) | |
} | |
function bR() { | |
bQ.called = !0, cF.staticDraw.lives.startDeath(), cm("lives remaining: " + bN.userLivesCount), bN.userLivesCount > 0 ? cN.lifeEndScreen(bN.currentLevel, bN.currentLevelNum) : cN.gameOverScreen(bN.currentLevel, bN.currentLevelNum) | |
} | |
function bP(a) { | |
bN.currentLevelNum = 0, bN.userLivesCount = 3, bI(a ? a : 0) | |
} | |
function bO() { | |
L(cJ, cK) | |
} | |
function bM() { | |
this.currentLevelNum = 0, this.currentLevel = null, this.userLivesCount = 3, this._paused = 0, this._startPause = !1; | |
var a = $.cookie("enableSound"); | |
this.soundEnabled = a !== null ? a === "true" : !0 | |
} | |
function bI(a) { | |
var b, c; | |
typeof a == "number" ? (b = bK[a], c = a) : (b = a, c = -1), cm("** START" + a); | |
if (b === undefined || cb[b.worldModel] === undefined || cb[b.worldModel].model === undefined) throw new Error("not implemented"); | |
cF = { | |
ready: !1 | |
}, cF.model = cb[b.worldModel].model, b$(), bN.currentLevelNum = c, bN.currentLevel = b, cH = []; | |
for (var d = 0; d < b.numPlayers; ++d) { | |
var e = f(0, cF.model.vtx.length - 1), | |
g = new w(d, cb.bike, e); | |
d !== bL.userIndex && (g.ai = new _(g, b.ai)), cH.push(g) | |
} | |
bL.userIndex >= 0 ? (cG = cH[bL.userIndex], cG.turnCallback = bZ) : cG = cH[0]; | |
for (var h in cH) cH[h].init(); | |
cF.map = [], b.view ? b.view === bJ.Inside ? cI = new bl : b.view === bJ.FirstPerson && (cI = new bm) : cI = new bk(worldModels[b.worldModel].eyeDist), cI.moveUpdate(cG), bN.setAbsPaused(!0), bN._startPause = !0, bQ = { | |
handler: null, | |
called: !1 | |
}, cN.clearMessages(), c === 0 && cN.addMessage("Use the arrow keys to start the game", bu.MSGID_START_ARROWS), cF.staticDraw = { | |
lives: new bG(cG) | |
}, cF.bonuses = [], cF.ready = !0, cO(!0), cN.drawGameState(), bO() | |
} | |
function bG(a) { | |
this.anglex = 0, this.angley = 0, this.color = b.x(a.modelColor, 1.5), this.count = bN.userLivesCount, this.activeDeath = undefined, this.activeOneUp = undefined, this.lightFactor = 1, this.pendingDeath = !1; | |
var c = cC.viewportWidth / cC.viewportHeight; | |
this.prMatrix = d.ortho(0, c, 1, 0, .1, 100) | |
} | |
function bF(a) { | |
this.box = a, this.move = 0, this.colors = []; | |
for (var b = 0; b < u.length; ++b) { | |
if (b === bL.userIndex) continue; | |
this.colors.push(u[b].model) | |
} | |
} | |
function bE(a) { | |
this.box = a | |
} | |
function bD(a) { | |
this.anglex = 0, this.angley = 0, this.box = a | |
} | |
function bA(a, b, c, d, e) { | |
this.base = d, this.img = a, this.text = b, this.boxImg = c, this.box = c.expanded(bn(cN.em / 4)), this.group = e, this.group && this.group.setBox(c.expanded(bn(cN.em / 8))) | |
} | |
function bz(a, b) { | |
this.id = b, this.com = a | |
} | |
function by(a) { | |
this.sel = a | |
} | |
function bx(a, b, c, d, e, f) { | |
this.base = f, this.imgOn = a, this.imgOff = b, this.text = c, this.boxImg = e, this.box = e.expanded(bn(cN.em / 4)), this.isOn = d, this.toggleCallback = this.base.callback, this.base.callback = function() { | |
this.isOn = !this.isOn, this.toggleCallback(this.isOn), this.draw(!0) | |
} | |
} | |
function bw(a, b, c, d) { | |
this.base = c, this.text = a, this.tx = b.x, this.ty = b.y + b.height, this.box = b.expanded(bn(cN.em / 4)).down(bn(cN.em / 7)), this.group = d, this.group && this.group.setBox(b.expanded(bn(cN.em / 8)).down(bn(cN.em / 7))) | |
} | |
function bv(a, b) { | |
this.callback = a, this.index = b | |
} | |
function bu() { | |
this.curPage = null, this.msgQueue = [], this.curMenuDraw = null, this.curMenuRemake = null, this.texth = 42, this.has3dContent = !1, this.render3d = [], this.mainMenu = null, window.setInterval(function() { | |
cN.checkMessageQueue() | |
}, 200) | |
} | |
function bt(a) {} | |
function bs(a) { | |
var b; | |
if (cN.curPage.widgets.length > 0) { | |
b = !1; | |
if (a.keyCode === G.DOM_VK_DOWN || a.keyCode === G.DOM_VK_RIGHT) cN.curPage.sel = (cN.curPage.sel + 1) % cN.curPage.widgets.length; | |
else if (a.keyCode === G.DOM_VK_UP || a.keyCode === G.DOM_VK_LEFT) cN.curPage.sel = (cN.curPage.sel - 1 + cN.curPage.widgets.length) % cN.curPage.widgets.length; | |
else if (a.keyCode === G.DOM_VK_RETURN || a.keyCode === G.DOM_VK_ENTER || a.keyCode === G.DOM_VK_SPACE) { | |
var c = cN.curPage.widgets[cN.curPage.sel]; | |
c.base.callback.call(c) | |
} else b = !0; | |
if (b === !1) { | |
cN.drawWidgets(); | |
return b | |
} | |
} | |
if (cN.curPage.keyHandler !== null) return cN.curPage.keyHandler(a.keyCode); | |
return !0 | |
} | |
function br() {} | |
function bq(a) { | |
var b = cN.getWidget(a); | |
b !== null ? b.base.callback.call(b) : cN.curPage.mouseHandler !== null && cN.curPage.mouseHandler() | |
} | |
function bp(a) { | |
var b = cN.getWidget(a); | |
b !== null && b.base.index !== cN.curPage.sel && (cN.curPage.sel = b.base.index, cN.drawWidgets()) | |
} | |
function bo(a, b, c, d) { | |
this.x = bn(a), this.y = bn(b), this.height = bn(d), this.width = bn(c) | |
} | |
function bm() { | |
this.eye = b.create([0, 0, 0]), this.upDir = b.create([0, 1, 0]), this.toPoint = b.create([0, 0, 0]), this.t = b.create(), this.twoSided = !1, this.addNearClip = 0, this.lightPoint = [-10, 4, 20] | |
} | |
function bl() { | |
this.eye = b.create([0, 0, 0]), this.upDir = b.create([0, 1, 0]), this.toPoint = b.create([0, 0, 1]), this.centerDist = 1.5, this.addNearClip = Math.max(0, this.centerDist - .8), this.twoSided = !0, this.bikeFlip = !0, this.lightPoint = [0, -4, 20] | |
} | |
function bk(a) { | |
this.eye = b.create([0, 0, 1]), this.upDir = b.create([0, 1, 0]), this.eyeDist = a, this.toPoint = b.create([0, 0, 0]), this.twoSided = !1, this.addNearClip = 0, this.lightPoint = [-10, 4, 20] | |
} | |
function bj(a) { | |
var c = bV(); | |
this.point = c[0]; | |
if (this.point !== null) { | |
this.index = a, this.occupy = c; | |
for (var d in this.occupy) cF.map[this.occupy[d]] = -100 + a; | |
this.normal = cF.model.normals[this.point], this.forward = b.normalize(b.nsubtract(cF.model.vtx[this.point], cF.model.vtx[c[1]])), this.rightHand = b.ncross(this.forward, this.normal), this.forward = b.ncross(this.normal, this.rightHand), this.anglex = 0, this.angley = 0, this.elapsed = 0, this.inflate = 0, cN.addMessage("Life bonus appeared") | |
} | |
} | |
function bi() { | |
if (!(Object.keys(cF.bonuses).length >= 5 || cF.bonuses.length > 99)) { | |
var a = new bj(cF.bonuses.length); | |
if (a.point === null) return; | |
cF.bonuses.push(a) | |
} | |
} | |
function bh(a) { | |
window.setTimeout(function() { | |
bg(a) | |
}, bd.TOTAL_TIME + bf.START_DELAY) | |
} | |
function bg(a) { | |
a.sfx.wall_decent = new bf(a) | |
} | |
function bf(a) { | |
this.player = a, this.brightness = 0, this.height = 1, this.elapsed = 0 | |
} | |
function be(a, b) { | |
b < 100 && b == cG.id && (a = cG), a.sfx.explode = new bd(a) | |
} | |
function bd(a) { | |
this.player = a, this.ringsScale = [-1, -0.5, .01], this.elapsed = 0, this.showSpikes = !0, this.spikesScale = .1 | |
} | |
function bc(a, b, c) { | |
if (b === 0) return c; | |
if (a.goForward()) return bc(a, b - 1, c + 1); | |
return c | |
} | |
function bb(a, b) { | |
this.init(a, b) | |
} | |
function ba(a) { | |
var b = cF.map[a]; | |
return b !== undefined && b >= 0 | |
} | |
function _(a, b) { | |
this.player = a; | |
var c = Z[b]; | |
this.stepsAhead = c.stepsAhead, this.look = new bb, this.occFwd = !0, this.occLeft = !0, this.occRight = !0 | |
} | |
function Y(a) { | |
var b = [], | |
c = [], | |
d = []; | |
for (var e = 0; e < U; ++e) { | |
var f = Math.PI * 2 / U * e, | |
g = Math.cos(f), | |
h = Math.sin(f); | |
b.push(g, h, 0, g * (1 + V), h * (1 + V), 0), c.push(0, 0, 1, 0, 0, 1), d.push(2 * e, 2 * e + 1) | |
} | |
d.push(0, 1), a.ring = {}, a.ring.vertexBuffer = r.Data(cC.ARRAY_BUFFER, new Float32Array(b), cC.STATIC_DRAW, 3), a.ring.vNormalBuffer = | |
r.Data(cC.ARRAY_BUFFER, new Float32Array(c), cC.STATIC_DRAW, 3), a.ring.triangleStrip = r.Data(cC.ELEMENT_ARRAY_BUFFER, new Uint16Array(d), cC.STATIC_DRAW, 1), b = [], c = []; | |
var i = [], | |
j = Math.PI * 2 / W; | |
for (var e = 0; e < W; ++e) { | |
var f = j * e; | |
f += (Math.random() - .5) * j; | |
var k = (Math.random() - .5) * .4 + 1, | |
g = Math.cos(f), | |
h = Math.sin(f), | |
l = h * X, | |
m = -g * X; | |
b.push(g * k, h * k, 0, l, m, 0, -l, -m, 0), c.push(0, 0, 1, 0, 0, 1, 0, 0, 1), i.push(3 * e, 3 * e + 1, 3 * e + 2) | |
} | |
a.spikes = {}, a.spikes.vertexBuffer = r.Data(cC.ARRAY_BUFFER, new Float32Array(b), cC.STATIC_DRAW, 3), a.spikes.vNormalBuffer = r.Data(cC.ARRAY_BUFFER, new Float32Array(c), cC.STATIC_DRAW, 3), a.spikes.triangleStrip = r.Data(cC.ELEMENT_ARRAY_BUFFER, new Uint16Array(i), cC.STATIC_DRAW, 1) | |
} | |
function T(a) { | |
var b = {}; | |
b.GRID_LINE_WIDTH = a * .19, b.WALL_WIDTH = a * .28, b.WALL_HEIGHT = a * 1.92, b.BIKE_SCALE = a * .96, b.BASE_SPEED = a * .01522, b.GLOBAL_SCALE = a / .052, b.BONUS_LIFE = a * .475; | |
return b | |
} | |
function S(a, c) { | |
c.vtx = []; | |
for (var d = 0; d < a.vertexPositions.length; d += 3) c.vtx.push(b.create([a.vertexPositions[d], a.vertexPositions[d + 1], a.vertexPositions[d + 2]])); | |
cm(c.vtx.length + " vertices in world"), c.normals = []; | |
if (a.vertexNormals) for (var d = 0; d < a.vertexNormals.length; d += 3) c.normals.push(b.create([a.vertexNormals[d], a.vertexNormals[d + 1], a.vertexNormals[d + 2]])); | |
c. | |
nei = []; | |
var e = Array(c.vtx.length); | |
for (var d = 0; d < e.length; ++d) e[d] = { | |
d: {}, | |
t: {}, | |
nc: 0 | |
}; | |
if (!a.quads) throw new Error("not supported"); | |
var f = 0, | |
g = 0, | |
h; | |
for (var d = 0; d < a.quads.length; d += 4) { | |
var i = a.quads[d], | |
j = a.quads[d + 1], | |
k = a.quads[d + 2]; | |
h = a.quads[d + 3], ds = R(c, i, j), e[i].d[j] = ds, e[j].d[i] = ds, f += ds, ds = R(c, j, k), e[j].d[k] = ds, e[k].d[j] = ds, f += ds, ds = R(c, k, h), e[k].d[h] = ds, e[h].d[k] = ds, f += ds, ds = R(c, h, i), e[h].d[i] = ds, e[i].d[h] = ds, f += ds, g += 4, e[i].t[j] = h, e[j].t[k] = i, e[k].t[h] = j, e[h].t[i] = k | |
} | |
c.distAvg = f / g, c.scale = T(c.distAvg), cm(c.distAvg), c.nei = e | |
} | |
function R(a, c, d) { | |
return b.distance(a.vtx[c], a.vtx[d]) | |
} | |
function Q(a, c, d, e) { | |
var f = [], | |
g = [], | |
h = [], | |
i = [], | |
j = 0; | |
for (var k = 0; k < a.nei.length; ++k) a.nei[k].tc = {}; | |
var k = 0, | |
l = function() { | |
for (var c = 0; c < 100; ++c) { | |
var d = a.vtx[k], | |
e = a.normals[k], | |
n = Object.keys(a.nei[k].t), | |
o = a.nei[k].nc = n.length; | |
a.nei[k].neiCount = o; | |
if (o > 6) throw new Error("not supported more than 6 neighbors per vertex " + k); | |
for (var p in a.nei[k].d) a.nei[k].tc[p] = []; | |
var q = i[k] = j, | |
r = a.nei[k].t[n[0]], | |
s; | |
for (var t = 0; t < o; ++t) { | |
var s = a.nei[k].t[r], | |
u = b.nsubtract(a.vtx[r], d), | |
v = b.nsubtract(a.vtx[s], d), | |
w = u; | |
b.normalize(b.add(w, v)), b.scale(w, a.scale.GRID_LINE_WIDTH * 1.41421), b.add(w, d), a.nei[k].tc[r].unshift(j), a.nei[k].tc[s].push(j), P(f, w), P(g, e), ++j, r = s | |
} | |
for (var x = 1; x < a.nei[k].nc - 1; ++x) h.push(q, q + x, q + x + 1); | |
++k; | |
if (k >= a.vtx.length) break | |
} | |
var y = k < a.vtx.length ? l : m; | |
return y | |
}, | |
m = function() { | |
j > 65536 && alert("model too big " + vtxBuf.length + " vertices"); | |
var b = Array(a.vtx.length); | |
for (var c = 0; c < b.length; ++c) b[c] = {}; | |
for (var c = 0; c < a.vtx.length; ++c) for (var d in a.nei[c].d) { | |
d = parseInt(d); | |
var e = c < d ? [c, d] : [d, c]; | |
if (b[e[0]][e[1]]) continue; | |
b[e[0]][e[1]] = !0; | |
var k = a.nei[c].tc[d], | |
l = a.nei[d].tc[c]; | |
h.push(k[0], l[1], l[0]), h.push(k[0], l[0], k[1]) | |
} | |
delete b, delete i, a.vertexBuffer = r.Data(cC.ARRAY_BUFFER, new Float32Array(f), cC.STATIC_DRAW, 3), a.vNormalBuffer = r.Data(cC.ARRAY_BUFFER, new Float32Array(g), cC.STATIC_DRAW, 3), a.triangles = r.Data(cC.ELEMENT_ARRAY_BUFFER, new Uint16Array(h), cC.STATIC_DRAW, 1), delete vtxBuf, delete g, delete h; | |
for (var c = 0; c < a.nei.length; ++c) delete a.nei[c].tc; | |
return null | |
}, | |
n = l, | |
o = function() { | |
n = n(), n === null ? (e && e(1), d()) : e && (c = e(k / (a.vtx.length + 200))) | |
}, | |
p = function() { | |
o(); | |
if (n !== null && c) setTimeout(p, 100); | |
else | |
while (n !== null && !c) o() | |
}; | |
p() | |
} | |
function P(a) { | |
for (var b = 1; b < arguments.length; ++b) a.push(arguments[b][0], arguments[b][1], arguments[b][2]) | |
} | |
function O(a, c) { | |
c.groups = []; | |
for (var d in a.groups) { | |
var e = a.groups[d], | |
f = {}, | |
g = [], | |
h = [], | |
i = 0; | |
while (i < e.triangles.length) { | |
var j = []; | |
for (var k = 0; k < 3; ++k) { | |
var l = e.triangles[i], | |
m = [a.vertexPositions[l * 3], a.vertexPositions[l * 3 + 1], a.vertexPositions[l * 3 + 2]]; | |
g.push.apply(g, m), j[k] = m, ++i | |
} | |
var n = b.ncross(b.nsubtract(j[0], j[1]), b.nsubtract(j[0], j[2])); | |
for (var k = 0; k < 3; ++k) h.push(n[0], n[1], n[2]) | |
} | |
f.vertexBuffer = r.Data(cC.ARRAY_BUFFER, new Float32Array(g), cC.STATIC_DRAW, 3), f.vNormalBuffer = r.Data(cC.ARRAY_BUFFER, new Float32Array(h), cC.STATIC_DRAW, 3), f.trianglesInline = !0, f.diffuseColor = e.diffuseColor, c.groups.push(f) | |
} | |
} | |
function N(a, b) { | |
b.vertexBuffer = r.Data(cC.ARRAY_BUFFER, new Float32Array(a.vertexPositions), cC.STATIC_DRAW, 3), a.vertexNormals && (b.vNormalBuffer = r.Data(cC.ARRAY_BUFFER, new Float32Array(a.vertexNormals), cC.STATIC_DRAW, 3)), a.vertexTextureCoords && (b.vTexCoord = r.Data(cC.ARRAY_BUFFER, new Float32Array(a.vertexTextureCoords), cC.STATIC_DRAW, 2)); | |
if (a.groups) { | |
b.groups = []; | |
for (var c in a.groups) { | |
var d = a.groups[c], | |
e = {}; | |
M(d, e), b.groups.push(e) | |
} | |
} else M(a, b) | |
} | |
function M(a, b) { | |
var c = ["triangles", "lines"]; | |
for (var d in c) { | |
var e = c[d]; | |
a[e] && (b[e] = r.Data(cC.ELEMENT_ARRAY_BUFFER, new Uint16Array(a[e]), cC.STATIC_DRAW, 1)) | |
} | |
if (a.quads) { | |
var f = new Uint16Array(a.quads.length / 4 * 6); | |
ti = 0; | |
for (var d = 0; d < a.quads.length; d += 4) f[ti++] = a.quads[d], f[ti++] = a.quads[d + 1], f[ti++] = a.quads[d + 2], f[ti++] = a.quads[d], f[ti++] = a.quads[d + 2], f[ti++] = a.quads[d + 3]; | |
b.triangles = r.Data(cC.ELEMENT_ARRAY_BUFFER, f, cC.STATIC_DRAW, 1) | |
} | |
} | |
function L(a, b) { | |
B.mouseEnabled = !0, a.onmousedown = C, b.onmousedown = C, document.onmouseup = D, document.onmousemove = E, document.onkeydown = I, document.onkeyup = J | |
} | |
function K(a) { | |
for (var b in B.currentlyPressedDirs) { | |
var c = B.currentlyPressedDirs[b]; | |
if (c === undefined) continue; | |
moveDir = cI.translateDir(c.dir, a), moveDir !== null && moveDir !== a.eDir.opposite ? (a.selDir = moveDir, bN.isPaused() && bL.debug && (cv(cG), cG.curStepFrac = 1), B.currentlyPressedDirs[b] = undefined) : (++c.skippedCount, c.skippedCount > 4 && (B.currentlyPressedDirs[b] = undefined)) | |
} | |
} | |
function J(a) {} | |
function I(a) { | |
var b = !0; | |
H[a.keyCode] !== undefined && (B.currentlyPressedDirs.push({ | |
dir: H[a.keyCode], | |
skippedCount: 0 | |
}), b = !1), a.keyCode === G.DOM_VK_P || a.keyCode === G.DOM_VK_PAUSE ? (bN.setPaused(!bN.isPaused()), b = !1) : a.keyCode === G.DOM_VK_M ? enableSound(!bN.enableSound) : a.keyCode === G.DOM_VK_ESCAPE ? (bN.setPaused(!0), cN.verbosePauseScreen()) : !bL.debug && bN.isPaused() && (bN.setPaused(!1), b = !1), a.keyCode === G.DOM_VK_SPACE && (b = !1), bL.debug && (a.keyCode === G.DOM_VK_E ? be(cG) : a.keyCode === G.DOM_VK_U ? (++bN.userLivesCount, cF.staticDraw.lives.startOneUp()) : a.keyCode === G.DOM_VK_B && bi()); | |
return b | |
} | |
function F() { | |
d.identity(B.rotationMatrix) | |
} | |
function E(a) { | |
if ( !! B.mouseDown) { | |
var b = a.clientX, | |
c = a.clientY; | |
if (!bL.debug) return; | |
var e = b - B.lastMouseX, | |
f = c - B.lastMouseY, | |
g = d.nidentity(); | |
d.rotateY(g, j(e / 2)), d.rotateX(g, j(f / 2)), d.multiply(g, B.rotationMatrix, B.rotationMatrix), B.lastMouseX = b, B.lastMouseY = c | |
} | |
} | |
function D(a) { | |
B.mouseDown = !1 | |
} | |
function C(a) { | |
B.mouseDown = !0, B.lastMouseX = a.clientX, B.lastMouseY = a.clientY | |
} | |
function A(a, b) { | |
var c = cF.model.nei[a], | |
d = {}, | |
e = b, | |
f = x.rightHand[c.nc]; | |
for (var g = 0; g < f; ++g) e = c.t[e]; | |
d.toRight = e, f = x.forward[c.nc] - x.rightHand[c.nc]; | |
for (var g = 0; g < f; ++g) e = c.t[e]; | |
d.toFwd = e, f = x.leftHand[c.nc] - x.forward[c.nc]; | |
for (var g = 0; g < f; ++g) e = c.t[e]; | |
d.toLeft = e; | |
return d | |
} | |
function z(a, b, c) { | |
var d = cF.model.nei[a], | |
e = b[d.nc], | |
f = c; | |
for (var g = 0; g < e; ++g) f = d.t[f]; | |
return f | |
} | |
function y(a, c) { | |
var d = cF.model.vtx[a], | |
e = cF.model.nei[a].d, | |
f = -100, | |
g = -100; | |
for (i in e) { | |
var h = cF.model.vtx[i], | |
j = b.normalize(b.nsubtract(h, d)), | |
k = b.dot(c, j); | |
k > f && (f = k, g = i) | |
} | |
return parseInt(g) | |
} | |
function w(a, c, d) { | |
this.alive = !0, this.model = c, this.id = a, this.ready = !1, this.modelColor = u[a].model, this.trailColor = u[a].trail, this.textColor = u[a].text, this.name = u[a].name, this.point = d, this.normal = b.create([0, 0, 1]), this. | |
rightHand = b.create([1, 0, 0]), this.upDir = b.create([0, 1, 0]), this.forward = this.upDir, this.last = { | |
point: -1, | |
normal: null, | |
upDir: null, | |
forward: null | |
}, this.last.point = y(this.point, b.nnegate(this.forward)), this.eDir = t.Up, this.selDir = t.Up, this.wall = new v, this.ai = null, this.sfx = { | |
explode: null, | |
wall_decent: null | |
}, this.lastMadeMoves = 0, this.dNow2Last = 0, this.dNow2Point = 0, this.curStepFrac = 1, this.lastMvDist = 1, this.turnCallback = null, this.selDir.move.call(this) | |
} | |
function v() { | |
this.queue = [], this.pntRecord = [], this.standing = !0 | |
} | |
function s() { | |
s.t || (s.t = {}, s.t[cC.FLOAT] = { | |
byteSize: 4, | |
arrCtor: Float32Array | |
}, s.t[cC.UNSIGNED_INT] = { | |
byteSize: 4, | |
arrCtor: Uint32Array | |
}, s.t[cC.INT] = { | |
byteSize: 4, | |
arrCtor: Int32Array | |
}, s.t[cC.UNSIGNED_SHORT] = { | |
byteSize: 2, | |
arrCtor: Uint16Array | |
}, s.t[cC.SHORT] = { | |
byteSize: 2, | |
arrCtor: Int16Array | |
}, s.t[cC.UNSIGNED_BYTE] = { | |
byteSize: 1, | |
arrCtor: Uint8Array | |
}, s.t[cC.BYTE] = { | |
byteSize: 1, | |
arrCtor: Int8Array | |
}); | |
return s.t | |
} | |
function r(a) { | |
if (arguments.length != 1) throw new Error("GLBuffer() needs 1 arguments"); | |
this.buf = cC.createBuffer(), this.target = a | |
} | |
function q() { | |
this.prog = null | |
} | |
function p(a, b) { | |
var c = b; | |
if (!c) return null; | |
var d = c[0], | |
e = d.text, | |
f; | |
if (d.type == "x-shader/x-fragment") f = a.createShader(a.FRAGMENT_SHADER); | |
else if (d.type == "x-shader/x-vertex") f = a.createShader(a.VERTEX_SHADER); | |
else | |
return null; | |
a.shaderSource(f, e), a.compileShader(f); | |
if (!a.getShaderParameter(f, a.COMPILE_STATUS)) { | |
alert(a.getShaderInfoLog(f)); | |
return null | |
} | |
return f | |
} | |
function m() { | |
this.stack = []; | |
for (var a = 0; a < 20; ++a) this.stack.push(d.create()); | |
this.stackTop = 0, this.current = d.create(), this.loadIdentity() | |
} | |
function l(a, b, c) { | |
var d, e, f; | |
if (b == 0) d = e = f = c; | |
else { | |
function g(a, b, c) { | |
c < 0 && (c += 1), c > 1 && (c -= 1); | |
if (c < 1 / 6) return a + (b - a) * 6 * c; | |
if (c < .5) return b; | |
if (c < 2 / 3) return a + (b - a) * (2 / 3 - c) * 6; | |
return a | |
} | |
var h = c < .5 ? c * (1 + b) : c + b - c * b, | |
i = 2 * c - h; | |
d = g(i, h, a + 1 / 3), e = g(i, h, a), f = g(i, h, a - 1 / 3) | |
} | |
return [d, e, f] | |
} | |
function k(a) { | |
return a * 180 / Math.PI | |
} | |
function j(a) { | |
return a * Math.PI / 180 | |
} | |
function h(a) { | |
var b = cC.getError(); | |
b != cC.NO_ERROR && (h.codes || (h.codes = {}, h.codes[cC.INVALID_ENUM] = "INVALID_ENUM", h.codes[cC.INVALID_VALUE] = "INVALID_VALUE", h.codes[cC.INVALID_OPERATION] = "INVALID_OPERATION", h.codes[cC.OUT_OF_MEMORY] = "OUT_OF_MEMORY"), alert((a ? a + " " : "") + "WebGL error: " + b + " " + h.codes[b])) | |
} | |
function g(a) { | |
return Math.random() < a / 100 | |
} | |
function f(a, b) { | |
return Math.floor(Math.random() * (b - a + 1)) + a | |
} | |
function e(a) { | |
return document.getElementById(a) | |
} | |
jQuery.cookie = function(a, b, c) { | |
if (typeof b == "undefined") { | |
var i = null; | |
if (document.cookie && document.cookie != "") { | |
var j = document.cookie.split(";"); | |
for (var k = 0; k < j.length; k++) { | |
var l = jQuery.trim(j[k]); | |
if (l.substring(0, a.length + 1) == a + "=") { | |
i = decodeURIComponent(l.substring(a.length + 1)); | |
break | |
} | |
} | |
} | |
return i | |
} | |
c = c || {}, b === null && (b = "", c.expires = -1); | |
var d = ""; | |
if (c.expires && (typeof c.expires == "number" || c.expires.toUTCString)) { | |
var e; | |
typeof c.expires == "number" ? (e = new Date, e.setTime(e.getTime() + c.expires * 24 * 60 * 60 * 1e3)) : e = c.expires, d = "; expires=" + e.toUTCString() | |
} | |
var f = c.path ? "; path=" + c.path : "", | |
g = c.domain ? "; domain=" + c.domain : "", | |
h = c.secure ? "; secure" : ""; | |
document.cookie = [a, "=", encodeURIComponent(b), d, f, g, h].join("") | |
}; | |
var a = { | |
init: function() { | |
this.browser = this.searchString(this.dataBrowser) || "An unknown browser", this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version", this.OS = this.searchString(this.dataOS) || "an unknown OS" | |
}, | |
searchString: function(a) { | |
for (var b = 0; b < a.length; b++) { | |
var c = a[b].string, | |
d = a[b].prop; | |
this.versionSearchString = a[b].versionSearch || a[b].identity; | |
if (c) { | |
if (c.indexOf(a[b].subString) != -1) return a[b].identity | |
} else if (d) return a[b].identity | |
} | |
}, | |
searchVersion: function(a) { | |
var b = a.indexOf(this.versionSearchString); | |
if (b != -1) return parseFloat( | |
a.substring(b + this.versionSearchString.length + 1)) | |
}, | |
dataBrowser: [{ | |
string: navigator.userAgent, | |
subString: "Chrome", | |
identity: "Chrome" | |
}, { | |
string: navigator.userAgent, | |
subString: "OmniWeb", | |
versionSearch: "OmniWeb/", | |
identity: "OmniWeb" | |
}, { | |
string: navigator.vendor, | |
subString: "Apple", | |
identity: "Safari", | |
versionSearch: "Version" | |
}, { | |
prop: window.opera, | |
identity: "Opera" | |
}, { | |
string: navigator.vendor, | |
subString: "iCab", | |
identity: "iCab" | |
}, { | |
string: navigator.vendor, | |
subString: "KDE", | |
identity: "Konqueror" | |
}, { | |
string: navigator.userAgent, | |
subString: "Firefox", | |
identity: "Firefox" | |
}, { | |
string: navigator.vendor, | |
subString: "Camino", | |
identity: "Camino" | |
}, { | |
string: navigator.userAgent, | |
subString: "Netscape", | |
identity: "Netscape" | |
}, { | |
string: navigator.userAgent, | |
subString: "MSIE", | |
identity: "Explorer", | |
versionSearch: "MSIE" | |
}, { | |
string: navigator.userAgent, | |
subString: "Gecko", | |
identity: "Mozilla", | |
versionSearch: "rv" | |
}, { | |
string: navigator.userAgent, | |
subString: "Mozilla", | |
identity: "Netscape", | |
versionSearch: "Mozilla" | |
}], | |
dataOS: [{ | |
string: navigator.platform, | |
subString: "Win", | |
identity: "Windows" | |
}, { | |
string: navigator.platform, | |
subString: "Mac", | |
identity: "Mac" | |
}, { | |
string: navigator.userAgent, | |
subString: "iPhone", | |
identity: "iPhone/iPod" | |
}, { | |
string: navigator.platform, | |
subString: "Linux", | |
identity: "Linux" | |
}] | |
}; | |
a.init(), WebGLUtils = function() { | |
var b, c, d = function(a, b) { | |
return '<div style="background-color: #EEE; width: 100%; height: 100%; text-align:center;" class="inframe"><div style="width: 80%; height: 100%; margin: auto; display:table;"><p style="font:bold 28px sans-serif; margin:10px 0 10px 0">' + a + "</p>" + '<div style="font-size: 18px; margin:0">' + b + "</div>" + "</div></div>" | |
}, | |
e = "Your browser does not support WebGL", | |
f = "http://www.google.com/chrome", | |
g = "http://getfirefox.com", | |
h = "<div style='float:left; width:150px'><a href='" + g + "' target=_blank><img src='img/firefox_icon128.png'><br/>Get firefox</a></div>", | |
i = "<div style='float:left; width:150px'><a href='" + f + "' target=_blank><img src='img/chromelogo128.png'><br/>Get chrome</a></div>", | |
j = '<div style="margin:10px auto 0 auto; display:table;">' + h + i + "</div>", | |
k = '<div style="margin:10px auto 0 auto; display:table;">' + i + "</div>", | |
l = '<div style="margin:10px auto 0 auto; display:table;">' + h + "</div>", | |
m = "To play CycleBlob please use <a href='" + f + "' target=_blank>Google Chrome</a> or <a href='" + g + "' target=_blank>Mozilla Firefox</a>", | |
n = '<iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/amFozFKhmxc?rel=0" frameborder="0" allowfullscreen></iframe>', | |
o = "Check this website: <a href='http://get.webgl.org/'>http://get.webgl.org/</a> for more information.", | |
p = "<br/>" + o + "<br/><br/>" + n, | |
q = "Firefox " + a.version + " does not supprot WebGL<br/>" + "To play CycleBlob please upgrade to the latest version of <a href='" + g + "' target=_blank>Firefox</a> (4.0 and above) or get <a href='" + f + "' target=_blank>Google Chrome</a><br/>" + j + p, | |
r = "Chrome " + a.version + " does not support WebGL<br/>" + "To play CycleBlob please upgrade to the latest version of <a href='" + f + "' target=_blank>Chrome</a> (9.0 and above) or get <a href='" + g + "' target=_blank>Mozilla Firefox</a><br/>" + j + p, | |
s = m + p, | |
t = "Microsoft Internet Explorer (MSIE) does not support WebGL yet.<br/>" + m + "<br/>" + j + p, | |
u = "Your version of Firefox (" + a.version + ") is supposed to support WebGL but an error occured while trying to use it</br>" + "Things you might try to do to fix this:</br><ul style='text-align:left; margin-bottom:0'>" + "<li>Write in the address 'about:config' in the address bar, press Enter, filter for 'WebGL' in the config page and make sure it is not disabled.</li>" + "<li>In the same page (about:config), set 'webgl.force-enable' to 'true'</li>" + "<li>Check for messages or errors at the very bottom of the 'about:support' page</li>" + "<li>Update the display drivers of your computer. Some older drivers are known not to work properly.</li>" + "<li>" + o + "</li>" + "<li>Try <a href='" + f + "' target=_blank>Google Chrome</a>.</li></ul>" + k + "<br/>" + n, | |
v = "Your version of Chrome (" + a.version + ") is supposed to support WebGL but an error occured while trying to use it</br>" + "Things you might try to do to fix this:</br><ul style='text-align:left; margin-bottom:0'>" + "<li>Update the display drivers of your computer. Some older drivers are known not to work properly.</li>" + "<li>Write in the address 'about:gpu' in the address bar, press Enter and see if you detect some sort of error which prevents using hardware acceleration</li>" + "<li>" + o + "</li>" + "<li>Try <a href='" + g + "' target=_blank>Mozilla Firefox</a>.</li></ul>" + l + "<br/>" + n, | |
w = "An Unknown error occured while initializing WebGL", | |
x = "Your browser appears to support WebGL but there was an error using it<br/>" + o + "<br/>" + n, | |
y = function(b, c, f) { | |
function g() { | |
var c = b.parentNode; | |
if ( !! c) { | |
var f; | |
a.browser == "Explorer" ? f = d(e, t) : a.browser == "Firefox" ? a.version < 4 ? f = d(e, q) : f = d(w, u) : a.browser == "Chrome" ? a.version < 9 ? f = d(e, r) : f = d(w, v) : window.WebGLRenderingContext ? f = d(w, x) : f = d(e, s), c.innerHTML = f, c.style.height = null | |
} | |
} | |
f = f || g, b.addEventListener && b.addEventListener("webglcontextcreationerror", function(a) { | |
f(a.statusMessage) | |
}, !1); | |
var h = | |
z(b, c); | |
h || f(); | |
return h | |
}, | |
z = function(a, b) { | |
var c = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"], | |
d = null; | |
for (var e = 0; e < c.length; ++e) { | |
try { | |
d = a.getContext(c[e], b) | |
} catch (f) {} | |
if (d) break | |
} | |
return d | |
}, | |
A = function() { | |
c || (c = function() { | |
var a = ["animationTime", "webkitAnimationTime", "mozAnimationTime", "oAnimationTime", "msAnimationTime"]; | |
for (var b = 0; b < a.length; ++b) { | |
var c = a[b]; | |
if (window[c]) return function() { | |
return window[c] | |
} | |
} | |
return function() { | |
return (new Date).getTime() | |
} | |
}()); | |
return c() | |
}, | |
B = function(a, c) { | |
b || (b = function() { | |
var a = ["requestAnimationFrame", "webkitRequestAnimationFrame", "mozRequestAnimationFrame", "oRequestAnimationFrame", "msRequestAnimationFrame"]; | |
for (var b = 0; b < a.length; ++b) { | |
var c = a[b]; | |
if (window[c]) return function(a) { | |
return function(b, c) { | |
window[a].call(window, c, b) | |
} | |
}(c) | |
} | |
return function(a, b) { | |
window.setTimeout(b, 1e3 / 70) | |
} | |
}()), b(a, c) | |
}; | |
return { | |
animationTime: A, | |
create3DContext: z, | |
requestAnimationFrame: B, | |
setupWebGL: y | |
} | |
}(), glMatrixArrayType = typeof Float32Array != "undefined" ? Float32Array : typeof WebGLFloatArray != "undefined" ? WebGLFloatArray : Array; | |
var b = {}; | |
b.create = function(a) { | |
var b = new glMatrixArrayType(3); | |
a && (b[0] = a[0], b[1] = a[1], b[2] = a[2]); | |
return b | |
}, b.set = function(a, b) { | |
b[0] = a[0], b[1] = a[1], b[2] = a[2]; | |
return b | |
}, b.add = function(a, b, c) { | |
if (!c || a == c) { | |
a[0] += b[0], a[1] += b[1], a[2] += b[2]; | |
return a | |
} | |
c[0] = a[0] + b[0], c[1] = a[1] + b[1], c[2] = a[2] + b[2]; | |
return c | |
}, b.subtract = function(a, b, c) { | |
if (!c || a == c) { | |
a[0] -= b[0], a[1] -= b[1], a[2] -= b[2]; | |
return a | |
} | |
c[0] = a[0] - b[0], c[1] = a[1] - b[1], c[2] = a[2] - b[2]; | |
return c | |
}, b.negate = function(a, b) { | |
b || (b = a), b[0] = -a[0], b[1] = -a[1], b[2] = -a[2]; | |
return b | |
}, b.scale = function(a, b, c) { | |
if (!c || a == c) { | |
a[0] *= b, a[1] *= b, a[2] *= b; | |
return a | |
} | |
c[0] = a[0] * b, c[1] = a[1] * b, c[2] = a[2] * b; | |
return c | |
}, b.normalize = function(a, b) { | |
b || (b = a); | |
var c = a[0], | |
d = a[1], | |
e = a[2], | |
f = Math.sqrt(c * c + d * d + e * e); | |
if (!f) { | |
b[0] = 0, b[1] = 0, b[2] = 0; | |
return b | |
} | |
if (f == 1) { | |
b[0] = c, b[1] = d, b[2] = e; | |
return b | |
} | |
f = 1 / f, b[0] = c * f, b[1] = d * f, b[2] = e * f; | |
return b | |
}, b.cross = function(a, b, c) { | |
c || (c = a); | |
var d = a[0], | |
e = a[1]; | |
a = a[2]; | |
var f = b[0], | |
g = b[1]; | |
b = b[2], c[0] = e * b - a * g, c[1] = a * f - d * b, c[2] = d * g - e * f; | |
return c | |
}, b.length = function(a) { | |
var b = a[0], | |
c = a[1]; | |
a = a[2]; | |
return Math.sqrt(b * b + c * c + a * a) | |
}, b.dot = function(a, b) { | |
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] | |
}, b.direction = function(a, b, c) { | |
c || (c = a); | |
var d = a[0] - b[0], | |
e = a[1] - b[1]; | |
a = a[2] - b[2], b = Math.sqrt(d * d + e * e + a * a); | |
if (!b) { | |
c[0] = 0, c[1] = 0, c[2] = 0; | |
return c | |
} | |
b = 1 / b, c[0] = d * b, c[1] = e * b, c[2] = a * b; | |
return c | |
}, b.str = function(a) { | |
return "[" + a[0] + ", " + a[1] + ", " + a[2] + "]" | |
}; | |
var c = {}; | |
c.create = function(a) { | |
var b = new glMatrixArrayType(9); | |
a && (b[0] = a[0], b[1] = a[1], b[2] = a[2], b[3] = a[3], b[4] = a[4], b[5] = a[5], b[6] = a[6], b[7] = a[7], b[8] = a[8], b[9] = a[9]); | |
return b | |
}, c.set = function(a, b) { | |
b[0] = a[0], b[1] = a[1], b[2] = a[2], b[3] = a[3], b[4] = a[4], b[5] = a[5], b[6] = a[6], b[7] = a[7], b[8] = a[8]; | |
return b | |
}, c.identity = function(a) { | |
a[0] = 1, a[1] = 0, a[2] = 0, a[3] = 0, a[4] = 1, a[5] = 0, a[6] = 0, a[7] = 0, a[8] = 1; | |
return a | |
}, c.toMat4 = function(a, b) { | |
b || (b = d.create()), b[0] = a[0], b[1] = a[1], b[2] = a[2], b[3] = 0, b[4] = a[3], b[5] = a[4], b[6] = a[5], b[7] = 0, b[8] = a[6], b[9] = a[7], b[10] = a[8], b[11] = 0, b[12] = 0, b[13] = 0, b[14] = 0, b[15] = 1; | |
return b | |
}, c.str = function(a) { | |
return "[" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + "]" | |
}; | |
var d = {}; | |
d.create = function(a) { | |
var b = new glMatrixArrayType(16); | |
a && (b[0] = a[0], b[1] = a[1], b[2] = a[2], b[3] = a[3], b[4] = a[4], b[5] = a[5], b[6] = a[6], b[7] = a[7], b[8] = a[8], b[9] = a[9], b[10] = a[10], b[11] = a[11], b[12] = a[12], b[13] = a[13], b[14] = a[14], b[15] = a[15]); | |
return b | |
}, d.set = function(a, b) { | |
b[0] = a[0], b[1] = a[1], b[2] = a[2], b[3] = a[3], b[4] = a[4], b[5] = a[5], b[6] = a[6], b[7] = a[7], b[8] = a[8], b[9] = a[9], b[10] = a[10], b[11] = a[11], b[12] = a[12], b[13] = a[13], b[14] = a[14], b[15] = a[15]; | |
return b | |
}, d.identity = function(a) { | |
a[0] = 1, a[1] = 0, a[2] = 0, a[3] = 0, a[4] = 0, a[5] = 1, a[6] = 0, a[7] = 0, a[8] = 0, a[9] = 0, a[10] = 1, a[11] = 0, a[12] = 0, a[13] = 0, a[14] = 0, a[15] = 1; | |
return a | |
}, d.transpose = function(a, b) { | |
if (!b || a == b) { | |
var c = a[1], | |
d = a[2], | |
e = a[3], | |
f = a[6], | |
g = a[7], | |
h = a[11]; | |
a[1] = a[4], a[2] = a[8], a[3] = a[12], a[4] = c, a[6] = a[9], a[7] = a[13], a[8] = d, a[9] = f, a[11] = a[14], a[12] = e, a[13] = g, a[14] = h; | |
return a | |
} | |
b[0] = a[0], b[1] = a[4], b[2] = a[8], b[3] = a[12], b[4] = a[1], b[5] = a[5], b[6] = a[9], b[7] = a[13], b[8] = a[2], b[9] = a[6], b[10] = a[10], b[11] = a[14], b[12] = a[3], b[13] = a[7], b[14] = a[11], b[15] = a[15]; | |
return b | |
}, d.determinant = function(a) { | |
var b = a[0], | |
c = a[1], | |
d = a[2], | |
e = a[3], | |
f = a[4], | |
g = a[5], | |
h = a[6], | |
i = a[7], | |
j = a[8], | |
k = a[9], | |
l = a[10], | |
m = a[11], | |
n = a[12], | |
o = a[13], | |
p = a[14]; | |
a = a[15]; | |
return n * k * h * e - j * o * h * e - n * g * l * e + f * o * l * e + j * g * p * e - f * k * p * e - n * k * d * i + j * o * d * i + n * c * l * i - b * o * l * i - j * c * p * i + b * k * p * i + n * g * d * m - f * o * d * m - n * c * h * m + b * o * h * m + f * c * p * m - b * g * p * m - j * g * d * a + f * k * d * a + j * c * h * a - b * k * h * a - f * c * l * a + b * g * l * a | |
}, d.inverse = function(a, b) { | |
b || (b = a); | |
var c = a[0], | |
d = a[1], | |
e = a[2], | |
f = a[3], | |
g = a[4], | |
h = a[5], | |
i = a[6], | |
j = a[7], | |
k = a[8], | |
l = a[9], | |
m = a[10], | |
n = a[11], | |
o = a[12], | |
p = a[13], | |
q = a[14], | |
r = a[15], | |
s = c * h - d * g, | |
t = c * i - e * g, | |
u = c * j - f * g, | |
v = d * i - e * h, | |
w = d * j - f * h, | |
x = e * j - f * i, | |
y = k * p - l * o, | |
z = k * q - m * o, | |
A = k * r - n * o, | |
B = l * q - m * p, | |
C = l * r - n * p, | |
D = m * r - n * q, | |
E = 1 / (s * D - t * C + u * B + v * A - w * z + x * y); | |
b[0] = (h * D - i * C + j * B) * E, b[1] = (-d * D + e * C - f * B) * E, b[2] = (p * x - q * w + r * v) * E, b[3] = (-l * x + m * w - n * v) * E, b[4] = (-g * D + i * A - j * z) * E, b[5] = (c * D - e * A + f * z) * E, b[6] = (-o * x + q * u - r * t) * E, b[7] = (k * x - m * u + n * t) * E, b[8] = (g * C - h * A + j * y) * E, b[9] = (-c * C + d * A - f * y) * E, b[10] = (o * w - p * u + r * s) * E, b[11] = (-k * w + l * u - n * s) * E, b[12] = (-g * B + h * z - i * y) * E, b[13] = (c * B - d * z + e * y) * E, b[14] = (-o * v + p * t - q * s) * E, b[15] = (k * v - l * t + m * s) * E; | |
return b | |
}, d.toMat3 = function(a, b) { | |
b || (b = c.create()), b[0] = a[0], b[1] = a[1], b[2] = a[2], b[3] = a[4], b[4] = a[5], b[5] = a[6], b[6] = a[8], b[7] = a[9], b[8] = a[10]; | |
return b | |
}, d.toInverseMat3 = function(a, b) { | |
var d = a[0], | |
e = a[1], | |
f = a[2], | |
g = a[4], | |
h = a[5], | |
i = a[6], | |
j = a[8], | |
k = a[9], | |
l = a[10], | |
m = l * h - i * k, | |
n = -l * g + i * j, | |
o = k * g - h * j, | |
p = d * m + e * n + f * o; | |
if (!p) return null; | |
p = 1 / p, b || (b = c.create()), b[0] = m * p, b[1] = (-l * e + f * k) * p, b[2] = (i * e - f * h) * p, b[3] = n * p, b[4] = (l * d - f * j) * p, b[5] = (-i * d + f * g) * p, b[6] = o * p, b[7] = (-k * d + e * j) * p, b[8] = (h * d - e * g) * p; | |
return b | |
}, d.multiply = function(a, b, c) { | |
c || (c = a); | |
var d = a[0], | |
e = a[1], | |
f = a[2], | |
g = a[3], | |
h = a[4], | |
i = a[5], | |
j = a[6], | |
k = a[7], | |
l = a[8], | |
m = a[9], | |
n = a[10], | |
o = a[11], | |
p = a[12], | |
q = a[13], | |
r = a[14]; | |
a = a[15]; | |
var s = b[0], | |
t = b[1], | |
u = b[2], | |
v = b[3], | |
w = b[4], | |
x = b[5], | |
y = b[6], | |
z = b[7], | |
A = b[8], | |
B = b[9], | |
C = b[10], | |
D = b[11], | |
E = b[12], | |
F = b[13], | |
G = b[14]; | |
b = b[15], c[0] = s * d + t * h + u * l + v * p, c[1] = s * e + t * i + u * m + v * q, c[2] = s * f + t * j + u * n + v * r, c[3] = s * g + t * k + u * o + v * a, c[4] = w * d + x * h + y * l + z * p, c[5] = w * e + x * i + y * m + z * q, c[6] = w * f + x * j + y * n + z * r, c[7] = w * g + x * k + y * o + z * a, c[8] = A * d + B * h + C * l + D * p, c[9] = A * e + B * i + C * m + D * q, c[10] = A * f + B * j + C * n + D * r, c[11] = A * g + B * k + C * o + D * a, c[12] = E * d + F * h + G * l + b * p, c[13] = E * e + F * i + G * m + b * q, c[14] = E * f + F * j + G * n + b * r, c[15] = E * g + F * k + G * o + b * a; | |
return c | |
}, d.multiplyVec3 = function(a, b, c) { | |
c || (c = b); | |
var d = b[0], | |
e = b[1]; | |
b = b[2], c[0] = a[0] * d + a[4] * e + a[8] * b + a[12], c[1] = a[1] * d + a[5] * e + a[9] * b + a[13], c[2] = a[2] * d + a[6] * e + a[10] * b + a[14]; | |
return c | |
}, d.multiplyVec4 = function(a, b, c) { | |
c || (c = b); | |
var d = b[0], | |
e = b[1], | |
f = b[2]; | |
b = b[3], c[0] = a[0] * d + a[4] * e + a[8] * f + a[12] * b, c[1] = a[1] * d + a[5] * e + a[9] * f + a[13] * b, c[2] = a[2] * d + a[6] * e + a[10] * f + a[14] * b, c[3] = a[3] * d + a[7] * e + a[11] * f + a[15] * b; | |
return c | |
}, d.translate = function(a, b, c) { | |
var d = b[0], | |
e = b[1]; | |
b = b[2]; | |
if (!c || a == c) { | |
a[12] = a[0] * d + a[4] * e + a[8] * b + a[12], a[13] = a[1] * d + a[5] * e + a[9] * b + a[13], a[14] = a[2] * d + a[6] * e + a[10] * b + a[14], a[15] = a[3] * d + a[7] * e + a[11] * b + a[15]; | |
return a | |
} | |
var f = a[0], | |
g = a[1], | |
h = a[2], | |
i = a[3], | |
j = a[4], | |
k = a[5], | |
l = a[6], | |
m = a[7], | |
n = a[8], | |
o = a[9], | |
p = a[10], | |
q = a[11]; | |
c[0] = f, c[1] = g, c[2] = h, c[3] = i, c[4] = j, c[5] = k, c[6] = l, c[7] = m, c[8] = n, c[9] = o, c[10] = p, c[11] = q, c[12] = f * d + j * e + n * b + a[12], c[13] = g * d + k * e + o * b + a[13], c[14] = h * d + l * e + p * b + a[14], c[15] = i * d + m * e + q * b + a[15]; | |
return c | |
}, d.scale = function(a, b, c) { | |
var d = b[0], | |
e = b[1]; | |
b = b[2]; | |
if (!c || a == c) { | |
a[0] *= d, a[1] *= d, a[2] *= d, a[3] *= d, a[4] *= e, a[5] *= e, a[6] *= e, a[7] *= e, a[8] *= b, a[9] *= b, a[10] *= b, a[11] *= b; | |
return a | |
} | |
c[0] = a[0] * d, c[1] = a[1] * d, c[2] = a[2] * d, c[3] = a[3] * d, c[4] = a[4] * e, c[5] = a[5] * e, c[6] = a[6] * e, c[7] = a[7] * e, c[8] = a[8] * b, c[9] = a[9] * b, c[10] = a[10] * b, c[11] = a[11] * b, c[12] = a[12], c[13] = a[13], c[14] = a[14], c[15] = a[15]; | |
return c | |
}, d.rotate = function(a, b, c, d) { | |
var e = c[0], | |
f = c[1]; | |
c = c[2]; | |
var g = Math.sqrt(e * e + f * f + c * c); | |
if (!g) return null; | |
g != 1 && (g = 1 / g, e *= g, f *= g, c *= g); | |
var h = Math.sin(b), | |
i = Math.cos(b), | |
j = 1 - i; | |
b = a[0], g = a[1]; | |
var k = a[2], | |
l = a[3], | |
m = a[4], | |
n = a[5], | |
o = a[6], | |
p = a[7], | |
q = a[8], | |
r = a[9], | |
s = a[10], | |
t = a[11], | |
u = e * e * j + i, | |
v = f * e * j + c * h, | |
w = c * e * j - f * h, | |
x = e * f * j - c * h, | |
y = f * f * j + i, | |
z = c * f * j + e * h, | |
A = e * c * j + f * h; | |
e = f * c * j - e * h, f = c * c * j + i, d ? a != d && (d[12] = a[12], d[13] = a[13], d[14] = a[14], d[15] = a[15]) : d = a, d[0] = b * u + m * v + q * w, d[1] = g * u + n * v + r * w, d[2] = k * u + o * v + s * w, d[3] = l * u + p * v + t * w, d[4] = b * x + m * y + q * z, d[5] = g * x + n * y + r * z, d[6] = k * x + o * y + s * z, d[7] = l * x + p * y + t * z, d[8] = b * A + m * e + q * f, d[9] = g * A + n * e + r * f, d[10] = k * A + o * e + s * f, d[11] = l * A + p * e + t * f; | |
return d | |
}, d.rotateX = function(a, b, c) { | |
var d = Math.sin(b); | |
b = Math.cos(b); | |
var e = a[4], | |
f = a[5], | |
g = a[6], | |
h = a[7], | |
i = a[8], | |
j = a[9], | |
k = a[10], | |
l = a[11]; | |
c ? a != c && (c[0] = a[0], c[1] = a[1], c[2] = a[2], c[3] = a[3], c[12] = a[12], c[13] = a[13], c[14] = a[14], c[15] = a[15]) : c = a, c[4] = e * b + i * d, c[5] = f * b + j * d, c[6] = g * b + k * d, c[7] = h * b + l * d, c[8] = e * -d + i * b, c[9] = f * -d + j * b, c[10] = g * -d + k * b, c[11] = h * -d + l * b; | |
return c | |
}, d.rotateY = function(a, b, c) { | |
var d = | |
Math.sin(b); | |
b = Math.cos(b); | |
var e = a[0], | |
f = a[1], | |
g = a[2], | |
h = a[3], | |
i = a[8], | |
j = a[9], | |
k = a[10], | |
l = a[11]; | |
c ? a != c && (c[4] = a[4], c[5] = a[5], c[6] = a[6], c[7] = a[7], c[12] = a[12], c[13] = a[13], c[14] = a[14], c[15] = a[15]) : c = a, c[0] = e * b + i * -d, c[1] = f * b + j * -d, c[2] = g * b + k * -d, c[3] = h * b + l * -d, c[8] = e * d + i * b, c[9] = f * d + j * b, c[10] = g * d + k * b, c[11] = h * d + l * b; | |
return c | |
}, d.rotateZ = function(a, b, c) { | |
var d = Math.sin(b); | |
b = Math.cos(b); | |
var e = a[0], | |
f = a[1], | |
g = a[2], | |
h = a[3], | |
i = a[4], | |
j = a[5], | |
k = a[6], | |
l = a[7]; | |
c ? a != c && (c[8] = a[8], c[9] = a[9], c[10] = a[10], c[11] = a[11], c[12] = a[12], c[13] = a[13], c[14] = a[14], c[15] = a[15]) : c = a, c[0] = e * b + i * d, c[1] = f * b + j * d, c[2] = g * b + k * d, c[3] = h * b + l * d, c[4] = e * -d + i * b, c[5] = f * -d + j * b, c[6] = g * -d + k * b, c[7] = h * -d + l * b; | |
return c | |
}, d.frustum = function(a, b, c, e, f, g, h) { | |
h || (h = d.create()); | |
var i = b - a, | |
j = e - c, | |
k = g - f; | |
h[0] = f * 2 / i, h[1] = 0, h[2] = 0, h[3] = 0, h[4] = 0, h[5] = f * 2 / j, h[6] = 0, h[7] = 0, h[8] = (b + a) / i, h[9] = (e + c) / j, h[10] = -(g + f) / k, h[11] = -1, h[12] = 0, h[13] = 0, h[14] = -(g * f * 2) / k, h[15] = 0; | |
return h | |
}, d.perspective = function(a, b, c, e, f) { | |
a = c * Math.tan(a * Math.PI / 360), b = a * b; | |
return d.frustum(-b, b, -a, a, c, e, f) | |
}, d.ortho = function(a, b, c, e, f, g, h) { | |
h || (h = d.create()); | |
var i = b - a, | |
j = e - c, | |
k = g - f; | |
h[0] = 2 / i, h[1] = 0, h[2] = 0, h[3] = 0, h[4] = 0, h[5] = 2 / j, h[6] = 0, h[7] = 0, h[8] = 0, h[9] = 0, h[10] = -2 / k, h[11] = 0, h[12] = -(a + b) / i, h[13] = -(e + c) / j, h[14] = -(g + f) / k, h[15] = 1; | |
return h | |
}, d.lookAt = function(a, b, c, e) { | |
e || (e = d.create()); | |
var f = a[0], | |
g = a[1]; | |
a = a[2]; | |
var h = c[0], | |
i = c[1], | |
j = c[2]; | |
c = b[1]; | |
var k = b[2]; | |
if (f == b[0] && g == c && a == k) return d.identity(e); | |
var l, m, n, o; | |
c = f - b[0], k = g - b[1], b = a - b[2], o = 1 / Math.sqrt(c * c + k * k + b * b), c *= o, k *= o, b *= o, l = i * b - j * k, j = j * c - h * b, h = h * k - i * c, (o = Math.sqrt(l * l + j * j + h * h)) ? (o = 1 / o, l *= o, j *= o, h *= o) : h = j = l = 0, i = k * h - b * j, m = b * l - c * h, n = c * j - k * l, (o = Math.sqrt(i * i + m * m + n * n)) ? (o = 1 / o, i *= o, m *= o, n *= o) : n = m = i = 0, e[0] = l, e[1] = i, e[2] = c, e[3] = 0, e[4] = j, e[5] = m, e[6] = k, e[7] = 0, e[8] = h, e[9] = n, e[10] = b, e[11] = 0, e[12] = -(l * f + j * g + h * a), e[13] = -(i * f + m * g + n * a), e[14] = -(c * f + k * g + b * a), e[15] = 1; | |
return e | |
}, d.str = function(a) { | |
return "[" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ", " + a[9] + ", " + a[10] + ", " + a[11] + ", " + a[12] + ", " + a[13] + ", " + a[14] + ", " + a[15] + "]" | |
}, quat4 = {}, quat4.create = function(a) { | |
var b = new glMatrixArrayType(4); | |
a && (b[0] = a[0], b[1] = a[1], b[2] = a[2], b[3] = a[3]); | |
return b | |
}, quat4.set = function(a, b) { | |
b[0] = a[0], b[1] = a[1], b[2] = a[2], b[3] = a[3]; | |
return b | |
}, quat4.calculateW = function(a, b) { | |
var c = a[0], | |
d = a[1], | |
e = a[2]; | |
if (!b || a == b) { | |
a[3] = -Math.sqrt(Math.abs(1 - c * c - d * d - e * e)); | |
return a | |
} | |
b[0] = c, b[1] = d, b[2] = e, b[3] = -Math.sqrt(Math.abs(1 - c * c - d * d - e * e)); | |
return b | |
}, quat4.inverse = function( | |
a, b) { | |
if (!b || a == b) { | |
a[0] *= 1, a[1] *= 1, a[2] *= 1; | |
return a | |
} | |
b[0] = -a[0], b[1] = -a[1], b[2] = -a[2], b[3] = a[3]; | |
return b | |
}, quat4.length = function(a) { | |
var b = a[0], | |
c = a[1], | |
d = a[2]; | |
a = a[3]; | |
return Math.sqrt(b * b + c * c + d * d + a * a) | |
}, quat4.normalize = function(a, b) { | |
b || (b = a); | |
var c = a[0], | |
d = a[1], | |
e = a[2], | |
f = a[3], | |
g = Math.sqrt(c * c + d * d + e * e + f * f); | |
if (g == 0) { | |
b[0] = 0, b[1] = 0, b[2] = 0, b[3] = 0; | |
return b | |
} | |
g = 1 / g, b[0] = c * g, b[1] = d * g, b[2] = e * g, b[3] = f * g; | |
return b | |
}, quat4.multiply = function(a, b, c) { | |
c || (c = a); | |
var d = a[0], | |
e = a[1], | |
f = a[2]; | |
a = a[3]; | |
var g = b[0], | |
h = b[1], | |
i = b[2]; | |
b = b[3], c[0] = d * b + a * g + e * i - f * h, c[1] = e * b + a * h + f * g - d * i, c[2] = f * b + a * i + d * h - e * g, c[3] = a * b - d * g - e * h - f * i; | |
return c | |
}, quat4.multiplyVec3 = | |
function(a, b, c) { | |
c || (c = b); | |
var d = b[0], | |
e = b[1], | |
f = b[2]; | |
b = a[0]; | |
var g = a[1], | |
h = a[2]; | |
a = a[3]; | |
var i = a * d + g * f - h * e, | |
j = a * e + h * d - b * f, | |
k = a * f + b * e - g * d; | |
d = -b * d - g * e - h * f, c[0] = i * a + d * -b + j * -h - k * -g, c[1] = j * a + d * -g + k * -b - i * -h, c[2] = k * a + d * -h + i * -g - j * -b; | |
return c | |
}, quat4.toMat3 = function(a, b) { | |
b || (b = c.create()); | |
var d = a[0], | |
e = a[1], | |
f = a[2], | |
g = a[3], | |
h = d + d, | |
i = e + e, | |
j = f + f, | |
k = d * h, | |
l = d * i; | |
d = d * j; | |
var m = e * i; | |
e = e * j, f = f * j, h = g * h, i = g * i, g = g * j, b[0] = 1 - (m + f), b[1] = l - g, b[2] = d + i, b[3] = l + g, b[4] = 1 - (k + f), b[5] = e - h, b[6] = d - i, b[7] = e + h, b[8] = 1 - (k + m); | |
return b | |
}, quat4.toMat4 = function(a, b) { | |
b || (b = d.create()); | |
var c = a[0], | |
e = a[1], | |
f = a[2], | |
g = a[3], | |
h = c + c, | |
i = e + e, | |
j = f + f, | |
k = c * h, | |
l = c * i; | |
c = c * j; | |
var m = e * i; | |
e = e * j, f = f * j, h = g * h, i = g * i, g = g * j, b[0] = 1 - (m + f), b[1] = l - g, b[2] = c + i, b[3] = 0, b[4] = l + g, b[5] = 1 - (k + f), b[6] = e - h, b[7] = 0, b[8] = c - i, b[9] = e + h, b[10] = 1 - (k + m), b[11] = 0, b[12] = 0, b[13] = 0, b[14] = 0, b[15] = 1; | |
return b | |
}, quat4.str = function(a) { | |
return "[" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + "]" | |
}, b.linearMix = function(a, c, d, e) { | |
e || (e = b.create()); | |
var f = 1 - d; | |
e[0] = a[0] * d + c[0] * f, e[1] = a[1] * d + c[1] * f, e[2] = a[2] * d + c[2] * f; | |
return e | |
}, b.x = function(a, c) { | |
var d = b.create(a); | |
return b.scale(d, c) | |
}, b.ncross = function(a, c) { | |
var d = b.create(a); | |
return b.cross(d, c) | |
}, b.nsubtract = function(a, c) { | |
var d = b.create(a); | |
return b.subtract(d, c) | |
}, b.nadd = function(a, c) { | |
var d = | |
b.create(a); | |
return b.add(d, c) | |
}, b.nadd3 = function(a, c) { | |
var d = b.create(a); | |
return b.add(d, c) | |
}, b.nnegate = function(a) { | |
var c = b.create(a); | |
return b.negate(c) | |
}, b.distance = function(a, b) { | |
var c = a[0] - b[0], | |
d = a[1] - b[1], | |
e = a[2] - b[2]; | |
return Math.sqrt(c * c + d * d + e * e) | |
}, d.nidentity = function() { | |
return d.identity(d.create()) | |
}, m.prototype.pushMatrix = function(a) { | |
this.stackTop >= this.stack.length && this.stack.push(d.create()), a ? (d.set(a, this.stack[this.stackTop]), d.set(a, this.current)) : d.set(this.current, this.stack[this.stackTop]), ++this.stackTop | |
}, m.prototype.popMatrix = function() { | |
if (this.stackTop === 0) throw "Invalid popMatrix!"; | |
--this.stackTop, d.set(this.stack[this.stackTop], this.current); | |
return this.current | |
}, m.prototype.loadIdentity = function() { | |
d.identity(this.current) | |
}, m.prototype.load = function(a) { | |
d.set(a, this.current) | |
}, m.prototype.multMatrix = function(a) { | |
d.multiply(this.current, a) | |
}, m.prototype.translate = function(a) { | |
d.translate(this.current, a) | |
}, m.prototype.scale = function(a) { | |
d.scale(this.current, [a, a, a]) | |
}, m.prototype.rotate = function(a, b) { | |
d.rotate(this.current, j(a), b) | |
}, m.prototype.rotateX = function(a) { | |
d.rotateX(this.current, j(a)) | |
}, m.prototype.rotateY = function(a) { | |
d.rotateY(this.current, j(a)) | |
}, m.prototype.rotateZ = function(a) { | |
d.rotateZ(this.current, j(a)) | |
}, m.prototype.perspective = function(a, b, c, e) { | |
d.perspective(a, b, c, e, this.current) | |
}; | |
var n = new m, | |
o = new m; | |
q.prototype.init = function(a, b) { | |
var c = p(cC, a), | |
d = p(cC, b); | |
this.prog = cC.createProgram(), cC.attachShader(this.prog, d), cC.attachShader(this.prog, c), cC.linkProgram(this.prog); | |
if (!cC.getProgramParameter(this.prog, cC.LINK_STATUS)) { | |
alert("Could not initialise shaders"); | |
return null | |
} | |
cC.useProgram(this.prog), this.vertexPositionAttribute = cC.getAttribLocation(this.prog, "aVertexPosition"), cC.enableVertexAttribArray(this.vertexPositionAttribute), this.vertexNormalAttribute = cC.getAttribLocation(this.prog, "aVertexNormal"), cC.enableVertexAttribArray(this.vertexNormalAttribute), this.pMatrixUniform = cC.getUniformLocation(this.prog, "uPMatrix"), this.mvMatrixUniform = cC.getUniformLocation(this.prog, "uMVMatrix"), this.useLightingUniform = cC.getUniformLocation(this.prog, "uUseLighting"), this.ambientColorUniform = cC.getUniformLocation(this.prog, "uAmbientColor"), this.pointLightingLocationUniform = cC.getUniformLocation(this.prog, "uPointLightingLocation"), this.pointLightingSpecularColorUniform = cC.getUniformLocation(this.prog, "uPointLightingSpecularColor"), this.pointLightingDiffuseColorUniform = cC.getUniformLocation(this.prog, "uPointLightingDiffuseColor"), this.globColorUniform = cC.getUniformLocation(this.prog, "uGlobColor"), this.twoSidedUniform = cC.getUniformLocation(this.prog, "uTwoSided") | |
}, q.prototype.setMatrixUniforms = function() { | |
cC.uniformMatrix4fv(this.pMatrixUniform, !1, o.current), cC.uniformMatrix4fv(this.mvMatrixUniform, !1, n.current) | |
}, q.prototype.setColor = function(a, b, c) { | |
cC.uniform4f(this.globColorUniform, a, b, c, 1) | |
}, q.prototype.setColor4 = function(a, b, c, d) { | |
cC.uniform4f(this.globColorUniform, a, b, c, d) | |
}, q.prototype.setColorv = function(a) { | |
cC.uniform4f(this.globColorUniform, a[0], a[1], a[2], 1) | |
}, q.prototype.setColor4v = | |
function(a) { | |
cC.uniform4f(this.globColorUniform, a[0], a[1], a[2], a[3]) | |
}, q.prototype.setTwoSided = function(a) { | |
cC.uniform1i(this.twoSidedUniform, a) | |
}, q.prototype.setUseLight = function(a) { | |
cC.uniform1i(this.useLightingUniform, a) | |
}, q.prototype.enableNormals = function(a) { | |
a ? cC.enableVertexAttribArray(this.vertexNormalAttribute) : cC.disableVertexAttribArray(this.vertexNormalAttribute) | |
}, r.Data = function(a, b, c, d) { | |
if (arguments.length != 4) throw new Error("GLBuffer.Data needs 4 arguments"); | |
var e = new r(a); | |
cC.bindBuffer(e.target, e.buf), cC.bufferData(e.target, b, c), e.itemSize = d, e.numItems = b.length / d, b instanceof Float32Array ? e.type = cC.FLOAT : b instanceof Uint32Array ? e.type = cC.UNSIGNED_INT : b instanceof Int32Array ? e.type = cC.INT : b instanceof Uint16Array ? e.type = cC.UNSIGNED_SHORT : b instanceof Int16Array ? e.type = cC.SHORT : b instanceof Uint8Array ? e.type = cC.UNSIGNED_BYTE : b instanceof Int8Array && (e.type = cC.BYTE); | |
return e | |
}, r.Size = function(a, b, c, d, e, f) { | |
if (arguments.length < 5) throw new Error("GLBuffer.Size needs 5 or 6 arguments"); | |
var g = new r(a); | |
g.itemSize = c, g.numItems = 0, g.allocElements = c * d; | |
var h = s()[b]; | |
g.bytesInElement = h.byteSize, cC.bindBuffer(g.target, g.buf), cC.bufferData(g.target, g.bytesInElement * c * d, e), f && (g.record = new h.arrCtor(c * d)); | |
return g | |
}, r.prototype.append = function(a) { | |
if (!this.allocElements) throw new Error("Cannot append to this kind of GLBuffer"); | |
if (a.BYTES_PER_ELEMENT !== this.bytesInElement) throw new Error("Cannot append this type of array " + a.toString + " != " + this.bytesInElement); | |
if (this.numItems + a.length >= this.allocElements) return null; | |
cC.bindBuffer(this.target, this.buf), cC.bufferSubData(this.target, this.numItems * this.itemSize * this.bytesInElement, a); | |
if (this.record) for (var b = 0; b < a.length; ++b) this.record[this.numItems * this.itemSize + b] = a[b]; | |
var c = this.numItems; | |
this.numItems += a.length / this.itemSize; | |
return c | |
}, r.prototype.backtrack = function(a) { | |
this.numItems -= a, this.numItems = Math.max(this.numItems, 0) | |
}, r.prototype.bind = function() { | |
cC.bindBuffer(this.target, this.buf) | |
}, r.prototype.rewriteWithRecord = function() { | |
cC.bindBuffer(this.target, this.buf), cC.bufferSubData(this.target, 0, this.record) | |
}; | |
var t = { | |
Left: { | |
name: "Left", | |
opposite: {}, | |
leftHand: {}, | |
rightHand: {}, | |
move: null | |
}, | |
Right: { | |
name: "Right", | |
opposite: {}, | |
leftHand: {}, | |
rightHand: {}, | |
move: null | |
}, | |
Up: { | |
name: "Up", | |
opposite: {}, | |
leftHand: {}, | |
rightHand: {}, | |
move: null | |
}, | |
Down: { | |
name: "Down", | |
opposite: {}, | |
leftHand: {}, | |
rightHand: {}, | |
move: null | |
} | |
}; | |
t.Left.opposite = t.Right, t.Left.leftHand = t.Down, t.Left.rightHand = | |
t.Up, t.Right.opposite = t.Left, t.Right.leftHand = t.Up, t.Right.rightHand = t.Down, t.Up.opposite = t.Down, t.Up.leftHand = t.Left, t.Up.rightHand = t.Right, t.Down.opposite = t.Up, t.Down.leftHand = t.Right, t.Down.rightHand = t.Left; | |
var u = [{ | |
model: [.2, .22, 1], | |
trail: [.1, .1, 1], | |
text: "#3939FF", | |
name: "Blue" | |
}, { | |
model: [1, .12, .1], | |
trail: [1, .1, .1], | |
text: "#FF1313", | |
name: "Red" | |
}, { | |
model: [1, .43, 0], | |
trail: [1, .48, 0], | |
text: "#FF6701", | |
name: "Orange" | |
}, { | |
model: [0, .82, .1], | |
trail: [0, .9, .1], | |
text: "#14A800", | |
name: "Green" | |
}, { | |
model: [.74, .1, 1], | |
trail: [.71, 0, 1], | |
text: "#D21DFF", | |
name: "Purple" | |
}, { | |
model: [1, .92, .1], | |
trail: [1, .92, .1], | |
text: "#FFE401", | |
name: "Yellow" | |
}]; | |
w.prototype.init = function() { | |
this.normal = cF.model.normals[this.point], this.rightHand = b.ncross(this.forward, this.normal); | |
var a = cF.model.vtx.length * 2; | |
this.wall.idxRbuf = r.Size(cC.ELEMENT_ARRAY_BUFFER, cC.UNSIGNED_SHORT, 1, a, cC.DYNAMIC_DRAW), this.wall.idxLbuf = r.Size(cC.ELEMENT_ARRAY_BUFFER, cC.UNSIGNED_SHORT, 1, a, cC.DYNAMIC_DRAW), this.wall.idxTbuf = r.Size(cC.ELEMENT_ARRAY_BUFFER, cC.UNSIGNED_SHORT, 1, a, cC.DYNAMIC_DRAW); | |
var c = cF.model.vtx.length * 3 * 4; | |
this.wall.vtxBuf = r.Size(cC.ARRAY_BUFFER, cC.FLOAT, 3, c, cC.DYNAMIC_DRAW, !0), this.wall.normalsBuf = r.Size(cC.ARRAY_BUFFER, cC.FLOAT, 3, c, cC.DYNAMIC_DRAW), this.wall.idxTbuf.append(new Uint16Array([0, 2, 4, 5])), this.postMove(this.eDir), this.ready = !0 | |
}, v.POINT_DELAY = 4, v.prototype.addRawPoint = function() { | |
function n(a, b) { | |
m[0] = a, m[1] = b; | |
return m | |
} | |
function l() { | |
var a = 0; | |
for (var b = 1; b < 7; ++b) k[a++] = arguments[b][0], k[a++] = arguments[b][1], k[a++] = arguments[b][2]; | |
return k | |
} | |
var a = b.create(), | |
c = b.create(), | |
d = b.create(), | |
e = b.create(), | |
f = b.create(), | |
g = b.create(), | |
h = b.create(), | |
i = b.create(), | |
j = b.create(), | |
k = new Float32Array(18), | |
m = new Uint16Array(2); | |
return function(m, o, p, q, r, s) { | |
var t = cF.model.scale.WALL_WIDTH, | |
u = cF.model.scale.WALL_HEIGHT; | |
b.set(s, a), b.scale(a, o), b.set(s, c), b.scale(c, m), b.set(r, d), b.add(d, a), b.set(r, e), b.negate(e), b.add(e, c), cI.bikeFlip && (b.negate(q, f), q = f), this.normalsBuf.append(l(k, d, d, e, e, q, q)), b.set(r, g), b.scale(g, t), b.add(g, p), b.scale(a, t), b.add(g, a), b.set(r, h), b.scale(h, -t), b.add(h, p), b.scale(c, t), b.add(h, c), b.scale(q, u, a), b.set(g, i), b.add(i, a), b.set(h, j), b.add(j, a); | |
var v = this.vtxBuf.append(l(k, g, i, h, j, i, j)); | |
this.idxRbuf.append(n(v, v + 1)), this.idxLbuf.append(n(v + 2, v + 3)), this.idxTbuf.append(n(v + 4, v + 5)) | |
} | |
}(), v.prototype.addPoint = function(a, b, c) { | |
this.pntRecord.push(c.point); | |
var d = cF.model.vtx[c.point], | |
e = cF.model.normals[c.point]; | |
this.addRawPoint(a, b, d, e, c.rightHand, c.forward) | |
}, v.prototype.backtrackRawPoint = function() { | |
this.vtxBuf.backtrack(6), this.normalsBuf.backtrack(6), this.idxRbuf.backtrack(2), this.idxLbuf.backtrack(2), this.idxTbuf.backtrack(2) | |
}, v.prototype.backtrackPoint = function() { | |
this.pntRecord.pop(), this.backtrackRawPoint() | |
}, v.prototype.queuePoint = function(a, b, c) { | |
if (v.POINT_DELAY === 0) this.addPoint(a, b, c); | |
else { | |
this.queue.push({ | |
la: a, | |
ra: b, | |
playerDummy: { | |
point: c.point, | |
forward: c.forward, | |
rightHand: c.rightHand | |
} | |
}); | |
if (this.queue.length > v.POINT_DELAY) { | |
var d = this.queue.shift(); | |
this.addPoint(d.la, d.ra, d.playerDummy) | |
} | |
} | |
}, v.prototype.queueBacktrack = function() { | |
v.POINT_DELAY === 0 || this.queue.length === 0 ? this.backtrackPoint() : this.queue.pop() | |
}, v.prototype.flushQueue = function() { | |
while (this.queue.length > 0) { | |
var a = this.queue.shift(); | |
this.addPoint(a.la, a.ra, a.playerDummy) | |
} | |
}, v.prototype.deathEnd = function(a) { | |
this.queueBacktrack(), this.queuePoint(-1, -1, a), this.flushQueue() | |
}, v.prototype.setWallHeight = function(a) { | |
var c = a * cF.model.scale.WALL_HEIGHT; | |
cI.bikeFlip && (c = -c); | |
var d = this.vtxBuf.record, | |
e = this.pntRecord.length; | |
for (var f = 0; f < e; ++f) { | |
var g = b.x(cF.model.normals[this.pntRecord[f]], c), | |
h = f * 6 * 3, | |
i = b.create([d[h], d[h + 1], d[h + 2]]); | |
h = (f * 6 + 2) * 3; | |
var j = b.create([d[h], d[h + 1], d[h + 2]]); | |
i = b.nadd(i, g), j = b.nadd(j, g), h = (f * 6 + 1) * 3, d[h] = i[0], d[h + 1] = i[1], d[h + 2] = i[2], h = (f * 6 + 4) * 3, d[h] = i[0], d[h + 1] = i[1], d[h + 2] = i[2], h = (f * 6 + 3) * 3, d[h] = j[0], d[h + 1] = j[1], d[h + 2] = j[2], h = (f * 6 + 5) * 3, d[h] = j[0], d[h + 1] = j[1], d[h + 2] = j[2] | |
} | |
this.vtxBuf.rewriteWithRecord() | |
}, v.prototype.fracExtend = function(a) { | |
if (this.pntRecord.length === 0) return !1; | |
var c = this.pntRecord[this.pntRecord.length - 1], | |
d; | |
this.queue.length > 0 ? d = this.queue[0].playerDummy : d = a; | |
var e = d.point, | |
f = a.curStepFrac, | |
g = b.linearMix(cF.model.vtx[e], cF.model.vtx[c], f), | |
h = cF.model.normals[e], | |
i = d.rightHand, | |
j = d.forward; | |
this.addRawPoint(0, 0, g, h, i, j); | |
return !0 | |
}, w.prototype.getBikeOrient = function() { | |
var a, c; | |
if (this.wall.queue.length == 0) a = this.forward, c = cF.model.normals[this.point]; | |
else if (this.wall.queue.length == 1) { | |
var d = this.wall.queue[0].playerDummy; | |
a = d.forward, c = cF.model.normals[d.point] | |
} else { | |
var e = Math.min(this.wall.queue.length - 1, 1), | |
d = this.wall.queue[e].playerDummy, | |
f = this.wall.queue[e - 1].playerDummy, | |
g = this.curStepFrac; | |
a = b.linearMix(d.forward, f.forward, g), c = b.linearMix(cF.model.normals[d.point], cF.model.normals[f.point], g) | |
} | |
return { | |
normal: c, | |
forward: a | |
} | |
}; | |
var x = { | |
rightHand: { | |
4: 1, | |
3: 1, | |
5: 1, | |
6: 1 | |
}, | |
forward: { | |
4: 2, | |
3: 1, | |
5: 2, | |
6: 3 | |
}, | |
leftHand: { | |
4: 3, | |
3: 2, | |
5: 4, | |
6: 5 | |
}, | |
back: { | |
4: 0, | |
3: 0, | |
5: 0, | |
6: 0 | |
} | |
}; | |
w.prototype.preMove = function( | |
a) { | |
var c; | |
a === this.eDir.rightHand ? (this.wall.queueBacktrack(), this.wall.queuePoint(1, -1, this), this.wall.flushQueue(), this.turnCallback && this.turnCallback(!1), c = x.rightHand) : a === this.eDir.leftHand ? (this.wall.queueBacktrack(), this.wall.queuePoint(-1, 1, this), this.wall.flushQueue(), this.turnCallback && this.turnCallback(!0), c = x.leftHand) : c = x.forward; | |
var d = z(this.point, c, this.last.point), | |
e = b.nsubtract(cF.model.vtx[d], cF.model.vtx[this.point]), | |
f = cF.model.nei[this.point].d[d]; | |
this.last = { | |
point: this.point, | |
normal: this.normal, | |
upDir: this.upDir, | |
forward: this.forward | |
}, this.point = d, this.normal = cF.model.normals[this.point]; | |
return { | |
tonext: e, | |
dist: f | |
} | |
}, w.prototype.postMove = function(a) { | |
this.rightHand = b.ncross(this.forward, this.normal), this.wall.queuePoint(0, 0, this), this.eDir = a | |
}, w.prototype.moveUp = function() { | |
var a = this.preMove(t.Up); | |
this.rightHand = b.normalize(b.ncross(a.tonext, this.normal)), this.upDir = b.normalize(b.ncross(this.normal, this.rightHand)), this.forward = this.upDir, this.postMove(t.Up); | |
return a.dist | |
}, w.prototype.moveDown = function() { | |
var a = this.preMove(t.Down); | |
this.rightHand = b.normalize(b.ncross(this.normal, a.tonext)), this.upDir = b.normalize(b.ncross(this.normal, this.rightHand)), this.forward = b.nnegate(this. | |
upDir), this.postMove(t.Down); | |
return a.dist | |
}, w.prototype.moveLeft = function() { | |
var a = this.preMove(t.Left); | |
this.upDir = b.normalize(b.ncross(a.tonext, this.normal)), this.rightHand = b.normalize(b.ncross(this.upDir, this.normal)), this.forward = b.nnegate(this.rightHand), this.postMove(t.Left); | |
return a.dist | |
}, w.prototype.moveRight = function() { | |
var a = this.preMove(t.Right); | |
this.upDir = b.normalize(b.ncross(this.normal, a.tonext)), this.rightHand = b.normalize(b.ncross(this.upDir, this.normal)), this.forward = this.rightHand, this.postMove(t.Right); | |
return a.dist | |
}, t.Up.move = w.prototype.moveUp, t.Down.move = w.prototype.moveDown, t.Right.move = w.prototype.moveRight, t.Left.move = w.prototype.moveLeft, w.prototype.prettyName = function() { | |
return "<" + this.id + ">" + this.name + "</>" | |
}; | |
var B = { | |
mouseEnabled: !1, | |
mouseDown: !1, | |
lastMouseX: null, | |
lastMouseY: null, | |
rotationMatrix: d.nidentity(), | |
currentlyPressedDirs: [] | |
}; | |
if (typeof G == "undefined") var G = { | |
DOM_VK_RETURN: 13, | |
DOM_VK_ENTER: 14, | |
DOM_VK_PAUSE: 19, | |
DOM_VK_ESCAPE: 27, | |
DOM_VK_SPACE: 32, | |
DOM_VK_LEFT: 37, | |
DOM_VK_UP: 38, | |
DOM_VK_RIGHT: 39, | |
DOM_VK_DOWN: 40, | |
DOM_VK_0: 48, | |
DOM_VK_1: 49, | |
DOM_VK_2: 50, | |
DOM_VK_3: 51, | |
DOM_VK_4: 52, | |
DOM_VK_5: 53, | |
DOM_VK_6: 54, | |
DOM_VK_7: 55, | |
DOM_VK_8: 56, | |
DOM_VK_9: 57, | |
DOM_VK_A: 65, | |
DOM_VK_B: 66, | |
DOM_VK_C: 67, | |
DOM_VK_D: 68, | |
DOM_VK_E: 69, | |
DOM_VK_F: 70, | |
DOM_VK_G: 71, | |
DOM_VK_H: 72, | |
DOM_VK_I: 73, | |
DOM_VK_J: 74, | |
DOM_VK_K: 75, | |
DOM_VK_L: 76, | |
DOM_VK_M: 77, | |
DOM_VK_N: 78, | |
DOM_VK_O: 79, | |
DOM_VK_P: 80, | |
DOM_VK_Q: 81, | |
DOM_VK_R: 82, | |
DOM_VK_S: 83, | |
DOM_VK_T: 84, | |
DOM_VK_U: 85, | |
DOM_VK_V: 86, | |
DOM_VK_W: 87, | |
DOM_VK_X: 88, | |
DOM_VK_Y: 89, | |
DOM_VK_Z: 90, | |
DOM_VK_F1: 112, | |
DOM_VK_F2: 113, | |
DOM_VK_F3: 114, | |
DOM_VK_F4: 115, | |
DOM_VK_F5: 116, | |
DOM_VK_F6: 117, | |
DOM_VK_F7: 118, | |
DOM_VK_F8: 119, | |
DOM_VK_F9: 120, | |
DOM_VK_F10: 121, | |
DOM_VK_F11: 122, | |
DOM_VK_F12: 123 | |
}; | |
var H = {}; | |
H[G.DOM_VK_LEFT] = t.Left, H[G.DOM_VK_RIGHT] = t.Right, H[G.DOM_VK_UP] = t.Up, H[G.DOM_VK_DOWN] = t.Down, H[G.DOM_VK_W] = t.Up, H[G.DOM_VK_A] = t.Left, H[G.DOM_VK_S] = t.Down, H[G.DOM_VK_D] = t.Right; | |
var U = 100, | |
V = .03, | |
W = 40, | |
X = .015, | |
Z = [{}, { | |
stepsAhead: 2 | |
}, { | |
stepsAhead: 5 | |
}, { | |
stepsAhead: 10 | |
}, { | |
stepsAhead: 15 | |
}, { | |
stepsAhead: 20 | |
}]; | |
_.prototype.turnLeft = function() { | |
this.player.selDir = this.player.eDir.leftHand | |
}, _.prototype.turnRight = function() { | |
this.player.selDir = this.player.eDir.rightHand | |
}, _.prototype.turnToAvailableSide = function(a) { | |
this.occRight = ba(a.toRight), this.occLeft = ba(a.toLeft); | |
if (!this.occRight || !this.occLeft) if (!this.occRight && !this.occLeft) { | |
if (this.checkFarBlocks()) return; | |
g(.5) ? this.turnLeft() : this.turnRight() | |
} else this.occRight ? this.turnLeft() : this.occLeft && this.turnRight() | |
}, bb.prototype.init = function(a, b) { | |
this.last = b, this.point = a, this.count = 0, this.ok = !0; | |
return this | |
}, bb.prototype.goRelDir = function(a) { | |
var b = this.point; | |
this.point = z(this.point, a, this.last), this.last = b; | |
if (ba(this.point)) { | |
this.ok = !1; | |
return !1 | |
}++this.count; | |
return !0 | |
}, bb.prototype.goForward = function() { | |
return this.goRelDir(x.forward) | |
}, bb.prototype.goRight = function() { | |
return this.goRelDir(x.rightHand) | |
}, bb.prototype.goLeft = function() { | |
return this.goRelDir(x.leftHand) | |
}, _.prototype.checkFarBlocks = function() { | |
var a = this.player.point, | |
b = this.player.last.point; | |
this.look.init(a, b).goLeft(); | |
var c = bc(this.look, this.stepsAhead, 1); | |
this.look.init(a, b).goRight(); | |
var d = bc(this.look, this.stepsAhead, 1); | |
if (c > d) this.turnLeft(); | |
else if (c < d) this.turnRight(); | |
else | |
return !1; | |
return !0 | |
}, _.prototype.moveControl = function(a) { | |
var b = A(this.player.point, this.player.last.point), | |
c = ba(b.toFwd); | |
if (c) this.turnToAvailableSide(b); | |
else if (g(2)) { | |
this.turnToAvailableSide(b); | |
return | |
} | |
}, bd.TOTAL_TIME = 800, bd.RING_MAX_SIZE = 1.5, bd.SPIKES_TIME = 320, bd.SPIKES_MAX_SIZE = .8, bd.prototype.draw = function() { | |
n.pushMatrix(), cE.setUseLight(!1), cC.enable(cC.BLEND), n.translate([0, 0, -cF.model.scale.WALL_WIDTH * 1.2]), n.scale(cF.model.scale.GLOBAL_SCALE); | |
for (var a = 0; a < this.ringsScale.length; ++a) { | |
var b = this.ringsScale[a]; | |
if (b < .1 || b > bd.RING_MAX_SIZE) continue; | |
var c = (b - bd.RING_MAX_SIZE) / (.2 - bd.RING_MAX_SIZE); | |
cE.setColor4(1, .6, .1, c), n.pushMatrix(), n.scale(b, b, b), this.player === cG && n.rotate(90, [1, 0, 0]), cq(cb.explode.ring), n.popMatrix() | |
} | |
this.showSpikes && (n.scale(this.spikesScale, this.spikesScale, this.spikesScale), cE.setColor(1, .6 + this.spikesScale, this.spikesScale), this.player === cG && n.rotate(90, [1, 0, 0]), cq(cb.explode.spikes)), cC.disable(cC.BLEND), cE.setUseLight(!0), n.popMatrix() | |
}, bd.prototype.advance = function(a) { | |
for (var b = 0; b < this.ringsScale.length; ++b) this.ringsScale[b] += a * ((bd.RING_MAX_SIZE + 1) / bd.TOTAL_TIME); | |
this.spikesScale += a * (bd.SPIKES_MAX_SIZE / bd.SPIKES_TIME), this.elapsed += a, this.elapsed > bd.SPIKES_TIME && (this.showSpikes = !1), this.elapsed > bd.TOTAL_TIME && (this.player.sfx.explode = null, bQ.handler !== null && bQ.called === !1 && bQ.handler()) | |
}, bf.START_DELAY = 500, bf.HEIGHT_DELAY = 250, bf.DECENT_TIME = 900, bf.BRIGHT_TIME = 340, bf.DARKEN_TIME = 200, bf.prototype.advance = function(a) { | |
this.elapsed += a, this.elapsed <= bf.BRIGHT_TIME ? this.brightness = this.elapsed * (1 / bf.BRIGHT_TIME) : this.brightness = Math.max(0, 1 - (this.elapsed - bf.BRIGHT_TIME) * (1 / bf.DARKEN_TIME)), this.elapsed >= bf.HEIGHT_DELAY && (this.height = 1 - (this.elapsed - bf.BRIGHT_TIME) * (1 / bf.DECENT_TIME), this.height = Math.min(1, Math.max(0, this.height))); | |
if (this.height <= 0) { | |
this.player.sfx.wall_decent = null; | |
var b = this.player.wall; | |
b.standing = !1; | |
for (var c = 0; c < b.pntRecord.length - 1; ++c) cF.map[b.pntRecord[c]] = undefined | |
} else this.player.wall.setWallHeight(this.height) | |
}, bj.prototype.getColor = function(a) { | |
return l(a / 360, 1, .5) | |
}, bj.prototype.draw = function() { | |
n.pushMatrix(), n.translate(cF.model.vtx[this.point]); | |
var a = cr(this.rightHand, this.normal, this.forward); | |
n.multMatrix(a); | |
var b = cF.model.scale.BONUS_LIFE; | |
cI.bikeFlip && (b = -b), n.translate([0, b * 2.3, 0]), n.scale(b * this.inflate), n.rotateY(this.anglex), n.rotateX(this.angley), cE.setColorv(this.getColor(this.anglex)), cq(cb.life), n.popMatrix() | |
}, bj.INFLATE_TIME = 500, bj.prototype.advance = function(a) { | |
bG.prototype.rotate.call(this, a), this.elapsed < bj.INFLATE_TIME ? (this.elapsed = Math.min(this.elapsed + a, bj.INFLATE_TIME), this.inflate = this.elapsed * (1 / bj.INFLATE_TIME)) : this.inflate = 1 | |
}, bj.prototype.action = function(a) { | |
a === cG && (++bN.userLivesCount, cF.staticDraw.lives.startOneUp()); | |
for (var b in this.occupy) delete cF.map[this.occupy[b]]; | |
delete cF.bonuses[this.index], ca(a), cN.addMessage(a.prettyName() + " found a life bonus") | |
}, bk.prototype.getCamera = | |
function() { | |
return this | |
}, bk.prototype.moveUpdate = function(a) { | |
if (a === cG) { | |
var c = a.curStepFrac; | |
b.linearMix(a.normal, a.last.normal, c, this.eye), b.scale(this.eye, this.eyeDist), b.linearMix(a.upDir, a.last.upDir, c, this.upDir) | |
} | |
}, bk.prototype.translateDir = function(a, b) { | |
return a | |
}, bk.prototype.getLight = function() { | |
return this.lightPoint | |
}, bl.prototype.getCamera = function() { | |
return this | |
}, bl.prototype.moveUpdate = function(a) { | |
if (a === cG) { | |
var c = a.curStepFrac; | |
b.linearMix(a.normal, a.last.normal, c, this.toPoint), b.negate(this.toPoint, this.eye), b.scale(this.eye, this.centerDist), b.linearMix(a.upDir, a.last.upDir, c, this.upDir) | |
} | |
}, bl.prototype.translateDir = function(a, b) { | |
if (a === t.Left || a === t.Right) return a.opposite; | |
return a | |
}, bl.prototype.getLight = function() { | |
return this.lightPoint | |
}, bm.prototype.getCamera = function() { | |
return this | |
}, bm.prototype.moveUpdate = function(a) { | |
if (a === cG) { | |
var c = a.curStepFrac; | |
b.linearMix(cF.model.vtx[a.point], cF.model.vtx[a.last.point], c, this.eye), b.linearMix(a.forward, a.last.forward, c, this.t), b.scale(this.t, slideval1), b.add(this.t, this.eye, this.toPoint), b.linearMix(a.normal, a.last.normal, c, this.upDir), b.scale(this.upDir, .1, this.t), b.add(this.eye, this.t) | |
} | |
}, bm.prototype.translateDir = function(a, b) { | |
if (a === t.Left) return b.eDir.leftHand; | |
if (a === t.Right) return b.eDir.rightHand; | |
a !== t.Up; | |
return b.eDir | |
}, bm.prototype.getLight = function() { | |
return this.lightPoint | |
}; | |
var bn = Math.round; | |
bo.prototype.inside = function(a) { | |
return a.x >= this.x && a.y >= this.y && a.x <= this.x + this.width && a.y <= this.y + this.height | |
}, bo.prototype.expand = function(a) { | |
this.x -= a, this.y -= a, this.height += 2 * a, this.width += 2 * a; | |
return this | |
}, bo.prototype.expanded = function(a) { | |
return new bo(this.x - a, this.y - a, this.width + 2 * a, this.height + 2 * a) | |
}, bo.prototype.down = function(a) { | |
this.y += a; | |
return this | |
}, bo.prototype.xmid = function() { | |
return this.x + bn(this.width / 2) | |
}, bu.prototype.setup2dInputs = function() { | |
document.onkeydown = bs, document.onkeyup = bt, cK.onmousedown = bq, cJ.onmousedown = bq, document.onmouseup = br, document.onmousemove = bp | |
}, bu.prototype.getCanvasCoord = function(a) { | |
return { | |
x: a.layerX, | |
y: a.layerY | |
} | |
}, bu.prototype.getWidget = function(a) { | |
var b = this.getCanvasCoord(a); | |
for (var c = 0; c < this.curPage.widgets.length; ++c) { | |
var d = this.curPage.widgets[c]; | |
if (d.box.inside(b)) return d | |
} | |
return null | |
}, bu.prototype.roundedBoxPath = function(a, b, c, d, e) { | |
cL.beginPath(), cL.moveTo(a + e, b), cL.arcTo(a + c, b, a + c, b + e, e), cL.arcTo(a + c, b + d, a + c - e, b + d, e), cL.arcTo(a, b + d, a, b + d - e, e), cL.arcTo(a, b, a + e, b, e) | |
}, bu.prototype.backgroundRect = function(a) { | |
cL.clearRect(a.x, a.y, a.width, a.height), this.widgetsBackground !== undefined && (cL.fillStyle = this.widgetsBackground, cL.fillRect(a.x, a.y, a.width, a.height)) | |
}, bu.prototype.drawSelect = function(a, b) { | |
if (b) { | |
var c = Math.max(a.width, a.height), | |
d = cL.createLinearGradient(a.x, a.y, a.x + c / 2, a.y + c / 2); | |
d.addColorStop(0, "rgba(136,255,19,1.0)"), d.addColorStop(1, "rgba(255,255,0,1.0)"), cL.fillStyle = d, cN.roundedBoxPath(a.x, a.y, a.width, a.height, 10), cL.fillStyle = "black", cL.fill(), cL.fillStyle = d, cL.fill() | |
} else this.backgroundRect(a) | |
}, bw.prototype.draw = function(a) { | |
cN.drawSelect(this.box, a), this.group && this.group.testndraw(), cL.fillStyle = "#ff8464"; | |
var b = cL.textAlign == "center" ? this.box.x + bn(.5 * this.box.width) : this.tx; | |
cL.fillText(this.text, b, this.ty), cL.lineWidth = 2, cL.strokeStyle = "#c90034", cL.strokeText(this.text, b, this.ty) | |
}, bx.prototype.draw = function(a) { | |
cN.drawSelect(this.box, a); | |
var b = this.isOn ? this.imgOn : this.imgOff; | |
cL.drawImage(b, this.boxImg.x, this.boxImg.y, this.boxImg.width, this.boxImg.height) | |
}, bu.prototype.blankScr = function(a) { | |
a ? (cL.fillStyle = a, cL.fillRect(0, 0, cL.canvas.width, cL.canvas.height)) : cL.clearRect(0, 0, cL.canvas.width, cL.canvas.height) | |
}, bz.prototype.setBox = function(a) { | |
this.box = a | |
}, bz.prototype.testndraw = function() { | |
this.com.sel === this.id && (cN.roundedBoxPath(this.box.x, this.box.y, this.box.width, this.box.height, 10), cL.lineWidth = 2, cL.fillStyle = "rgba(0,0,255,0.2)", cL.fill(), cL.strokeStyle = "#0000FF", cL.stroke()) | |
}, bA.prototype.draw = function(a) { | |
cN.drawSelect(this.box, a), this.group && this.group.testndraw(), cL.drawImage(this.img, this.boxImg.x, this.boxImg.y, this.boxImg.width, this.boxImg.height) | |
}, bu.prototype.clearScr = function() { | |
this.curPage = {}, this.curPage.widgets = [], this.curPage.sel = 0, this.curPage.background = undefined, this.curPage.keyHandler = null, this.curPage.mouseHandler = null, this.curPage.selTextBox = null, this.blankScr(), this.curMenuDraw = null, this.curMenuRemake = null | |
}, bu.prototype.setSelectionTextBox = function(a) { | |
var b = a.height; | |
this.curPage.selTextBox = a.expanded(bn(a.height / 4)), this.curPage.selTextBox.th = b | |
}, bu.prototype.makeTextButton = function(a, b, c, d, e, f, g) { | |
var h = cL.measureText(a); | |
this.curPage.widgets.push(new bw(a, new bo(b, c, e, d), new bv(f, this.curPage.widgets.length), g)) | |
}, bu.prototype.makeImgToggleButton = function(a, b, c, d, e, f, g, h, i) { | |
this.curPage.widgets.push(new bx(a, b, c, d, new bo(e, f, h, g), new bv(i, this.curPage.widgets.length))) | |
}, bu.prototype.makeImgButton = function(a, b, c, d, e, f, g, h) { | |
this.curPage.widgets.push(new bA(a, b, new bo(c, d, f, e), new bv(g, this.curPage.widgets.length), h)) | |
}, bu.prototype.drawWidgets = function() { | |
if (this.curPage.widgets.length !== 0) { | |
for (var a = 0; a < this.curPage.widgets.length; ++a) { | |
var b = this.curPage.widgets[a]; | |
b.draw(a === this.curPage.sel) | |
} | |
var c = this.curPage.widgets[this.curPage.sel].text; | |
this.curPage.selTextBox && c && (this.backgroundRect(this.curPage.selTextBox), cL.fillStyle = "#ff3c00", cL.textAlign = "center", this.setMenuFont(this.curPage.selTextBox.th), cL.fillText(c, this.curPage.selTextBox.xmid(), this.curPage.selTextBox.y + this.curPage.selTextBox.th), cL.textAlign = "start") | |
} | |
}; | |
var bB = "rgba(0, 0, 0, 0.8)", | |
bC = "rgba(128, 128, 128, 0.7)"; | |
bu.prototype.preMenu = function(a) { | |
this.setup2dInputs(), this.clearScr(), this.widgetsBackground = a; | |
var b = arguments.callee.caller, | |
c = b.arguments; | |
this.curMenuRemake = function() { | |
b.apply(this, c) | |
} | |
}, bu.prototype.setMenuFont = function(a) { | |
a || (a = this.texth), cL.font = "bold " + bn(a) + "px sans-serif" | |
}, bu.prototype.resizeAdjust = function(a, b) { | |
this.texth = bn(42 * (a / 900)), this.setMenuFont(), this.em = cL.measureText("m").width, this.en = cL.measureText("n").width, cm("text height: " + this.texth + " em: " + this.em + " " + this.en), this.drawGameState(!0), this.curMenuRemake && this.curMenuRemake() | |
}, bu.prototype.showStartScreen = function() { | |
cj(0, bL.preloadFirst, null), cO(!1), this.preMenu("black"); | |
var a = cL.canvas.width, | |
b = cL.canvas.height, | |
c = bn(a / 2), | |
d = bn(b / 2), | |
e = this.texth, | |
f = this.em; | |
this.setMenuFont(); | |
var g = 8 * f; | |
this.makeTextButton("New game", 20, b - 6 * e, e, g, function() { | |
cm("NewNew!"), cN.clearScr(), cN.mainMenu = bu.prototype.showStartScreen, ce(function() { | |
bP() | |
}) | |
}), this.makeTextButton("How to play", 20, b - 4.3 * e, e, g, function() { | |
cN.instructionsScreen() | |
}), this.makeTextButton("Custom level", 20, b - 2.6 * e, e, g, function() { | |
cN.customLevelScreen() | |
}), this.makeImgToggleButton($("#soundOnImg")[0], $("#soundOffImg")[0], "Sound", bN.soundEnabled, a - 50 - 2 * f, b - 50 - 2 * f, 2.5 * f, 2.5 * f, function(a) { | |
cm("SetSnd " + a), bN.enableSound(a) | |
}), this.blankScr("black"); | |
var h = $("#titleTextImg")[0]; | |
cL.drawImage(h, 0, 0, a, bn(h.height / h.width * a)), this.drawVersionNum(), bL.debug && (this.curPage.keyHandler = function(a) { | |
if (a >= G.DOM_VK_F1 && a <= G.DOM_VK_F12) { | |
var b = a - G.DOM_VK_F1; | |
cj(b, bL.preloadFirst, null), cm("NewNew! " + b), cN.clearScr(), cN.mainMenu = bu.prototype.showStartScreen, ce(function() { | |
bP(b) | |
}); | |
return !1 | |
} | |
return !0 | |
}), this.drawWidgets() | |
}, bu.prototype.drawVersionNum = function() { | |
cL.textAlign = "right", cL.fillStyle = "#333", cL.font = "10px sans-serif", cL.fillText(bL.version, cL.canvas.width, 10), this.setMenuFont(), cL.textAlign = "start" | |
}, bu.prototype.drawHoverBox = function(a, b, c, d) { | |
cL.fillStyle = bB, cL.strokeStyle = bC, cL.lineWidth = 5, this.roundedBoxPath(bn(a), bn(b), bn(c), bn(d), 20), cL.fill(), cL.stroke() | |
}, bu.prototype.levelComplete = function(a, b) { | |
this.preMenu(bB); | |
var c = bn(cL.canvas.width / 2), | |
d = bn(cL.canvas.height / 2), | |
e = this.en, | |
f = this.texth, | |
g = bn(f / 2); | |
this.makeImgButton($("#againImg")[0], "This one again", c - 7 * e, d, 4 * e, 4 * e, function() { | |
cN.clearScr(), bI(b) | |
}), this.makeImgButton($("#menuImg")[0], "Exit game", c - 2 * e, d, 4 * e, 4 * e, function() { | |
cN.showStartScreen() | |
}), this.makeImgButton( | |
$("#nextImg")[0], "Next level", c + 3 * e, d, 4 * e, 4 * e, function() { | |
cN.clearScr(); | |
b === bK.length - 1 ? this.showStartScreen() : a !== -1 ? cj(a + 1, bL.preloadBatch, function() { | |
bI(a + 1) | |
}) : cN.customLevelScreen() | |
}), this.curPage.sel = 2, this.setSelectionTextBox(new bo(c - 6 * e, d + 5 * e, 12 * e, .7 * f)), this.curMenuDraw = function() { | |
this.setMenuFont(), this.drawHoverBox(c - 9 * this.en, d - 2.5 * this.texth, 18 * this.en, 7 * f), cL.fillStyle = "#ff3c00", cL.textAlign = "center", cL.fillText("Level " + (a + 1) + " Completed!", c, d - this.texth), cL.textAlign = "start", this.drawWidgets() | |
}, this.drawGameState() | |
}, bu.prototype.lifeEndScreen = function(a, b) { | |
this.preMenu(bB); | |
var c = bn(cL.canvas.width / 2), | |
d = bn(cL.canvas.height / 2), | |
e = this.texth, | |
f = this.en; | |
this.makeImgButton($("#againImg")[0], "Try again", c - 5 * f, d, 4 * f, 4 * f, function() { | |
cN.clearScr(), bI(a) | |
}), this.makeImgButton($("#menuImg")[0], "Exit Game", c + 1 * f, d, 4 * f, 4 * f, function() { | |
cN.mainMenu() | |
}), this.setSelectionTextBox(new bo(c - 6 * f, d + 5 * f, 12 * f, .7 * e)), this.curMenuDraw = function() { | |
this.setMenuFont(), this.drawHoverBox(c - 7 * f, d - 2.5 * e, 14 * f, 6.5 * e), cL.fillStyle = "#ff3c00", cL.textAlign = "center", cL.fillText("You crashed!", c, d - 40), cL.textAlign = "start", this.drawWidgets() | |
}, this.drawGameState() | |
}, bu.prototype.gameOverScreen = function(a, b) { | |
this.preMenu(bB); | |
var c = bn(cL.canvas.width / 2), | |
d = bn(cL.canvas.height / 2), | |
e = this.texth, | |
f = this.en; | |
this.makeImgButton($("#menuImg")[0], "Back to menu", c - 2 * f, d, 4 * f, 4 * f, function() { | |
cN.mainMenu() | |
}), this.setSelectionTextBox(new bo(c - 6 * f, d + 5 * f, 12 * f, .7 * e)), this.curMenuDraw = function() { | |
this.setMenuFont(), this.drawHoverBox(c - 7 * this.en, d - 2.5 * e, 14 * f, 6.5 * e), cL.fillStyle = "#ff3c00", cL.textAlign = "center", cL.fillText("Game Over!", c, d - this.texth), cL.textAlign = "start", this.drawWidgets() | |
}, this.drawGameState() | |
}, bu.prototype.verbosePauseScreen = function() { | |
function f() { | |
cN.clearScr(), cN.drawGameState(), bO(), bN.setPaused(!1) | |
} | |
this.preMenu( | |
bB); | |
var a = bn(cL.canvas.width / 2), | |
b = bn(cL.canvas.height / 2), | |
c = this.en, | |
d = this.em, | |
e = this.texth; | |
this.makeImgButton($("#resumeImg")[0], "Resume", a - 7 * c, b, 4 * c, 4 * c, function() { | |
f() | |
}), this.makeImgButton($("#menuImg")[0], "End game", a - 2 * c, b, 4 * c, 4 * c, function() { | |
cN.mainMenu() | |
}), this.makeImgToggleButton($("#soundOnImg")[0], $("#soundOffImg")[0], "Sound", bN.soundEnabled, a + 3 * c, b, 4 * c, 4 * c, function(a) { | |
cm("SetSnd " + a), bN.enableSound(a) | |
}), this.setSelectionTextBox(new bo(a - 6 * c, b + 5 * c, 12 * c, .7 * e)), this.curMenuDraw = function() { | |
this.setMenuFont(), this.drawHoverBox(a - 8 * c, b - 2.2 * e, 16 * c, 6.5 * e), cL.fillStyle = "#ff3c00", cL.textAlign = "center", cL.fillText("Paused", a, b - e), cL.textAlign = "start", this.drawWidgets(bB) | |
}, this.curPage.keyHandler = function(a) { | |
if (a === G.DOM_VK_ESCAPE) { | |
f(); | |
return !1 | |
} | |
return !0 | |
}, this.drawGameState() | |
}, bu.prototype.loadingScreen = function(a) { | |
this.blankScr("black"), this.setup2dInputs(), cO(!1); | |
var b = bn(cL.canvas.width / 2), | |
c = bn(cL.canvas.height / 2); | |
this.setMenuFont(), cL.fillStyle = "#ff3c00", cL.textAlign = "center", cL.fillText("Loading... ", b, c), cL.textAlign = "start" | |
}, bu.prototype.instructionsScreen = function() { | |
this.preMenu(); | |
var a = cL.canvas.width, | |
b = cL.canvas.height, | |
c = bn(a / 2), | |
d = bn(b / 2), | |
e = this.texth, | |
f = this.em, | |
g = this.en, | |
h = $("#instructImg")[0]; | |
cL.drawImage(h, 0, 0, a, bn(h.height / h.width * a)); | |
var i = $("#instructHeader")[0], | |
j = bn(678 / h.width * a); | |
cL.drawImage(i, c - bn(j / 2), 0, j, bn(i.height / i.width * j)), this.curPage.keyHandler = this.curPage.mouseHandler = function() { | |
cN.end3dAbove(), cN.showStartScreen(); | |
return !1 | |
}; | |
var k = bn(e * 1.5); | |
this.render3d = [new bD(new bo(1.2 * g, b * .18, k, k)), new bE(new bo(c - 2.5 * g, b * .19, 2 * k, k)), new bF(new bo(c - 2.5 * g, b * .07, 2 * k, k))], this.start3dAbove() | |
}, bu.prototype.customLevelScreen = function() { | |
this.preMenu("black"), cO(!1); | |
var a = cL.canvas.width, | |
b = cL.canvas.height, | |
c = bn(a / 2), | |
d = bn(b / 2), | |
e = this.texth, | |
f = this.em, | |
g = this.en, | |
h = bn(a / 6), | |
i = bn(h * .8), | |
j = { | |
worldSel: new by(0), | |
numPlayersSel: new by(2), | |
aiSel: new by(1) | |
}; | |
for (var k = 0; k < bK.length; ++k) { | |
var l = new Image; | |
l.src = bK[k].icon, l.onload = function() { | |
cN.drawWidgets() | |
}, this.makeImgButton(l, "", f + h * (k % 5), e * 1.2 + h * Math.floor(k / 5), i, i, function(a) { | |
return function() { | |
j.worldSel.sel = a, cN.drawWidgets() | |
} | |
}(k), new bz(j.worldSel, k)) | |
} | |
this.blankScr("black"), cL.fillStyle = "#ff3c00", cN.setMenuFont(e * .7), cL.fillText("Select World:", g, bn(e * .7)); | |
var m = h * 2 + 1.4 * e; | |
cL.fillText("Number of Players:", g, m); | |
for (var k = 1; k <= 6; ++k) this.makeTextButton(k, k * f * 2, m + .3 * e, e, g, function(a) { | |
return function() { | |
j.numPlayersSel.sel = a, cN.drawWidgets() | |
} | |
}(k), new bz(j.numPlayersSel, k)); | |
var n = h * 2 + 4 * e; | |
cL.fillText("Difficulty:", g, n); | |
var o = [{ | |
txt: "easy", | |
d: 1 | |
}, { | |
txt: "medium", | |
d: 3 | |
}, { | |
txt: "hard", | |
d: 5 | |
}], | |
p = 2 * f; | |
for (var k = 0; k < o.length; ++k) { | |
var q = o[k], | |
r = g * (q.txt.length + 1); | |
this.makeTextButton(q.txt, p, n + .3 * e, e, r, function(a) { | |
return function() { | |
j.aiSel.sel = a, cN.drawWidgets() | |
} | |
}(k), new bz(j.aiSel, k)), p += r + g | |
} | |
this.makeImgButton($("#menuImg")[0], "Exit game", a - 5 * g, b - 10 * g, 4 * g, 4 * g, function() { | |
cN.showStartScreen() | |
}), this.makeImgButton($("#nextImg")[0], "Next level", a - 5 * g, b - 5 * g, 4 * g, 4 * g, function() { | |
cN.clearScr(), worldLvl = j.worldSel.sel, cj(worldLvl, bL.preloadBatch, function() { | |
bN. | |
currentLevelNum = -1, bN.userLivesCount = 3, cN.mainMenu = bu.prototype.customLevelScreen, cL.textAlign = "start", bI({ | |
worldModel: bK[worldLvl].worldModel, | |
view: bK[worldLvl].view, | |
numPlayers: j.numPlayersSel.sel, | |
ai: o[j.aiSel.sel].d | |
}) | |
}) | |
}), this.curPage.keyHandler = function(a) { | |
if (a === G.DOM_VK_ESCAPE) { | |
cN.showStartScreen(); | |
return !1 | |
} | |
return !0 | |
}, cN.setMenuFont(e), cL.textAlign = "center", this.drawWidgets() | |
}, bD.prototype.draw = function() { | |
cC.viewport(this.box.x, this.box.y, this.box.width, this.box.height), o.load(d.ortho(-1, 1, 1, -1, .1, 100)), n.pushMatrix(), n.translate([0, 0, -10]), n.scale(.3), n.rotateX(this.anglex), n.rotateZ(this.angley), cE.setColorv(bj.prototype.getColor(this.anglex)), cq(cb.life), n.popMatrix() | |
}, bD.prototype.advance = function(a) { | |
bG.prototype.rotate.call(this, a) | |
}, bE.prototype.draw = function() { | |
cC.viewport(this.box.x, this.box.y, this.box.width, this.box.height); | |
var a = this.box.height / this.box.width; | |
o.load(d.ortho(-1, 1, a, -a, .1, 100)), n.pushMatrix(), n.translate([0, 0, -10]), n.scale(.3), n.rotateX(57), n.rotateZ(106), cq(cb.bike, u[bL.userIndex].model), n.popMatrix() | |
}, bF.prototype.draw = function() { | |
cC.viewport(this.box.x, this.box.y, this.box.width, this.box.height); | |
var a = this.box.height / this.box.width; | |
o.load(d.ortho(-1, 1, a, -a, .1, 100)); | |
for (var b = 0; b < this.colors.length + 1; ++b) n.pushMatrix(), n.translate([0, 0, -10]), n.rotateX(57), n.rotateZ(106), n.translate([0, -this.move * this.colors.length * 2 + b * 2, 0]), n.scale(.3), cq(cb.bike, this.colors[b % this.colors.length]), n.popMatrix() | |
}, bF.prototype.advance = function(a) { | |
this.move += a * 1e-4; | |
while (this.move > 1) this.move -= 1 | |
}, bu.prototype.draw3d = function(a) { | |
cC.clear(cC.COLOR_BUFFER_BIT | cC.DEPTH_BUFFER_BIT), n.loadIdentity(), ct(), cE.setTwoSided(!0); | |
for (var b in this.render3d) { | |
var c = this.render3d[b]; | |
c.advance && c.advance(a), c.draw() | |
} | |
}, bu.prototype.start3dAbove = function() { | |
this.has3dContent = !0, cJ.style.zIndex = 2, cC.clearColor(0, 0, 0, 0), cI = new bk | |
}, bu.prototype.end3dAbove = function() { | |
cN.render3d = [], cN.has3dContent = !1, cJ.style.zIndex = 0, cC.clearColor(0, 0, 0, 1), cC.clear(cC.COLOR_BUFFER_BIT | cC.DEPTH_BUFFER_BIT), cI = null | |
}, bu.prototype.drawColorText = function(a, b, c, d) { | |
var e = [], | |
f = a.match(/<([0-9]*|\/)>/g); | |
f === null && (f = []); | |
var g = 0; | |
for (var h = 0; h < f.length; ++h) { | |
var i = f[h]; | |
g = a.indexOf(i, g), a = a.slice(0, g) + a.slice(g + i.length), e.push({ | |
s: g, | |
n: parseInt(i.slice(1, -1)) | |
}) | |
} | |
var j = cL.measureText(a).width, | |
k = b - j, | |
g = 0, | |
l = cL.fillStyle; | |
for (var h = 0; h < e.length; h += 2) { | |
var m = e[h].s, | |
n = e[h + 1].s; | |
if (n !== m) { | |
var o = a.slice(g, m); | |
cL.fillStyle = l, cL.fillText(o, k, c), g += o.length, k += cL.measureText(o).width | |
} | |
o = a.slice(m, n), cL.fillStyle = d(e[h].n), cL.fillText(o, k, c), g += o.length, k += cL.measureText(o).width | |
} | |
var o = a.slice(g); | |
cL.fillStyle = l, cL.fillText(o, k, c) | |
}, bu.prototype.drawGameState = function(a) { | |
if (cM) { | |
this.blankScr(), cL.font = "bold " + bn(this.texth * .667) + "px sans-serif", cL.fillStyle = "#dda7ff", cL.fillText("Lives:", 5, this.texth); | |
if (this.msgQueue.length > 0) { | |
cL.font = "bold 18px sans-serif"; | |
var b = cL.canvas.width, | |
c = cL.canvas.height; | |
for (var d = 0; d < this.msgQueue.length; ++d) { | |
var e = this.msgQueue[d].text; | |
this.drawColorText(e, b - 5, 25 + 22 * d, function(a) { | |
return cH[a].textColor | |
}) | |
} | |
} | |
} | |
this.curMenuDraw && !a && this.curMenuDraw.call(this) | |
}, bu.MSGID_START_ARROWS = 1001, bu.prototype.addMessage = function(a, b) { | |
this.msgQueue.push({ | |
text: a, | |
outTime: (new Date).getTime() + 8e3, | |
id: b | |
}), this.drawGameState() | |
}, bu.prototype.removeMessage = function(a) { | |
var b = !1, | |
c = []; | |
for (var d in this.msgQueue) this.msgQueue[d].id === a ? b = !0 : c.push(this.msgQueue[d]); | |
b && (this.msgQueue = c, this.drawGameState()) | |
}, bu.prototype.checkMessageQueue = function() { | |
if (this.msgQueue.length !== 0 && !bN.isPaused()) { | |
var a = (new Date).getTime(), | |
b = 0; | |
while (this.msgQueue.length && this.msgQueue[0].outTime < a) this.msgQueue.shift(), ++b; | |
cM && b > 0 && this.drawGameState() | |
} | |
}, bu.prototype.clearMessages = function() { | |
this.msgQueue = [] | |
}, bG.prototype.render = function() { | |
that = this; | |
var a = function(a, b) { | |
n.pushMatrix(), n.translate([.172 + a * .068, .048, -1]), n.scale(.011 * b), n.rotateX(that.anglex + 20 * a), n.rotateZ(that.angley + 20 * a), cq(cb.life), n.popMatrix() | |
}; | |
o.pushMatrix(), o.load(this.prMatrix), cE.setColorv(this.color); | |
var c = 0; | |
for (; c < this.count; ++c) a(c, 1); | |
if (this.activeDeath !== undefined || this.activeOneUp !== undefined) { | |
cE.setColorv(b.x(this.color, this.lightFactor)); | |
var d = (this.lightFactor - 1) * .2 + 1; | |
a(c, d) | |
} | |
o.popMatrix() | |
}, bG.ROTX_SPEED = .09, bG.ROTY_SPEED = .18, bG.PASS_PEAK_LIGHT = 3, bG.PASS_PEAK_TIME = 1e3, bG.PASS_TOTAL_TIME = 2e3, bG.getLightFactor = function(a, b) { | |
if (a >= 0) { | |
if (a <= bG.PASS_PEAK_TIME) return 1 + bG.PASS_PEAK_LIGHT / bG.PASS_PEAK_TIME * a; | |
if (a <= bG.PASS_TOTAL_TIME) return bG.PASS_PEAK_LIGHT - bG.PASS_PEAK_LIGHT / (bG.PASS_TOTAL_TIME - bG.PASS_PEAK_TIME) * (a - bG.PASS_PEAK_TIME) | |
} | |
b(); | |
return 1 | |
}, bG.prototype.rotate = function(a) { | |
this.anglex += bG.ROTX_SPEED * a; | |
while (this.anglex > 360) this.anglex -= 360; | |
this.angley += bG.ROTY_SPEED * a; | |
while (this.angley > 360) this.angley -= 360 | |
}, bG.prototype.advance = function(a) { | |
this.rotate(a); | |
if (this.activeOneUp !== undefined) { | |
var b = this; | |
this.activeOneUp += a, this.lightFactor = bG.getLightFactor(bG. | |
PASS_TOTAL_TIME - this.activeOneUp, function() { | |
++b.count, b.activeOneUp = undefined, b.pendingDeath && (b.pendingDeath = !1, b.startDeath()) | |
}) | |
} else if (this.activeDeath !== undefined) { | |
var b = this; | |
this.activeDeath += a, this.lightFactor = bG.getLightFactor(this.activeDeath, function() { | |
b.activeDeath = undefined | |
}) | |
} | |
}, bG.prototype.startDeath = function() { | |
this.activeOneUp !== undefined ? this.pendingDeath = !0 : (--this.count, this.activeDeath = 0) | |
}, bG.prototype.startOneUp = function() { | |
this.activeOneUp = 0 | |
}; | |
var bH = 112; | |
worldModels = { | |
cube: { | |
file: "modelsz/cube5quads.jsonz", | |
eyeDist: 3.3 | |
}, | |
triCorner: { | |
file: "modelsz/triCorner4.jsonz", | |
eyeDist: 7 | |
}, | |
plus: { | |
file: "modelsz/plus4q.jsonz", | |
eyeDist: 7 | |
}, | |
dblsofa: { | |
file: "modelsz/dbl_sofa_soft_4q.jsonz", | |
eyeDist: 3.3 | |
}, | |
softsofa: { | |
file: "modelsz/sofa4q_soft.jsonz", | |
eyeDist: 3.54 | |
}, | |
dDiamond: { | |
file: "modelsz/distortDiamond5q.jsonz", | |
eyeDist: 4 | |
}, | |
torus: { | |
file: "modelsz/torus_100_50s.jsonz", | |
eyeDist: 3.66 | |
}, | |
tetra: { | |
file: "modelsz/tetra1_4q.jsonz", | |
eyeDist: 3.4 | |
}, | |
mobius: { | |
file: "modelsz/mobius_10r_3q.jsonz", | |
eyeDist: 1 | |
} | |
}; | |
var bJ = { | |
Outside: 0, | |
Inside: 1, | |
FirstPerson: 2 | |
}, | |
bK = [{ | |
worldModel: "cube", | |
numPlayers: 2, | |
ai: 1, | |
icon: "img/m_cube.png" | |
}, { | |
worldModel: "dblsofa", | |
numPlayers: 4, | |
ai: 1, | |
icon: "img/m_dbl_sofa.png" | |
}, { | |
worldModel: "tetra", | |
numPlayers: 3, | |
ai: 2, | |
icon: "img/m_tetra.png" | |
}, { | |
worldModel: "triCorner", | |
numPlayers: 4, | |
ai: 2, | |
icon: "img/m_triCorner.png" | |
}, { | |
worldModel: "dDiamond", | |
numPlayers: 4, | |
ai: 3, | |
icon: "img/m_diamond.png" | |
}, { | |
worldModel: "cube", | |
numPlayers: 3, | |
ai: 3, | |
view: bJ.Inside, | |
icon: "img/m_inside_cube.png" | |
}, { | |
worldModel: "plus", | |
numPlayers: 4, | |
ai: 4, | |
icon: "img/m_plus.png" | |
}, { | |
worldModel: "torus", | |
numPlayers: 3, | |
ai: 4, | |
icon: "img/m_torus.png" | |
}, { | |
worldModel: "softsofa", | |
numPlayers: 5, | |
ai: 5, | |
icon: "img/m_softsofa.png" | |
}, { | |
worldModel: "mobius", | |
numPlayers: 3, | |
ai: 5, | |
icon: "img/m_mobius.png" | |
}], | |
bL = { | |
userIndex: 0, | |
disableDeath: !1, | |
disableEndLevel: !1, | |
debug: !1, | |
printFps: !0, | |
preloadFirst: 1, | |
preloadBatch: 3, | |
version: "0.2." + bH | |
}, | |
bN = new | |
bM; | |
bM.prototype.setPaused = function(a) { | |
a ? ++this._paused : this._paused > 0 && --this._paused, this._startPause && this._paused === 0 && (this._startPause = !1, cN.removeMessage(bu.MSGID_START_ARROWS)), cy = (new Date).getTime(), cm("pause: " + this._paused) | |
}, bM.prototype.setAbsPaused = function(a) { | |
this._paused = a ? 1 : 0, cy = (new Date).getTime() | |
}, bM.prototype.isPaused = function() { | |
return this._paused > 0 | |
}, bM.prototype.enableSound = function(a) { | |
this.soundEnabled = a, $.cookie("enableSound", a, { | |
expires: 14 | |
}) | |
}; | |
var bQ = { | |
handler: null, | |
called: !1 | |
}; | |
bW.prototype.play = function(a) { | |
var b = this.players[this.curChannel]; | |
this.curChannel = (this.curChannel + 1) % this.numChannels, a !== b.volume && (b.volume = a), b.play() | |
}; | |
var bX = null, | |
cb = { | |
_ready: !1 | |
}, | |
cc = { | |
items: {}, | |
ondone: null, | |
onprogress: null | |
}; | |
if (!cm) var cm = function() {}, | |
cn = function() {}, | |
co = function() {}; | |
var cx = function() { | |
var a = 0, | |
b = 0; | |
return function(c) { | |
a += c, ++b, b > 10 && ($("#fpsui").text("FPS: " + Math.round(1e3 / (a / b))), a = 0, b = 0) | |
} | |
}(), | |
cy = 0, | |
cz = 0, | |
cC, cE = new q, | |
cF = { | |
map: [], | |
ready: !1 | |
}, | |
cG = null, | |
cH = [], | |
cI = null, | |
cJ, cK = null, | |
cL = null, | |
cM = !1, | |
cN = new bu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment