diff options
| author | Michele Bini <michele.bini@gmail.com> | 2014-10-05 21:53:10 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2014-10-05 21:53:10 (GMT) |
| commit | 2174455ae8a9e5fc346aaea62a9e2e18c5e969e9 (patch) | |
| tree | 033d89794ba7bbeff8b228abed0fb4c43519bfd5 | |
| parent | 02db0270e2ccd2e54f678dbd8d3f7af6875a81f9 (diff) | |
Updated the demo with swimming animation for main character; simplify key events handling in jaws code
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | attic/game-debug.html (renamed from game-debug.html) | 0 | ||||
| -rw-r--r-- | attic/game-debug.html.coffee (renamed from game-debug.html.coffee) | 14 | ||||
| -rw-r--r-- | game.html | 320 | ||||
| -rw-r--r-- | game.html.coffee | 299 | ||||
| -rw-r--r-- | jaws-assets-named.coffee | 456 | ||||
| -rwxr-xr-x[-rw-r--r--] | jaws/jaws-min.js | 4 | ||||
| -rwxr-xr-x[-rw-r--r--] | jaws/jaws.js | 209 | ||||
| -rwxr-xr-x | jaws/src/input.js | 207 |
10 files changed, 941 insertions, 579 deletions
diff --git a/.gitmodules b/.gitmodules index 7fb3f75..d4da416 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "htmlcup"] path = htmlcup url = ./htmlcup +[submodule "jaws"] + path = jaws + url = https://github.com/ippa/jaws.git diff --git a/README.md b/README.md new file mode 100644 index 0000000..58cd490 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +Vaquitas are the most endangered and smallest marine cetacean. + +The sources here include a web page and an ocean-themed game featuring Vaquita characters both compilable with CoffeeScript and htmlcup. + +The game is not playable yet but is a demo. + +Consult LICENSE and the individual files for copyright, licensing and autorship details. + diff --git a/game-debug.html b/attic/game-debug.html index 52935f8..52935f8 100644 --- a/game-debug.html +++ b/attic/game-debug.html diff --git a/game-debug.html.coffee b/attic/game-debug.html.coffee index e9645f5..3877da7 100644 --- a/game-debug.html.coffee +++ b/attic/game-debug.html.coffee @@ -1,18 +1,10 @@ # Copyright (c) 2013, 2014 Michele Bini -# This program is free software: you can redistribute it and/or modify -# it under the terms of the version 3 of the GNU General Public License -# as published by the Free Software Foundation. +# A game featuring a Vaquita, the smallest, most endagered marine cetacean -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. +# This program is available under the terms of the MIT License -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -version = "0.0.10" +version = "0.0.11" { htmlcup } = require 'htmlcup' @@ -1,5 +1,5 @@ <!DOCTYPE 5> -<html><head><meta charset="utf-8"><link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAIAEBAAAAEACABoBQAAJgAAACAgAAABABgAqAwAAI4FAAAoAAAAEAAAACAAAAABAAgAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAKCcrAHx1eACOipIAExUaAHGChAADAAAAMSAoAPfz8ADi4NwAeHqHAFZQUwABBgkAztHLAIB8ewC8t70A5uTfABoaIABcXFwA7OroAJagngDt7egAmKCeAExKSwCHhY0A3NrUAI+GhwChm6EAZWJlAH5zcwCNipMAPTpAACgnLABIW1oA9vLuAGlkYgBPVVoAU1FXABYVGwAUGBsA5ODdABYYGwArLDIARj1AAFZbWgAGCg0ABhANAB0eJADCwcEA2tnJAISJiADw7OYAY1tjAHd1cQChm6IAxsrKALa1uQB+eHoABQMCAF1MUgBBQ0EAqaGrABgaIgAxLyoAQkJHAFNcXgAaGiIAQ0NKAIV/fQC6xr8AvsHCAJiTnQBxanUAPVJTAB8hJQB0cW8Admp1AMLHwgB+aWkAiISMADg0OQB2bngAr7W6AGuKhAApJy4AUVJTAODi3ADe498AQTpCACoqLgB6eoEAGBgdAObj3wD79vMAlo+SAM7UzgC9vbcAgn57AODq6wAaHCAAgH+HAK+nowBcVVwACggJA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jKiIjKgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"><title>Vilma the Vaquita Demo</title><style type="text/css">body { +<html><head><meta charset="utf-8"><link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAIAEBAAAAEACABoBQAAJgAAACAgAAABABgAqAwAAI4FAAAoAAAAEAAAACAAAAABAAgAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAKCcrAHx1eACOipIAExUaAHGChAADAAAAMSAoAPfz8ADi4NwAeHqHAFZQUwABBgkAztHLAIB8ewC8t70A5uTfABoaIABcXFwA7OroAJagngDt7egAmKCeAExKSwCHhY0A3NrUAI+GhwChm6EAZWJlAH5zcwCNipMAPTpAACgnLABIW1oA9vLuAGlkYgBPVVoAU1FXABYVGwAUGBsA5ODdABYYGwArLDIARj1AAFZbWgAGCg0ABhANAB0eJADCwcEA2tnJAISJiADw7OYAY1tjAHd1cQChm6IAxsrKALa1uQB+eHoABQMCAF1MUgBBQ0EAqaGrABgaIgAxLyoAQkJHAFNcXgAaGiIAQ0NKAIV/fQC6xr8AvsHCAJiTnQBxanUAPVJTAB8hJQB0cW8Admp1AMLHwgB+aWkAiISMADg0OQB2bngAr7W6AGuKhAApJy4AUVJTAODi3ADe498AQTpCACoqLgB6eoEAGBgdAObj3wD79vMAlo+SAM7UzgC9vbcAgn57AODq6wAaHCAAgH+HAK+nowBcVVwACggJAH6GigAwMzcACAoPAPDo5QDw7OgAEQsSAPHt6wAfKSwAEhMYAHpzfwBlaGgAsb3BAAAEBwC+s7UA0NLJAFdUWgAoNTUACgQHAM7Y0gCRmJwAlpKcAHFtdwBvc3cANDQ7ACAhJwAiIScAkX9/ACYjGwB2cXEAYF1jAHdxcQB+mIsAt6+qAIyGiwD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title>Vilma the Vaquita</title><style type="text/css">body { /* background:pink; */ /* background: #69B2FF; */ /* background: #21AFF8; */ @@ -11,6 +11,7 @@ font-family: Helvetica; color:white; color:rgba(255,255,255,0.9); + margin:0; } .banner { border: 5px solid white; @@ -18,14 +19,16 @@ box-shadow: 0 2px 4px blue; margin: 1em; } -p { +footer, p { margin-top:0.418em; margin-bottom:0.418em; margin-left:auto; margin-right:auto; + text-shadow: 0 1px 1px blue; +} +p { width:22em; max-width:100%; - text-shadow: 0 1px 1px blue; } a { /* @@ -112,133 +115,194 @@ g.flipped { } .dim:hover { opacity: 1; -}</style></head><body><div class="centering page"><div class="centered"><svg id="sea-svgroot" width="960" height="720"><defs><linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"></stop><stop offset="25%" style="stop-color:rgb(100,200,250);stop-opacity:1"></stop><stop offset="50%" style="stop-color:rgb(0,80,240);stop-opacity:1"></stop><stop offset="75%" style="stop-color:rgb(0,0,180);stop-opacity:1"></stop><stop offset="100%" style="stop-color:rgb(0,0,0);stop-opacity:1"></stop></linearGradient><g id="_"><g transform="translate(-18,-15)"><image width="50" height="30" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAFWElEQVRYw+2WX0gcVxTGv7l3Zmd2drs6aHaNW7Jd88cYDaQYI1jsQ5GSh1BCAhUsNQ/JWxT6lLKExISCQkBECoW+6IMJEknaIEKQbKXJ5iFY6mKsEhOkk6qbRTe67szs7M7szvQhydKWhibEbQn1B/M2557z3e/ecy6wxRZbbLHFFv8hZ86ccYVCIe/rxkUiEXckEnFvVh3M6wZMTk7un56eHkkkEnsJIdA0DZRSuFwumKbZqSjKRHd399zL4sfHx9l4PL7TMIw5AGR4eLh0YmJi402FkFf9cXZ2tv7SpUv2zZs378fj8b2WZcE0TRDybAnTNKHr+tcOh2N2ZGTk4Iu4vr6+P22Wqqo1uVzuQSwWI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0jwh5LtcLsd7vd4Vl8uVraqqyhVlssuyLLa3t2vz8/M4f/48kskkDMMAx3EIBAJwOp3w+XyFbmOaJm7fvo2ysjJwHAfTNFFXVwdd139YXV39KhgMZgkhv3IcpzY3N2v/+hPl4sWL72ua1pvNZgcAlFNK4Xa76wghw5ZlCYqirFZWVpY8efLEcfLkybFIJAJVVV9M/4YTJ078UlFRkSnWm48pxqLhcHg/y7L3l5aWsLi4CAAIhUIMiggpxqItLS0zPp8PoiiC4zgYhoGBgQHurRMCADzPv7tv3z4cOnQI8Xh8ezgctt9KIVVVVctjY2PvpFKpMlmW12VZLqqQouP3+5m2tjbS1NREi5mHLbaQQCCA52683Y5s8X/ld5pkXmGj97LmAAAAAElFTkSuQmCC"></image></g></g><g id="_v105"><g transform="translate(-18,-15)"><image width="50" height="30" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAF0ElEQVRYw+2XW2xUxxnH/3M5N+9Z73p9ARuIuSSOGgJRUxq5fQCJqhFV0gZoX3qREkW0riwq1KRVkt5SVa2oRFFFhOzKJVLbpChFQoIXEh6gLhcnkQUFJ+kl0IawXmxTe3ftPXv2zOXM9CGkD30hKWylqv4/jmb+3/zm8n0zwKIWtahFLer/Vfmh8s5b9eC3cTIZAKgOFuofYsxaAFsBqP86yOeHRg+0T5//dFKt+I1MLyCqJJtpbxjvrWhKd48cB/bdzGNgYGBda2vrk2euHe/7e9sGRwTtr98qCPmgHZ98/tgTeuL496K44TACQghBbDyq6rMOZQ5aw4yklBpDV1Zp//YXh768+hkAuO/AO+0Xd6ya+9dC7H7p67kro7sCzvpmbUjGuz9zrty+/mh1sPDjpoN86ci1te6JX7zqcEYceZ0AgDEGjuNIpTStRTW/xfdTxrmVUnLmBoIzYqLgzmTatLavSK+eijKFsbJs+eodC+NtDqx3w1q/tnzbsWL+o2fW58XPKyJlF3esEu/H3fK76R9cuHBuw/Tuhz53W0Ae2XfiNx3Fc9s9MQUlY/R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S4lNXaJR9ZdRxwgbsZDk0IBXK5ngb39QK9ozGSF1OlNTyYXNP3McZq8vaP7N6mDhcDMenh8YJD9UXgagD8DdAKYAzAG4D8BmABUArwGYAPDOx9XE7hVvHHyUEUuFUiqJY33o0KGwmS9o0izjx3YMXHKpXW2sTRuNhrbrHnr14FNf/FSz4tFmGbsPP7W5o2spWoIWzjn3/Esn72/mjjQNZGTr6qJM4u/k2gqxkpJE0hxuJghrpvnY2NjZlb13XF6yZMnhJJr//cTExGSzYnE0WUEQnJ2enmZhGOrFT/2i/gf1T8lwuYI1cNwxAAAAAElFTkSuQmCC"></image></g></g><g id="twistleft"><g transform="translate(-18,-15)"><image width="50" height="30" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gkcCToKOZJRQQAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAVlSURBVFjD7ZddaBRXFMf/c2dnZndmv8Iuq812DQluUIhgqFGwpPRRqAVBUjDUqCj4oEIRFLYlJhI0IIQ07UNbKFrwI5BikRC0wTU0JhQJJRJ1S6MERyVhbbS7O7Ozs/N1pw+SQB8EtVlE2N/znHvu/5577v8MUKVKlSpVqrxFjh8/LqVSqdjrxExMTHgnJiZ8K7kP5nUDpqamNszMzAw9e/ZsHSEEmqaBZVlIkgTLso6oqjp2+vTpP18WPzo6yj5+/LgFADM4OJgZGxtTVkIIedUPM5nMB2fOnHGvXbt2J5vNrqOUwrIsEPJiCcuyoOv6tzzPZ4aGhjYtxfX39//nsIrFYp1hGOO2bd+oqamJvyxfe3s7MzAwEOzu7iYrVhFVVaW+vr6iKIrQdR0AYJomeJ6HYRh4/vw5QqEQvF4vdF0Hx3EQBAGSJP316NGj3bFYTPd6vWoul9u3Zs2anbZtb/D5fMhkMpuCwaDR3d19r6enJ9zZ2ZlfyvngwQNx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tbW1oaOHTt2/ejRo5/s379/JJ1OQ9d1uK4LQkjLnj177q1evbpciZmPqcSiIyMjreVy+ebDhw+hKApEUUQqlapIrteetV6HXC73eyAQgKIocBwHpmni7Nmz3DsnZPfu3U4ymXx/ya2z2ex76XTafeeEAEBDQ8O8KIqBlpaWiCzLOVmWKyqk4sTjcaa9vZ1s3bqVrWQettJCVFVFIBAAADeRSDBPnjyp/lZXeZf4F2oCbZ1+z182AAAAAElFTkSuQmCC"></image></g></g></defs><rect x="0" y="0" width="960" height="720" fill="url(#grad1)"></rect><g transform="scale(2)"><g id="sea" transform="translate(240,180)"><use xlink:href="#_"></use></g></g></svg><div class="dim"><span>Vilma the Vaquita Demo v0.0.12</span><span> - </span><a target="_blank" href="index.html">Learn about Vaquitas</a></div></div></div><script type="text/javascript">gameObjects=null;</script><script type="text/javascript">(function () { - var addVaquita, downKey, getTransformMatrix, k, keyDownActions, keydown, leftKey, pressedKeys, rightKey, screen_x1, screen_y1, sea, svgroot, upKey, usedKeys, v, vaquitaObj, vaquitas, _j, _len1; - svgroot = document.getElementById("sea-svgroot"); - screen_x1 = 240; - screen_y1 = 180; - vaquitas = []; - vaquitaObj = { - update: function(x, y) { - var rx, ry, s, vx, vy; - if (!window.abcd) { - window.abcd = 1; - } - vx = this.vx + Math.floor(Math.random() * 3) - 1; - vy = this.vy + Math.floor(Math.random() * 3) - 1; - x = this.x; - y = this.y; - rx = 0.5 * x / screen_x1; - ry = 0.5 * y / screen_y1; - if ((s = vx * vx + vy * vy * 2) > 6) { - vx = Math.round(vx * 0.9 + rx); - vy = Math.round(vy * 0.9 + ry); - } - this.x = x -= this.vx = vx; - this.y = y -= this.vy = vy; - if (vx > 0) { - this.scaleX = 1; - } else if (vx < 0) { - this.scaleX = -1; - } - return this.e.setAttribute("transform", "translate(" + x + ", " + y + ") scale(" + this.scaleX + ", 1)"); - } - }; - sea = document.getElementById("sea"); - v = sea.firstChild; - getTransformMatrix = function(el) { - var transformListXX, transformMatrixXX, transformXX; - transformListXX = el.transform.baseVal; - transformMatrixXX = svgroot.createSVGMatrix(); - transformXX = svgroot.createSVGTransform(); - transformXX.setMatrix(transformMatrixXX); - transformListXX.initialize(transformXX); - return transformXX.matrix; - }; - addVaquita = function() { - var angle, n, vaquita; - n = v.cloneNode(); - n.setAttribute("opacity", "0.5"); - if (Math.random(0) > 0.5) { - n.href.baseVal = "#_v105"; - } - sea.appendChild(n); - angle = Math.random() * 6.28; - vaquita = { - e: n, - x: Math.sin(angle) * 300, - y: Math.cos(angle) * 300, - vx: 0, - vy: 0, - scaleX: 1, - __proto__: vaquitaObj - }; - vaquita.update(); - return vaquitas.push(vaquita); - }; - leftKey = 37; - upKey = 38; - rightKey = 39; - downKey = 40; - usedKeys = [leftKey, upKey, rightKey, downKey]; - keyDownActions = { - 32: addVaquita - }; - pressedKeys = {}; - for (_j = 0, _len1 = usedKeys.length; _j < _len1; _j++) { - k = usedKeys[_j]; - pressedKeys[k] = 0; - } - keydown = function(event) { - var code; - code = event.keyCode; - if (typeof keyDownActions[code] === "function") { - keyDownActions[code](event); - } - return pressedKeys[code] = 1; - }; - keydown = function(event) { - return pressedKeys[event.keyCode] = 0; - }; - window.addEventListener('keydown', keydown, true); - window.addEventListener('keyup', keyup, true); - return (function(x, y) { - var ax, ay, currentFrame, gameFrame, scaleX, scaleY, time, vx, vy; - time = 0; - vx = 0; - vy = 0; - ax = 0; - ay = 0; - scaleX = 1; - scaleY = 1; - window.cf = currentFrame = v.href; - gameFrame = function() { - var vq, _k, _len2; - if ((time & 0xff) === 0x00 && vaquitas.length < 4) { - addVaquita(); - } - x -= vx = pressedKeys[leftKey] - pressedKeys[rightKey]; - y -= pressedKeys[upKey] - pressedKeys[downKey]; - if (vx > 0) { - scaleX = 1; - } else if (vx < 0) { - scaleX = -1; - } - v.setAttribute("transform", "translate(" + x + ", " + y + ") scale(" + scaleX + ", " + scaleY + ")"); - if ((time % 3) === 0) { - if (currentFrame.baseVal === "#twistleft") { - currentFrame.baseVal = "#_"; - } else if (vx !== 0) { - currentFrame.baseVal = "#twistleft"; +}</style></head><body><div class="centering page"><div class="centered"><div style="visibility:hidden;position:absolute"><img id="pixyvaquita" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAFWElEQVRYw+2WX0gcVxTGv7l3Zmd2drs6aHaNW7Jd88cYDaQYI1jsQ5GSh1BCAhUsNQ/JWxT6lLKExISCQkBECoW+6IMJEknaIEKQbKXJ5iFY6mKsEhOkk6qbRTe67szs7M7szvQhydKWhibEbQn1B/M2557z3e/ecy6wxRZbbLHFFv8hZ86ccYVCIe/rxkUiEXckEnFvVh3M6wZMTk7un56eHkkkEnsJIdA0DZRSuFwumKbZqSjKRHd399zL4sfHx9l4PL7TMIw5AGR4eLh0YmJi402FkFf9cXZ2tv7SpUv2zZs378fj8b2WZcE0TRDybAnTNKHr+tcOh2N2ZGTk4Iu4vr6+P22Wqqo1uVzuQSwWI4uLi5AkqfJlOdva2pj+/v7tFy5cIJviiKIort7eXlUURei6DgAwDAMOhwPZbBZPnz5FSUkJBEGAruvgOA48z8Plcj14/Pjx516vVxcEQVlZWflsx44d3clkEplMBrZtI5PJHPR4PFlK6dK5c+eSf8z76NGjytHR0eXa2tomlmUftLS0rL+RkBs3bhycn5//CQCSySSOHDkCv98Py7JAKYWu68hkMlhYWMDDhw8Rj8fhcrlg2zYMw/hZkiSNYRhKCPlAVdWCYJZlQSlFPp/v4jhOIYT8ePbs2WgikRB7enp2+ny++06nE36/v/7YsWNTb+RIOByWotHoGsuyiMViOH36NAAgn8+jo6MDtm2jv78fDMNA0zRYloV79+4hlUpBUZRnSRgGhmGgpKQEAGDbNhiGQT6fRz6fh2VZ4DgOlFIQQpDNZpFOpwEAHo8HlmXBtm2Iong1n89fDYVC3/+1TvYV7saHuVwO2WwW5eXlAACHw4HW1lbcuXMHPM/j1KlTGBoawp49exCNRtHc3AyPx4PBwUGkUinkcjmwLItkMlkQJkkSqqurwTAM5ubmkMlk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/+6wA4GpjrO+6VCmVlsvlNJPJhGEYIo7jxFqLVOtUKQUCwPN94rku8TyPBpmQ1uIkZY5PKl33Vg+be97MdPaKbMqOVW9X1vrCwLdn/3L25RwAXL58mXmeh5GRkTnf9xkAJEmSlkolTE5OuowxxjlvUEpDzjm6urpILYpsPYps3GgQSghhjJEw20pqUc36rstqUT013Mdo38DXyrV614LbdRBAC4BrH6a43nRH/hzcVbZ4JUdhsWfPnlJfX184Pz+PU6dP83K57FFKre/7yuGcMM4RRVFea80IIXZ2bi4JgoBls1nak88TISUcztm4XgEszf2xgyykE+0r2yad5aVEek8kbuaF6mCh1JTK7q5/8LumOv3c3MnnO4vFYtdf334bWmvOGTOu46RBEKSu57HWbJbm83lWq9XslStXUsdxaLlSQUuYheu6ODXraRWuTNo4P38xs/ZPMyh8qzpYkPmh8gFY3A/gBIBXml7ZH/jJy2O5hXfXVfyuwFUNS4lNXaJR9ZdRxwgbsZDk0IBXK5ngb39QK9ozGSF1OlNTyYXNP3McZq8vaP7N6mDhcDMenh8YJD9UXgagD8DdAKYAzAG4D8BmABUArwGYAPDOx9XE7hVvHHyUEUuFUiqJY33o0KGwmS9o0izjx3YMXHKpXW2sTRuNhrbrHnr14FNf/FSz4tFmGbsPP7W5o2spWoIWzjn3/Esn72/mjjQNZGTr6qJM4u/k2gqxkpJE0hxuJghrpvnY2NjZlb13XF6yZMnhJJr//cTExGSzYnE0WUEQnJ2enmZhGOrFT/2i/gf1T8lwuYI1cNwxAAAAAElFTkSuQmCC"><img id="pixyvaquita_twistleft" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAeCAYAAABuUU38AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gkcCToKOZJRQQAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAVlSURBVFjD7ZddaBRXFMf/c2dnZndmv8Iuq812DQluUIhgqFGwpPRRqAVBUjDU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mHnzp24cOECOjo6AACXL18GALAsC0opisUiisUitmzZAlVVMT09DY7jwLIsQqEQXNcFpRSCIIBlWViWBdM0oet6xnXdHy5duvTdxYsXaTwev7ZiPnLkyBF3dHQUACDLMjiOw927d8Fx3PKzOz8/j8nJyeXXrL6+Hi0tLSCEoFAogBACWZbhui4YhoHX6132H9M0QQj5WhCEr6ampqze3l6rIoa4bdu2L+bm5voZhsH58+dRV1cHXdcxPDyMXC4HURQRDoexceNGWJaF69evw3XdFw1ICNavX49YLAaWZaFp2rzH45EURblQU1MzSwj5xbZtIRaL/S1JUrmhocGpmLPLsix2dHRos7OzOHHiBPL5PEzTBMdxqKurg8/nw6pVq0AIWeqDvGVZ4fHxcUQiEXAcB8uy0NTUBE3TpoPBYKcgCOOtra3aWxlRTp482axpWp9hGGcBRFmWhd/vbyKEDFJKvaqqLtbW1oaOHTt2/ejRo5/s379/JJ1OQ9d1uK4LQkjLnj177q1evbpciZmPqcSiIyMjreVy+ebDhw+hKApEUUQqlapIrteetV6HXC73eyAQgKIocBwHpmni7Nmz3DsnZPfu3U4ymXx/ya2z2ex76XTafeeEAEBDQ8O8KIqBlpaWiCzLOVmWKyqk4sTjcaa9vZ1s3bqVrWQettJCVFVFIBAAADeRSDBPnjyp/lZXeZf4F2oCbZ1+z182AAAAAElFTkSuQmCC"></div><div style="position:relative"><svg id="sea-svgroot" width="960" height="720" style="position:absolute;opacity:0.9;z-index:-1000"><defs><linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:rgb(255,255,255);stop-opacity:1"></stop><stop offset="25%" style="stop-color:rgb(100,200,250);stop-opacity:1"></stop><stop offset="50%" style="stop-color:rgb(0,80,240);stop-opacity:1"></stop><stop offset="75%" style="stop-color:rgb(0,0,180);stop-opacity:1"></stop><stop offset="100%" style="stop-color:rgb(0,0,0);stop-opacity:1"></stop></linearGradient></defs><rect x="0" y="0" width="960" height="720" fill="url(#grad1)"></rect></svg><canvas width="960" height="720"></canvas></div><footer class="dim"><span>Vilma the Vaquita v0.1.54</span><span> - </span><a target="_blank" href="index.html">Learn about Vaquitas</a><span id="fps"></span></footer></div></div><script type="text/javascript">gameObjects=null;</script><script type="text/javascript">__hasProp = {}.hasOwnProperty; __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };</script><script type="text/javascript">var jaws=function(t){function e(e){t.mouse_x=e.pageX||e.clientX,t.mouse_y=e.pageY||e.clientY;var i=t.canvas?t.canvas:t.dom;t.mouse_x-=i.offsetLeft,t.mouse_y-=i.offsetTop}var i,s;return t.SpriteList=function(){throw"To use SpriteList() you need to include src/extras/sprite_list.js"},t.Audio=function(){throw"To use jaws.Audio() you need to include src/extras/audio.js"},t.title=function(e){return t.isString(e)?e?i.innerHTML=e:i.innerHTML:void t.log.error("jaws.title: Passed in value is not a String.")},t.unpack=function(){var e=["Sprite","SpriteList","Animation","SpriteSheet","Parallax","pressed","QuadTree"];e.forEach(function(e){window[e]?t.log.warn("jaws.unpack: "+e+" already exists in global namespace."):window[e]=t[e]})},t.log=function(e,i){t.isString(e)||(e=JSON.stringify(e)),t.log.on&&(s&&t.log.use_log_element&&(i?s.innerHTML+=e+"<br />":s.innerHTML=e),console.log&&t.log.use_console&&console.log("JawsJS: ",e))},t.log.on=!0,t.log.use_console=!1,t.log.use_log_element=!0,t.log.warn=function(e){console.warn&&t.log.use_console&&t.log.on?console.warn(e):t.log("[WARNING]: "+JSON.stringify(e),!0)},t.log.error=function(e){console.error&&t.log.use_console&&t.log.on?console.error(e):t.log("[ERROR]: "+JSON.stringify(e),!0)},t.log.info=function(e){console.info&&t.log.use_console&&t.log.on?console.info(e):t.log("[INFO]: "+JSON.stringify(e),!0)},t.log.debug=function(e){console.debug&&t.log.use_console&&t.log.on?console.debug(e):t.log("[DEBUG]: "+JSON.stringify(e),!0)},t.log.clear=function(){s&&(s.innerHTML=""),console.clear&&console.clear()},t.init=function(o){i=document.getElementsByTagName("title")[0],t.url_parameters=t.getUrlParameters(),t.canvas=document.getElementsByTagName("canvas")[0],t.canvas||(t.dom=document.getElementById("canvas")),t.canvas?t.context=t.canvas.getContext("2d"):t.dom?t.dom.style.position="relative":(t.canvas=document.createElement("canvas"),t.canvas.width=o.width,t.canvas.height=o.height,t.context=t.canvas.getContext("2d"),document.body.appendChild(t.canvas)),s=document.getElementById("jaws-log"),t.url_parameters.debug&&(s||(s=document.createElement("div"),s.id="jaws-log",s.style.cssText="overflow: auto; color: #aaaaaa; width: 300px; height: 150px; margin: 40px auto 0px auto; padding: 5px; border: #444444 1px solid; clear: both; font: 10px verdana; text-align: left;",document.body.appendChild(s))),t.url_parameters.bust_cache&&(t.log.info("Busting cache when loading assets"),t.assets.bust_cache=!0),t.context&&t.useCrispScaling(),t.width=t.canvas?t.canvas.width:t.dom.offsetWidth,t.height=t.canvas?t.canvas.height:t.dom.offsetHeight,t.mouse_x=0,t.mouse_y=0,window.addEventListener("mousemove",e)},t.useCrispScaling=function(){t.context.imageSmoothingEnabled=!1,t.context.webkitImageSmoothingEnabled=!1,t.context.mozImageSmoothingEnabled=!1},t.useSmoothScaling=function(){t.context.imageSmoothingEnabled=!0,t.context.webkitImageSmoothingEnabled=!0,t.context.mozImageSmoothingEnabled=!0},t.start=function(e,i,s){function o(e,s){t.log.info(s+"%: "+e,!0),i.loading_screen&&t.assets.displayProgress(s)}function n(e,i){t.log.info(i+"%: Error loading asset "+e,!0)}function a(){t.log.info("all assets loaded",!0),t.switchGameState(e||window,{fps:r},s)}i||(i={});var r=i.fps||60;return void 0===i.loading_screen&&(i.loading_screen=!0),i.width||(i.width=500),i.height||(i.height=300),t.init(i),t.isFunction(e)||t.isObject(e)?t.isObject(s)||void 0===s?(i.loading_screen&&t.assets.displayProgress(0),t.log.info("setupInput()",!0),t.setupInput(),t.log.info("assets.loadAll()",!0),void(t.assets.length()>0?t.assets.loadAll({onprogress:o,onerror:n,onload:a}):a())):void t.log.error("jaws.start: The setup options for the game state is not an object."):void t.log.error("jaws.start: Passed in GameState is niether function or object")},t.switchGameState=function(e,i,s){if(void 0===i&&(i={}),t.isFunction(e)&&(e=new e),!t.isObject(e))return void t.log.error("jaws.switchGameState: Passed in GameState should be a Function or an Object.");var o=i&&i.fps||t.game_loop&&t.game_loop.fps||60,n=i.setup;t.game_loop&&t.game_loop.stop(),t.clearKeyCallbacks(),t.previous_game_state=t.game_state,t.game_state=e,t.game_loop=new t.GameLoop(e,{fps:o,setup:n},s),t.game_loop.start()},t.imageToCanvas=function(e){if(t.isCanvas(e))return e;if(!t.isImage(e))return void t.log.error("jaws.imageToCanvas: Passed in object is not an Image.");var i=document.createElement("canvas");i.src=e.src,i.width=e.width,i.height=e.height;var s=i.getContext("2d");return s.drawImage(e,0,0,e.width,e.height),i},t.forceArray=function(t){return Array.isArray(t)?t:[t]},t.clear=function(){t.context.clearRect(0,0,t.width,t.height)},t.fill=function(e){t.context.fillStyle=e,t.context.fillRect(0,0,t.width,t.height)},t.draw=function(){var e=arguments;1==e.length&&t.isArray(e[0])&&(e=e[0]);for(var i=0;i<e.length;i++)t.isArray(e[i])?t.draw(e[i]):e[i].draw&&e[i].draw()},t.update=function(){var e=arguments;1==e.length&&t.isArray(e[0])&&(e=e[0]);for(var i=0;i<e.length;i++)t.isArray(e[i])?t.update(e[i]):e[i].update&&e[i].update()},t.isImage=function(t){return"[object HTMLImageElement]"===Object.prototype.toString.call(t)},t.isCanvas=function(t){return"[object HTMLCanvasElement]"===Object.prototype.toString.call(t)},t.isDrawable=function(e){return t.isImage(e)||t.isCanvas(e)},t.isString=function(t){return"string"==typeof t||"object"==typeof t&&t.constructor===String},t.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},t.isArray=function(t){return t?!(-1===t.constructor.toString().indexOf("Array")):!1},t.isObject=function(t){return null!==t&&"object"==typeof t},t.isFunction=function(t){return"[object Function]"===Object.prototype.toString.call(t)},t.isRegExp=function(t){return t instanceof RegExp},t.isOutsideCanvas=function(e){return e.x&&e.y?e.x<0||e.y<0||e.x>t.width||e.y>t.height:void 0},t.forceInsideCanvas=function(e){e.x&&e.y&&(e.x<0&&(e.x=0),e.x>t.width&&(e.x=t.width),e.y<0&&(e.y=0),e.y>t.height&&(e.y=t.height))},t.getUrlParameters=function(){for(var t,e=[],i=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),s=0;s<i.length;s++)t=i[s].split("="),e.push(t[0]),e[t[0]]=t[1];return e},t.parseOptions=function(e,i,s){e.options=i;for(var o in i)void 0===s[o]&&t.log.warn("jaws.parseOptions: Unsupported property "+o+"for "+e.constructor);for(var o in s)t.isFunction(s[o])&&(s[o]=s[o]()),e[o]=void 0!==i[o]?i[o]:t.clone(s[o])},t.clone=function(e){return t.isArray(e)?e.slice(0):t.isObject(e)?JSON.parse(JSON.stringify(e)):e},t.imageToCanvasContext=function(e){var i=document.createElement("canvas");i.width=e.width,i.height=e.height;var s=i.getContext("2d");return t.context&&(s.imageSmoothingEnabled=t.context.mozImageSmoothingEnabled,s.webkitImageSmoothingEnabled=t.context.mozImageSmoothingEnabled,s.mozImageSmoothingEnabled=t.context.mozImageSmoothingEnabled),s.drawImage(e,0,0,i.width,i.height),s},t.retroScaleImage=function(e,i){var s=t.isImage(e)?t.imageToCanvas(e):e,o=s.getContext("2d"),n=o.getImageData(0,0,s.width,s.height).data,a=document.createElement("canvas");a.width=e.width*i,a.height=e.height*i;for(var r=a.getContext("2d"),h=r.createImageData(a.width,a.height),c=h.width,l=h.height,u=0;l>u;u+=1)for(var d=Math.floor(u/i),f=u*h.width,p=d*e.width,g=0;c>g;g+=1){var m=Math.floor(g/i),w=4*(f+g),x=4*(p+m);h.data[w]=n[x],h.data[w+1]=n[x+1],h.data[w+2]=n[x+2],h.data[w+3]=n[x+3]}return r.putImageData(h,0,0),a},t}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws);var jaws=function(t){function e(){for(var t in h)delete h[t]}function i(t){var e=e=t.keyCode;h[e]=!1,d[e]?(d[e](e),t.preventDefault()):g[e]&&t.preventDefault()}function s(t){var e=e=t.keyCode;h[e]=!0,u[e]?(u[e](e),t.preventDefault()):g[e]&&t.preventDefault()}function o(t){var e=f[t.button];"Microsoft Internet Explorer"==navigator.appName&&(e=p[t.button]),h[e]=!0,u[e]&&(u[e](e),t.preventDefault())}function n(t){var e=f[t.button];"Microsoft Internet Explorer"==navigator.appName&&(e=p[t.button]),h[e]=!1,d[e]&&(d[e](e),t.preventDefault())}function a(e){h.left_mouse_button=!0,t.mouse_x=e.touches[0].pageX-t.canvas.offsetLeft,t.mouse_y=e.touches[0].pageY-t.canvas.offsetTop}function r(){h.left_mouse_button=!1,t.mouse_x=void 0,t.mouse_y=void 0}var h={},c={0:"48",1:"49",2:"50",3:"51",4:"52",5:"53",6:"54",7:"55",8:"56",9:"57",backspace:"8",tab:"9",enter:"13",shift:"16",ctrl:"17",alt:"18",pause:"19",caps_lock:"20",esc:"27",space:"32",page_up:"33",page_down:"34",end:"35",home:"36",left:"37",up:"38",right:"39",down:"40",insert:"45","delete":"46",a:"65",b:"66",c:"67",d:"68",e:"69",f:"70",g:"71",h:"72",i:"73",j:"74",k:"75",l:"76",m:"77",n:"78",o:"79",p:"80",q:"81",r:"82",s:"83",t:"84",u:"85",v:"86",w:"87",x:"88",y:"89",z:"90",windows_left:"91",windows_right:"92",select:"93",numpad0:"96",numpad1:"97",numpad2:"98",numpad3:"99",numpad4:"100",numpad5:"101",numpad6:"102",numpad7:"103",numpad8:"104",numpad9:"105",asterisk:"106",plus:"107",minus:"109",decimal_point:"110",divide:"111",f1:"112",f2:"113",f3:"114",f4:"115",f5:"116",f6:"117",f7:"118",f8:"119",f9:"120",numlock:"144",scrollock:"145",semicolon:"186",equals:"187",comma:"188",dash:"189",period:"190",slash:"191",grave_accent:"192",open_bracket:"219",backslash:"220",close_bracket:"221",single_quote:"222"},l={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"caps_lock",27:"esc",32:"space",33:"page_up",34:"page_down",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"windows_left",92:"windows_right",93:"select",96:"numpad0",97:"numpad1",98:"numpad2",99:"numpad3",100:"numpad4",101:"numpad5",102:"numpad6",103:"numpad7",104:"numpad8",105:"numpad9",106:"asterisk",107:"plus",109:"minus",110:"decimal_point",111:"divide",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",144:"numlock",145:"scrollock",186:"semicolon",187:"equals",188:"comma",189:"dash",190:"period",191:"slash",192:"grave_accent",219:"open_bracket",220:"backslash",221:"close_bracket",222:"single_quote"},u=[],d=[],f=[],p=[],g=[];return t.setupInput=function(){var h=[];h[0]="left_mouse_button",h[1]="center_mouse_button",h[2]="right_mouse_button";var c=[];c[1]="left_mouse_button",c[2]="right_mouse_button",c[4]="center_mouse_button",f=h,p=c,window.addEventListener("keydown",s),window.addEventListener("keyup",i);var l=t.canvas||t.dom;l.addEventListener("mousedown",o,!1),l.addEventListener("mouseup",n,!1),l.addEventListener("touchstart",a,!1),l.addEventListener("touchend",r,!1),window.addEventListener("blur",e,!1),document.oncontextmenu=function(){return!1}},t.preventDefaultKeys=function(){for(var t=arguments,e=0;e<t.length;e++)g[t[e]]=!0},t.pressed=h,t.keyCodes=c,t.keycodeNames=l,t.on_keydown=function(e,i){if(t.isArray(e))for(var s=0;e[s];s++)u[e[s]]=i;else u[e]=i},t.on_keyup=function(e,i){if(t.isArray(e))for(var s=0;e[s];s++)d[e[s]]=i;else d[e]=i},t.clearKeyCallbacks=function(){d=[],u=[]},t}(jaws||{}),jaws=function(t){function e(e){if(t.isDrawable(e)){for(var i=t.isImage(e)?t.imageToCanvas(e):e,s=i.getContext("2d"),o=s.getImageData(0,0,i.width,i.height),n=o.data,a=0;a<n.length;a+=4)255===n[a]&&0===n[a+1]&&255===n[a+2]&&(n[a+3]=0);return s.putImageData(o,0,0),i}}return t.Assets=function(){function i(e){if(t.isString(e)){var i=r.getPostfix(e);return r.file_type[i]?r.file_type[i]:i}t.log.error("jaws.assets.getType: Argument not a String with "+e)}function s(s){var o=this.asset,n=o.src,h=i(o.src);try{if("json"===h){if(4!==this.readyState)return;r.data[o.src]=JSON.parse(this.responseText)}else if("image"===h){var c=r.image_to_canvas?t.imageToCanvas(o.image):o.image;r.fuchia_to_transparent&&"bmp"===r.getPostfix(o.src)&&(c=e(c)),r.data[o.src]=c}else r.data[o.src]="audio"===h&&r.can_play[r.getPostfix(o.src)]?o.audio:"video"===h&&r.can_play[r.getPostfix(o.src)]?o.video:this.response}catch(l){t.log.error("Cannot process "+n+" (Message: "+l.message+", Name: "+l.name+")"),r.data[o.src]=null}r.loaded[n]||r.load_count++,r.loaded[n]=!0,r.loading[n]=!1,a(o,!0,s)}function o(t){r.loaded[t.src]=!0,r.loading[t.src]=!1,r.load_count++,a(t,!0)}function n(t){var e=this.asset;r.error_count++,a(e,!1,t)}function a(t,e,i){var s=parseInt((r.load_count+r.error_count)/r.src_list.length*100);e?(r.onprogress&&r.onprogress(t.src,s),t.onprogress&&void 0!==i&&t.onprogress(i)):(r.onerror&&r.onerror(t.src,s),t.onerror&&void 0!==i&&t.onerror(i)),100===s&&(r.onload&&r.onload(),r.onprogress=null,r.onerror=null,r.onload=null)}if(!(this instanceof arguments.callee))return new arguments.callee;var r=this;r.loaded=[],r.loading=[],r.src_list=[],r.data=[],r.bust_cache=!1,r.image_to_canvas=!0,r.fuchia_to_transparent=!0,r.root="",r.file_type={},r.file_type.json="json",r.file_type.wav="audio",r.file_type.mp3="audio",r.file_type.ogg="audio",r.file_type.m4a="audio",r.file_type.weba="audio",r.file_type.aac="audio",r.file_type.mka="audio",r.file_type.flac="audio",r.file_type.png="image",r.file_type.jpg="image",r.file_type.jpeg="image",r.file_type.gif="image",r.file_type.bmp="image",r.file_type.tiff="image",r.file_type.mp4="video",r.file_type.webm="video",r.file_type.ogv="video",r.file_type.mkv="video",r.can_play={};try{var h=new Audio;r.can_play.wav=!!h.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),r.can_play.ogg=!!h.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),r.can_play.mp3=!!h.canPlayType("audio/mpeg;").replace(/^no$/,""),r.can_play.m4a=!!(h.canPlayType("audio/x-m4a;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),r.can_play.weba=!!h.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,""),r.can_play.aac=!!h.canPlayType("audio/aac;").replace(/^no$/,""),r.can_play.mka=!!h.canPlayType("audio/x-matroska;").replace(/^no$/,""),r.can_play.flac=!!h.canPlayType("audio/x-flac;").replace(/^no$/,"")}catch(c){}try{var l=document.createElement("video");r.can_play.mp4=!!l.canPlayType("video/mp4;").replace(/^no$/,""),r.can_play.webm=!!l.canPlayType('video/webm; codecs="vorbis"').replace(/^no$/,""),r.can_play.ogv=!!l.canPlayType('video/ogg; codecs="vorbis"').replace(/^no$/,""),r.can_play.mkv=!!l.canPlayType("video/x-matroska;").replace(/^no$/,"")}catch(c){}r.length=function(){return r.src_list.length},r.setRoot=function(t){return r.root=t,r},r.get=function(e){if(t.isArray(e))return e.map(function(t){return r.data[t]});if(!t.isString(e))return void t.log.error("jaws.get: Neither String nor Array. Incorrect URL resource "+e);if("*"===e[e.length-1])for(var i=e.replace("*",""),s=0;s<r.src_list.length;s++)if(0==r.src_list[s].indexOf(i)&&r.data[r.src_list[s]])return r.data[r.src_list[s]];return r.data[e]?r.data[e]:void t.log.warn("No such asset: "+e,!0)},r.isLoading=function(e){return t.isString(e)?r.loading[e]:void t.log.error("jaws.isLoading: Argument not a String with "+e)},r.isLoaded=function(e){return t.isString(e)?r.loaded[e]:void t.log.error("jaws.isLoaded: Argument not a String with "+e)},r.getPostfix=function(e){return t.isString(e)?e.toLowerCase().match(/.+\.([^?]+)(\?|$)/)[1]:void t.log.error("jaws.assets.getPostfix: Argument not a String with "+e)},r.add=function(e){var i=arguments;1==i.length&&t.isArray(i[0])&&(i=i[0]);for(var s=0;s<i.length;s++)t.isArray(i[s])?r.add(i[s]):t.isString(i[s])?r.src_list.push(i[s]):t.log.error("jaws.assets.add: Neither String nor Array. Incorrect URL resource "+e);return r},r.loadAll=function(e){return r.load_count=0,r.error_count=0,e.onprogress&&t.isFunction(e.onprogress)&&(r.onprogress=e.onprogress),e.onerror&&t.isFunction(e.onerror)&&(r.onerror=e.onerror),e.onload&&t.isFunction(e.onload)&&(r.onload=e.onload),r.src_list.forEach(function(t){r.load(t)}),r},r.load=function(e,a){if(a||(a={}),!t.isString(e))return void t.log.error("jaws.assets.load: Argument not a String with "+e);var h={},c="";h.src=e,h.onload=a.onload,h.onerror=a.onerror,r.loading[e]=!0;var l=RegExp("^((f|ht)tp(s)?:)?//");c=l.test(e)?h.src:r.root+h.src,r.bust_cache&&(c+="?"+parseInt(1e7*Math.random()));var u=i(h.src);if("image"===u)try{h.image=new Image,h.image.asset=h,h.image.addEventListener("load",s),h.image.addEventListener("error",n),h.image.src=c}catch(d){t.log.error("Cannot load Image resource "+c+" (Message: "+d.message+", Name: "+d.name+")")}else if(r.can_play[r.getPostfix(h.src)]){if("audio"===u)try{h.audio=new Audio,h.audio.asset=h,h.audio.addEventListener("error",n),h.audio.addEventListener("canplay",s),r.data[h.src]=h.audio,h.audio.src=c,h.audio.load()}catch(d){t.log.error("Cannot load Audio resource "+c+" (Message: "+d.message+", Name: "+d.name+")")}else if("video"===u)try{h.video=document.createElement("video"),h.video.asset=h,r.data[h.src]=h.video,h.video.setAttribute("style","display:none;"),h.video.addEventListener("error",n),h.video.addEventListener("canplay",s),document.body.appendChild(h.video),h.video.src=c,h.video.load()}catch(d){t.log.error("Cannot load Video resource "+c+" (Message: "+d.message+", Name: "+d.name+")")}}else{if("audio"===u&&!r.can_play[r.getPostfix(h.src)])return o(h),r;try{var f=new XMLHttpRequest;f.asset=h,f.onreadystatechange=s,f.onerror=n,f.open("GET",c,!0),"json"!==u&&(f.responseType="blob"),f.send(null)}catch(d){t.log.error("Cannot load "+c+" (Message: "+d.message+", Name: "+d.name+")")}}return r},r.displayProgress=function(e){t.isNumber(e)&&t.context&&(t.context.save(),t.context.fillStyle="black",t.context.fillRect(0,0,t.width,t.height),t.context.fillStyle="white",t.context.strokeStyle="white",t.context.textAlign="center",t.context.strokeRect(49,t.height/2-30-1,t.width-100+2,62),t.context.fillRect(50,t.height/2-30,(t.width-100)/100*e,60),t.context.font="11px verdana",t.context.fillText("Loading... "+e+"%",t.width/2,t.height/2-35),t.context.font="11px verdana",t.context.fillStyle="#ccc",t.context.textBaseline="bottom",t.context.fillText("powered by www.jawsjs.com",t.width/2,t.height-1),t.context.restore())}},t.assets=new t.Assets,t}(jaws||{});if("undefined"!=typeof require)var jaws=require("./core.js");var jaws=function(t){function e(t){this.size=t,this.values=new Array(this.size),this.value,this.add=function(t){if(this.values.length>this.size){this.values.splice(0,1),this.value=0;for(var e=0;this.values[e];e++)this.value+=this.values[e];this.value=this.value/this.size}return this.values.push(t),this},this.get=function(){return parseInt(this.value)}}return window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,16.666)}}(),t.GameLoop=function(i,s,o){if(!(this instanceof arguments.callee))return new arguments.callee(i,s);this.tick_duration=0,this.fps=0,this.ticks=0;var n,a=!1,r=!1,h=this,c=new e(20);this.runtime=function(){return this.last_tick-this.first_tick},this.start=function(){t.log.info("Game loop start",!0),this.first_tick=(new Date).getTime(),this.current_tick=(new Date).getTime(),this.last_tick=(new Date).getTime(),s.setup!==!1&&i.setup&&i.setup(o),step_delay=1e3/s.fps,60==s.fps?requestAnimFrame(this.loop):n=setInterval(this.loop,step_delay)},this.loop=function(){h.current_tick=(new Date).getTime(),h.tick_duration=h.current_tick-h.last_tick,h.fps=c.add(1e3/h.tick_duration).get(),r||a||(i.update&&i.update(),i.draw&&i.draw(),h.ticks++),60!=s.fps||r||requestAnimFrame(h.loop),h.last_tick=h.current_tick},this.pause=function(){a=!0},this.unpause=function(){a=!1},this.stop=function(){n&&clearInterval(n),r=!0}},t}(jaws||{}),jaws=function(t){var e=0;return t.Rect=function(t,i,s,o){return this instanceof arguments.callee?(this.x=t,this.y=i,this.width=s,this.height=o,this.right=t+s-e,void(this.bottom=i+o-e)):new arguments.callee(t,i,s,o)},t.Rect.prototype.getPosition=function(){return[this.x,this.y]},t.Rect.prototype.move=function(t,e){return this.x+=t,this.y+=e,this.right+=t,this.bottom+=e,this},t.Rect.prototype.moveTo=function(t,i){return this.x=t,this.y=i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.resize=function(t,i){return this.width+=t,this.height+=i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.clone=function(){return new t.Rect(this.x,this.y,this.width,this.height)},t.Rect.prototype.shrink=function(t,i){return this.x+=t,this.y+=i,this.width-=t+t,this.height-=i+i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.resizeTo=function(t,i){return this.width=t,this.height=i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.draw=function(){return t.context.strokeStyle="red",t.context.strokeRect(this.x-.5,this.y-.5,this.width,this.height),this},t.Rect.prototype.collidePoint=function(t,e){return t>=this.x&&t<=this.right&&e>=this.y&&e<=this.bottom},t.Rect.prototype.collideRect=function(t){return(this.x>=t.x&&this.x<=t.right||t.x>=this.x&&t.x<=this.right)&&(this.y>=t.y&&this.y<=t.bottom||t.y>=this.y&&t.y<=this.bottom)},t.Rect.prototype.toString=function(){return"[Rect "+this.x+", "+this.y+", "+this.width+", "+this.height+"]"},t}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.Rect);var jaws=function(jaws){return jaws.Sprite=function(t){return this instanceof arguments.callee?(this.set(t),void(this.context=t.context?t.context:jaws.context)):new arguments.callee(t)},jaws.Sprite.prototype.default_options={x:0,y:0,alpha:1,angle:0,flipped:!1,anchor_x:0,anchor_y:0,image:null,image_path:null,anchor:null,scale_image:null,damping:1,scale_x:1,scale_y:1,scale:1,color:"#ddd",width:16,height:16,_constructor:null,context:null,data:null},jaws.Sprite.prototype.set=function(t){if(jaws.isString(this.image)&&(this.image_path=this.image),jaws.parseOptions(this,t,this.default_options),this.scale&&(this.scale_x=this.scale_y=this.scale),this.image&&this.setImage(this.image),this.scale_image&&this.scaleImage(this.scale_image),this.anchor&&this.setAnchor(this.anchor),!this.image&&this.color&&this.width&&this.height){var e=document.createElement("canvas"),i=e.getContext("2d");e.width=this.width,e.height=this.height,i.fillStyle=this.color,i.fillRect(0,0,this.width,this.height),this.image=e}return this.cacheOffsets(),this},jaws.Sprite.prototype.clone=function(object){var constructor=this._constructor?eval(this._constructor):this.constructor,new_sprite=new constructor(this.attributes());return new_sprite._constructor=this._constructor||this.constructor.name,new_sprite},jaws.Sprite.prototype.setImage=function(t){var e=this;return jaws.isDrawable(t)?(this.image=t,this.cacheOffsets()):(jaws.assets.isLoaded(t)?(this.image=jaws.assets.get(t),this.cacheOffsets()):(jaws.log.warn("Image '"+t+"' not preloaded with jaws.assets.add(). Image and a working sprite.rect() will be delayed."),jaws.assets.load(t,{onload:function(){e.image=jaws.assets.get(t),e.cacheOffsets()}})),this)},jaws.Sprite.prototype.stepToWhile=function(t,e,i){var s=1,o=t<this.x?-s:s,n=e<this.y?-s:s;t=parseInt(t),e=parseInt(e);for(var a=!1,r=!1;;)if(a===!1&&(this.x!=t&&(this.x+=o),i(this)||(this.x-=o,a=!0)),r===!1&&(this.y!=e&&(this.y+=n),i(this)||(this.y-=n,r=!0)),(a||this.x==t)&&(r||this.y==e))return{x:a,y:r}},jaws.Sprite.prototype.stepWhile=function(t,e,i){return this.stepToWhile(this.x+t,this.y+e,i)},jaws.Sprite.prototype.flip=function(){return this.flipped=this.flipped?!1:!0,this},jaws.Sprite.prototype.flipTo=function(t){return this.flipped=t,this},jaws.Sprite.prototype.rotate=function(t){return this.angle+=t,this},jaws.Sprite.prototype.rotateTo=function(t){return this.angle=t,this},jaws.Sprite.prototype.moveTo=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),this.x=t,this.y=e,this},jaws.Sprite.prototype.move=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),t&&(this.x+=t),e&&(this.y+=e),this},jaws.Sprite.prototype.scaleAll=function(t){return this.scale_x*=t,this.scale_y*=t,this.cacheOffsets()},jaws.Sprite.prototype.scaleTo=function(t){return this.scale_x=this.scale_y=t,this.cacheOffsets()},jaws.Sprite.prototype.scaleWidth=function(t){return this.scale_x*=t,this.cacheOffsets()},jaws.Sprite.prototype.scaleHeight=function(t){return this.scale_y*=t,this.cacheOffsets()},jaws.Sprite.prototype.setX=function(t){return this.x=t,this},jaws.Sprite.prototype.setY=function(t){return this.y=t,this},jaws.Sprite.prototype.setTop=function(t){return this.y=t+this.top_offset,this},jaws.Sprite.prototype.setBottom=function(t){return this.y=t-this.bottom_offset,this},jaws.Sprite.prototype.setLeft=function(t){return this.x=t+this.left_offset,this},jaws.Sprite.prototype.setRight=function(t){return this.x=t-this.right_offset,this},jaws.Sprite.prototype.setWidth=function(t){return this.scale_x=t/this.image.width,this.cacheOffsets()},jaws.Sprite.prototype.setHeight=function(t){return this.scale_y=t/this.image.height,this.cacheOffsets()},jaws.Sprite.prototype.resize=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),this.scale_x=(this.width+t)/this.image.width,this.scale_y=(this.height+e)/this.image.height,this.cacheOffsets()},jaws.Sprite.prototype.resizeTo=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),this.scale_x=t/this.image.width,this.scale_y=e/this.image.height,this.cacheOffsets()},jaws.Sprite.prototype.setAnchor=function(t){var e={top_left:[0,0],left_top:[0,0],center_left:[0,.5],left_center:[0,.5],bottom_left:[0,1],left_bottom:[0,1],top_center:[.5,0],center_top:[.5,0],center_center:[.5,.5],center:[.5,.5],bottom_center:[.5,1],center_bottom:[.5,1],top_right:[1,0],right_top:[1,0],center_right:[1,.5],right_center:[1,.5],bottom_right:[1,1],right_bottom:[1,1]};return(a=e[t])&&(this.anchor_x=a[0],this.anchor_y=a[1],this.image&&this.cacheOffsets()),this},jaws.Sprite.prototype.cacheOffsets=function(){return this.image?(this.width=this.image.width*this.scale_x,this.height=this.image.height*this.scale_y,this.left_offset=this.width*this.anchor_x,this.top_offset=this.height*this.anchor_y,this.right_offset=this.width*(1-this.anchor_x),this.bottom_offset=this.height*(1-this.anchor_y),this.cached_rect&&this.cached_rect.resizeTo(this.width,this.height),this):void 0},jaws.Sprite.prototype.rect=function(){return!this.cached_rect&&this.width&&(this.cached_rect=new jaws.Rect(this.x,this.y,this.width,this.height)),this.cached_rect&&this.cached_rect.moveTo(this.x-this.left_offset,this.y-this.top_offset),this.cached_rect},jaws.Sprite.prototype.draw=function(){return this.image?(this.context.save(),this.context.translate(this.x,this.y),0!=this.angle&&jaws.context.rotate(this.angle*Math.PI/180),this.flipped&&this.context.scale(-1,1),this.context.globalAlpha=this.alpha,this.context.translate(-this.left_offset,-this.top_offset),this.context.drawImage(this.image,0,0,this.width,this.height),this.context.restore(),this):this},jaws.Sprite.prototype.scaleImage=function(t){return this.image?(this.setImage(jaws.retroScaleImage(this.image,t)),this):void 0},jaws.Sprite.prototype.asCanvasContext=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");return jaws.context&&(e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled),e.drawImage(this.image,0,0,this.width,this.height),e},jaws.Sprite.prototype.asCanvas=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");return jaws.context&&(e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled),e.drawImage(this.image,0,0,this.width,this.height),t},jaws.Sprite.prototype.toString=function(){return"[Sprite "+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width+", "+this.height+"]"},jaws.Sprite.prototype.attributes=function(){var t={};return t._constructor=this._constructor||"jaws.Sprite",t.x=parseFloat(this.x.toFixed(2)),t.y=parseFloat(this.y.toFixed(2)),t.image=this.image_path,t.alpha=this.alpha,t.flipped=this.flipped,t.angle=parseFloat(this.angle.toFixed(2)),t.scale_x=this.scale_x,t.scale_y=this.scale_y,t.anchor_x=this.anchor_x,t.anchor_y=this.anchor_y,null!==this.data&&(t.data=jaws.clone(this.data)),t},jaws.Sprite.parse=function(objects){function parseArray(array){array.forEach(function(data){var constructor=data._constructor?eval(data._constructor):data.constructor;if(jaws.isFunction(constructor)){jaws.log.info("Creating "+data._constructor+"("+data.toString()+")",!0);var object=new constructor(data);object._constructor=data._constructor||data.constructor.name,sprites.push(object)}})}var sprites=[];return jaws.isArray(objects)?objects.every(function(t){return t._constructor})?parseArray(objects):sprites=objects:jaws.isString(objects)&&(parseArray(JSON.parse(objects)),jaws.log.info(objects)),sprites},jaws.Sprite.prototype.toJSON=function(){return JSON.stringify(this.attributes())},jaws}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.Sprite);var jaws=function(t){function e(t,e,i,s,o){var n=document.createElement("canvas");n.width=s,n.height=o;var a=n.getContext("2d");return a.drawImage(t,e,i,s,o,0,0,n.width,n.height),n}return t.SpriteSheet=function(i){if(!(this instanceof arguments.callee))return new arguments.callee(i);if(t.parseOptions(this,i,this.default_options),t.isString(this.image)&&!i.frame_size){var s=new RegExp("_(\\d+)x(\\d+)","g"),o=s.exec(this.image);this.frame_size=[],this.frame_size[0]=parseInt(o[1]),this.frame_size[1]=parseInt(o[2])}if(this.image=t.isDrawable(this.image)?this.image:t.assets.data[this.image],this.scale_image){var n=t.isDrawable(this.image)?this.image:t.assets.get(this.image);this.frame_size[0]*=this.scale_image,this.frame_size[1]*=this.scale_image,this.image=t.retroScaleImage(n,this.scale_image)}if(this.frames=[],"down"==this.orientation)for(var a=this.offset;a<this.image.width;a+=this.frame_size[0])for(var r=0;r<this.image.height;r+=this.frame_size[1])this.frames.push(e(this.image,a,r,this.frame_size[0],this.frame_size[1]));else for(var r=this.offset;r<this.image.height;r+=this.frame_size[1])for(var a=0;a<this.image.width;a+=this.frame_size[0])this.frames.push(e(this.image,a,r,this.frame_size[0],this.frame_size[1]))},t.SpriteSheet.prototype.default_options={image:null,orientation:"down",frame_size:[32,32],offset:0,scale_image:null},t.SpriteSheet.prototype.toString=function(){return"[SpriteSheet "+this.frames.length+" frames]"},t}(jaws||{}),jaws=function(t){return t.Animation=function(e){if(!(this instanceof arguments.callee))return new arguments.callee(e);if(t.parseOptions(this,e,this.default_options),e.sprite_sheet){var i=new t.SpriteSheet({image:e.sprite_sheet,scale_image:this.scale_image,frame_size:this.frame_size,orientation:this.orientation,offset:this.offset});this.frames=i.frames,this.frame_size=i.frame_size}if(e.scale_image){var s=t.isDrawable(e.sprite_sheet)?e.sprite_sheet:t.assets.get(e.sprite_sheet);this.frame_size[0]*=e.scale_image,this.frame_size[1]*=e.scale_image,e.sprite_sheet=t.retroScaleImage(s,e.scale_image)}if(this.current_tick=(new Date).getTime(),this.last_tick=(new Date).getTime(),this.sum_tick=0,e.subsets){this.subsets={};for(subset in e.subsets)start_stop=e.subsets[subset],this.subsets[subset]=this.slice(start_stop[0],start_stop[1])}},t.Animation.prototype.default_options={frames:[],subsets:[],frame_duration:100,index:0,loop:1,bounce:0,frame_direction:1,frame_size:null,orientation:"down",on_end:null,offset:0,scale_image:null,sprite_sheet:null},t.Animation.prototype.subset=function(t){return this.subsets[t]},t.Animation.prototype.update=function(){return this.current_tick=(new Date).getTime(),this.sum_tick+=this.current_tick-this.last_tick,this.last_tick=this.current_tick,this.sum_tick>this.frame_duration&&(this.index+=this.frame_direction,this.sum_tick=0),(this.index>=this.frames.length||this.index<0)&&(this.bounce?(this.frame_direction=-this.frame_direction,this.index+=2*this.frame_direction):this.loop?this.index=this.frame_direction<0?this.frames.length-1:0:(this.index-=this.frame_direction,this.on_end&&(this.on_end(),this.on_end=null))),this +},t.Animation.prototype.slice=function(e,i){var s={};return s.frame_duration=this.frame_duration,s.loop=this.loop,s.bounce=this.bounce,s.on_end=this.on_end,s.frame_direction=this.frame_direction,s.frames=this.frames.slice().slice(e,i),new t.Animation(s)},t.Animation.prototype.next=function(){return this.update(),this.frames[this.index]},t.Animation.prototype.atLastFrame=function(){return this.index==this.frames.length-1},t.Animation.prototype.atFirstFrame=function(){return 0==this.index},t.Animation.prototype.currentFrame=function(){return this.frames[this.index]},t.Animation.prototype.toString=function(){return"[Animation, "+this.frames.length+" frames]"},t}(jaws||{});if("undefined"!=typeof require)var jaws=require("./core.js");var jaws=function(t){function e(t,e){for(var i=function(e){return void 0!==t.isSpriteList?t.at(e):t[e]},s=[],o=new Array(e),n=0;e>n;n++)o[n]=n;for(var n=e-1,a=t.length;n>=0;a=t.length){for(s.push(o.map(i));n>=0&&o[n]===a-1;)n--,a--;if(n>=0){o[n]+=1;for(var r=n+1;e>r;r++)o[r]=o[r-1]+1;n=e-1}}return s}return t.collideOneWithOne=function(e,i){return e.radius&&i.radius&&e!==i&&t.collideCircles(e,i)?!0:e.rect&&i.rect&&e!==i&&t.collideRects(e.rect(),i.rect())?!0:!1},t.collideOneWithMany=function(e,i,s){var o=[];if(s){for(var n=0;n<i.length;n++)t.collideOneWithOne(e,i[n])&&(s(e,i[n]),o.push(i[n]));return o}return i.filter(function(i){return t.collideOneWithOne(e,i)})},t.collideManyWithMany=function(i,s,o){var n=[];return i===s?e(i,2).forEach(function(e){t.collideOneWithOne(e[0],e[1])&&(o?o(e[0],e[1]):n.push([e[0],e[1]]))}):i.forEach(function(e){s.forEach(function(i){t.collideOneWithOne(e,i)&&(o?o(e,i):n.push([e,i]))})}),n},t.collideCircles=function(e,i){return t.distanceBetween(e,i)<e.radius+i.radius},t.collideRects=function(t,e){return(t.x>=e.x&&t.x<=e.right||e.x>=t.x&&e.x<=t.right)&&(t.y>=e.y&&t.y<=e.bottom||e.y>=t.y&&e.y<=t.bottom)},t.distanceBetween=function(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))},t.collide=function(e,i,s){if((e.rect||e.radius)&&i.forEach)return t.collideOneWithMany(e,i,s).length>0;if(e.forEach&&i.forEach)return t.collideManyWithMany(e,i,s).length>0;if(e.forEach&&(i.rect||i.radius))return t.collideOneWithMany(i,e,s).length>0;if(e.rect&&i.rect||e.radius&&i.radius){var o=t.collideOneWithOne(e,i);if(!s||!o)return o;s(e,i)}},t}(jaws||{}),jaws=function(t){return t.PixelMap=function(e){return this instanceof arguments.callee?(this.options=e,this.scale=e.scale||1,this.x=e.x||0,this.y=e.y||0,e.image?(this.setContext(e.image),e.scale_image&&this.setContext(t.retroScaleImage(this.context.canvas,e.scale_image)),this.width=this.context.canvas.width*this.scale,this.height=this.context.canvas.height*this.scale):t.log.warn("PixelMap needs an image to work with"),this.named_colors=[],void this.update()):new arguments.callee(e)},t.PixelMap.prototype.setContext=function(e){var e=t.isDrawable(e)?e:t.assets.get(e);this.context=t.imageToCanvasContext(e)},t.PixelMap.prototype.update=function(t,e,i,s){if((void 0===t||0>t)&&(t=0),(void 0===e||0>e)&&(e=0),(void 0===i||i>this.width)&&(i=this.width),(void 0===s||s>this.height)&&(s=this.height),0==arguments.length)this.data=this.context.getImageData(t,e,i,s).data;else for(var o=this.context.getImageData(t,e,i,s).data,n=0,a=4*this.width,r=e*this.width*4+4*t,h=4*i,c=0;s>c;c++){for(var l=0;h>l;l++)this.data[r+l]=o[n++];r+=a}},t.PixelMap.prototype.draw=function(){t.context.drawImage(this.context.canvas,this.x,this.y,this.width,this.height)},t.PixelMap.prototype.namedColorAtRect=function(t,e){for(var i=t.x,s=t.y;i<t.right-1;i++)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);for(;s<t.bottom-1;s++)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);for(;i>t.x;i--)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);for(;s>t.y;s--)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);return!1},t.PixelMap.prototype.at=function(t,e){t=parseInt(t),e=parseInt(e),0>e&&(e=0);var i=e*this.width*4+4*t,s=this.data[i],o=this.data[i+1],n=this.data[i+2],a=this.data[i+3];return[s,o,n,a]},t.PixelMap.prototype.namedColorAt=function(t,e){for(var i=this.at(t,e),s=0;s<this.named_colors.length;s++){var o=this.named_colors[s].name,n=this.named_colors[s].color;if(n[0]==i[0]&&n[1]==i[1]&&n[2]==i[2]&&n[3]==i[3])return o}},t.PixelMap.prototype.nameColor=function(t,e){this.named_colors.push({name:e,color:t})},t}(jaws||{}),jaws=function(t){return t.Parallax=function(e){return this instanceof arguments.callee?void t.parseOptions(this,e,this.default_options):new arguments.callee(e)},t.Parallax.prototype.default_options={width:function(){return t.width},height:function(){return t.height},scale:1,repeat_x:null,repeat_y:null,camera_x:0,camera_y:0,layers:[]},t.Parallax.prototype.draw=function(){for(var t,e,i=0;i<this.layers.length;i++)for(t=this.layers[i],e=this.repeat_x?-(this.camera_x/t.damping%t.width):-(this.camera_x/t.damping),t.y=this.repeat_y?-(this.camera_y/t.damping%t.height):-(this.camera_y/t.damping),t.x=e;t.y<this.height;){for(;t.x<this.width&&(t.x+t.width>=0&&t.y+t.height>=0&&t.draw(),t.x=t.x+t.width,this.repeat_x););if(t.y=t.y+t.height,t.x=e,!this.repeat_y)break}},t.Parallax.prototype.addLayer=function(e){var i=new t.ParallaxLayer(e);i.scaleAll(this.scale),this.layers.push(i)},t.Parallax.prototype.toString=function(){return"[Parallax "+this.x+", "+this.y+". "+this.layers.length+" layers]"},t.ParallaxLayer=function(e){return this instanceof arguments.callee?(this.damping=e.damping||0,void t.Sprite.call(this,e)):new arguments.callee(e)},t.ParallaxLayer.prototype=t.Sprite.prototype,t}(jaws||{}),jaws=function(jaws){return jaws.Text=function(t){return this instanceof arguments.callee?(this.set(t),t.context&&(this.context=t.context),void(t.context||jaws.context&&(this.context=jaws.context))):new arguments.callee(t)},jaws.Text.prototype.default_options={x:0,y:0,alpha:1,angle:0,anchor_x:0,anchor_y:0,anchor:"top_left",damping:1,style:"normal",fontFace:"serif",fontSize:12,color:"black",textAlign:"start",textBaseline:"alphabetic",text:"",wordWrap:!1,width:function(){return jaws.width},height:function(){return jaws.height},shadowColor:null,shadowBlur:null,shadowOffsetX:null,shadowOffsetY:null,_constructor:null},jaws.Text.prototype.set=function(t){return jaws.parseOptions(this,t,this.default_options),this.anchor&&this.setAnchor(this.anchor),this.cacheOffsets(),this},jaws.Text.prototype.clone=function(){var constructor=this._constructor?eval(this._constructor):this.constructor,new_sprite=new constructor(this.attributes());return new_sprite._constructor=this._constructor||this.constructor.name,new_sprite},jaws.Text.prototype.rotate=function(t){return this.angle+=t,this},jaws.Text.prototype.rotateTo=function(t){return this.angle=t,this},jaws.Text.prototype.moveTo=function(t,e){return this.x=t,this.y=e,this},jaws.Text.prototype.move=function(t,e){return t&&(this.x+=t),e&&(this.y+=e),this},jaws.Text.prototype.setX=function(t){return this.x=t,this},jaws.Text.prototype.setY=function(t){return this.y=t,this},jaws.Text.prototype.setTop=function(t){return this.y=t+this.top_offset,this},jaws.Text.prototype.setBottom=function(t){return this.y=t-this.bottom_offset,this},jaws.Text.prototype.setLeft=function(t){return this.x=t+this.left_offset,this},jaws.Text.prototype.setRight=function(t){return this.x=t-this.right_offset,this},jaws.Text.prototype.setWidth=function(t){return this.width=t,this.cacheOffsets(),this},jaws.Text.prototype.setHeight=function(t){return this.height=t,this.cacheOffsets(),this},jaws.Text.prototype.resize=function(t,e){return this.width+=t,this.height+=e,this.cacheOffsets(),this},jaws.Text.prototype.resizeTo=function(t,e){return this.width=t,this.height=e,this.cacheOffsets(),this},jaws.Text.prototype.setAnchor=function(t){var e={top_left:[0,0],left_top:[0,0],center_left:[0,.5],left_center:[0,.5],bottom_left:[0,1],left_bottom:[0,1],top_center:[.5,0],center_top:[.5,0],center_center:[.5,.5],center:[.5,.5],bottom_center:[.5,1],center_bottom:[.5,1],top_right:[1,0],right_top:[1,0],center_right:[1,.5],right_center:[1,.5],bottom_right:[1,1],right_bottom:[1,1]};return e.hasOwnProperty(t)&&(this.anchor_x=e[t][0],this.anchor_y=e[t][1],this.cacheOffsets()),this},jaws.Text.prototype.cacheOffsets=function(){return this.left_offset=this.width*this.anchor_x,this.top_offset=this.height*this.anchor_y,this.right_offset=this.width*(1-this.anchor_x),this.bottom_offset=this.height*(1-this.anchor_y),this.cached_rect&&this.cached_rect.resizeTo(this.width,this.height),this},jaws.Text.prototype.rect=function(){return!this.cached_rect&&this.width&&(this.cached_rect=new jaws.Rect(this.x,this.y,this.width,this.height)),this.cached_rect&&this.cached_rect.moveTo(this.x-this.left_offset,this.y-this.top_offset),this.cached_rect},jaws.Text.prototype.draw=function(){this.context.save(),0!==this.angle&&this.context.rotate(this.angle*Math.PI/180),this.context.globalAlpha=this.alpha,this.context.translate(-this.left_offset,-this.top_offset),this.context.fillStyle=this.color,this.context.font=this.style+" "+this.fontSize+"px "+this.fontFace,this.context.textBaseline=this.textBaseline,this.context.textAlign=this.textAlign,this.shadowColor&&(this.context.shadowColor=this.shadowColor),this.shadowBlur&&(this.context.shadowBlur=this.shadowBlur),this.shadowOffsetX&&(this.context.shadowOffsetX=this.shadowOffsetX),this.shadowOffsetY&&(this.context.shadowOffsetY=this.shadowOffsetY);var t=this.y,e=this.x;if(this.wordWrap)for(var i=this.text.split(" "),s="",o=0;o<i.length;o++){var n=s+i[o]+" ",a=this.context.measureText(n);this.y<t+this.height&&(a.width>this.width?(this.context.fillText(s,this.x,this.y),s=i[o]+" ",this.y+=this.fontSize):s=n,this.context.fillText(s,this.x,this.y))}else if(this.context.measureText(this.text).width<this.width)this.context.fillText(this.text,this.x,this.y);else for(var i=this.text.split(" "),s=" ",o=0;o<i.length;o++){var n=s+i[o]+" ";this.context.measureText(n).width<Math.abs(this.width-this.x)&&(this.context.fillText(n,this.x,this.y),s=i[o]+" ",s=n)}return this.y=t,this.x=e,this.context.restore(),this},jaws.Text.prototype.asCanvasContext=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled,this.context.fillStyle=this.color,this.context.font=this.style+this.fontSize+"px "+this.fontFace,this.context.textBaseline=this.textBaseline,this.context.textAlign=this.textAlign,this.shadowColor&&(this.context.shadowColor=this.shadowColor),this.shadowBlur&&(this.context.shadowBlur=this.shadowBlur),this.shadowOffsetX&&(this.context.shadowOffsetX=this.shadowOffsetX),this.shadowOffsetY&&(this.context.shadowOffsetY=this.shadowOffsetY);var i=this.y,s=this.x;if(this.wordWrap)for(var o=this.text.split(" "),n="",a=0;a<o.length;a++){var r=n+o[a]+" ",h=this.context.measureText(r);this.y<i+this.height&&(h.width>this.width?(this.context.fillText(n,this.x,this.y),n=o[a]+" ",this.y+=this.fontSize):n=r,this.context.fillText(n,this.x,this.y))}else if(this.context.measureText(this.text).width<this.width)this.context.fillText(this.text,this.x,this.y);else for(var o=this.text.split(" "),n=" ",a=0;a<o.length;a++){var r=n+o[a]+" ";this.context.measureText(r).width<Math.abs(this.width-this.x)&&(this.context.fillText(r,this.x,this.y),n=o[a]+" ",n=r)}return this.y=i,this.x=s,e},jaws.Text.prototype.asCanvas=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled,this.context.fillStyle=this.color,this.context.font=this.style+this.fontSize+"px "+this.fontFace,this.context.textBaseline=this.textBaseline,this.context.textAlign=this.textAlign,this.shadowColor&&(this.context.shadowColor=this.shadowColor),this.shadowBlur&&(this.context.shadowBlur=this.shadowBlur),this.shadowOffsetX&&(this.context.shadowOffsetX=this.shadowOffsetX),this.shadowOffsetY&&(this.context.shadowOffsetY=this.shadowOffsetY);var i=this.y,s=this.x;if(this.wordWrap)for(var o=this.text.split(" "),n="",a=0;a<o.length;a++){var r=n+o[a]+" ",h=e.measureText(r);this.y<i+this.height&&(h.width>this.width?(e.fillText(n,this.x,this.y),n=o[a]+" ",this.y+=this.fontSize):n=r,e.fillText(n,this.x,this.y))}else if(e.measureText(this.text).width<this.width)this.context.fillText(this.text,this.x,this.y);else for(var o=this.text.split(" "),n=" ",a=0;a<o.length;a++){var r=n+o[a]+" ";e.measureText(r).width<Math.abs(this.width-this.x)&&(e.fillText(r,this.x,this.y),n=o[a]+" ",n=r)}return this.y=i,this.x=s,t},jaws.Text.prototype.toString=function(){return"[Text "+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width+", "+this.height+"]"},jaws.Text.prototype.attributes=function(){var t=this.options;return t._constructor=this._constructor||"jaws.Text",t.x=parseFloat(this.x.toFixed(2)),t.y=parseFloat(this.y.toFixed(2)),t.text=this.text,t.alpha=this.alpha,t.angle=parseFloat(this.angle.toFixed(2)),t.anchor_x=this.anchor_x,t.anchor_y=this.anchor_y,t.style=this.style,t.fontSize=this.fontSize,t.fontFace=this.fontFace,t.color=this.color,t.textAlign=this.textAlign,t.textBaseline=this.textBaseline,t.wordWrap=this.wordWrap,t.width=this.width,t.height=this.height,t},jaws.Text.prototype.toJSON=function(){return JSON.stringify(this.attributes())},jaws}(jaws||{});if("undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.Text),"undefined"!=typeof require)var jaws=require("./core.js");var jaws=function(t){return t.QuadTree=function(e){this.depth=arguments[1]||0,this.bounds=e||new t.Rect(0,0,t.width,t.height),this.nodes=[],this.objects=[]},t.QuadTree.prototype.clear=function(){this.objects=[];for(var t=0;t<this.nodes.length;t++)"undefined"!=typeof this.nodes[t]&&(this.nodes[t].clear(),delete this.nodes[t])},t.QuadTree.prototype.split=function(){var e=Math.round(this.bounds.width/2),i=Math.round(this.bounds.height/2),s=this.bounds.x,o=this.bounds.y;this.nodes[0]=new t.QuadTree(new t.Rect(s+e,o,e,i),this.depth+1),this.nodes[1]=new t.QuadTree(new t.Rect(s,o,e,i),this.depth+1),this.nodes[2]=new t.QuadTree(new t.Rect(s,o+i,e,i),this.depth+1),this.nodes[3]=new t.QuadTree(new t.Rect(s+e,o+i,e,i),this.depth+1)},t.QuadTree.prototype.getIndex=function(t){var e=-1,i=this.bounds.x+this.bounds.width/2,s=this.bounds.y+this.bounds.height/2,o=t.y<s&&t.y+t.height<s,n=t.y>s;return t.x<i&&t.x+t.width<i?o?e=1:n&&(e=2):t.x>i&&(o?e=0:n&&(e=3)),e},t.QuadTree.prototype.insert=function(t){if(t.hasOwnProperty("x")||t.hasOwnProperty("y")||t.hasOwnProperty("width")||t.hasOwnProperty("height")){if("undefined"!=typeof this.nodes[0]){var e=this.getIndex(t);if(-1!==e)return void this.nodes[e].insert(t)}this.objects.push(t),"undefined"==typeof this.nodes[0]&&this.split();for(var i=0;i<this.objects.length;){var e=this.getIndex(this.objects[i]);-1!==e?this.nodes[e].insert(this.objects.splice(i,1)[0]):i++}}},t.QuadTree.prototype.retrieve=function(t){if(t.hasOwnProperty("x")||t.hasOwnProperty("y")||t.hasOwnProperty("width")||t.hasOwnProperty("height")){var e=this.getIndex(t),i=this.objects;if("undefined"!=typeof this.nodes[0])if(-1!==e)i=i.concat(this.nodes[e].retrieve(t));else for(var s=0;s<this.nodes.length;s++)i=i.concat(this.nodes[s].retrieve(t));return i}},t.QuadTree.prototype.collide=function(e,i,s){var o=!1,n=new t.QuadTree,a=[];return e.forEach||(a.push(e),e=a),i.forEach||(a=[],a.push(i),i=a),i.forEach(function(t){n.insert(t)}),e.forEach(function(e){t.collide(e,n.retrieve(e),s)&&(o=!0)}),n.clear(),o},t}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.QuadTree),window.addEventListener("load",function(){jaws.onload&&jaws.onload()},!1);</script><script type="text/javascript">(function () { + return (function() { + var screen_x1, screen_y1; + screen_x1 = 240; + screen_y1 = 180; + return jaws.onload = function() { + var Demo, game, gameloop; + Demo = (function() { + var AiVaquita, FlippableSprite, HeroVaquita, Sprite, Vaquita, downKey, leftKey, rightKey, spaceKey, upKey, _ref1; + + _ref1 = jaws.keyCodes, leftKey = _ref1.left, rightKey = _ref1.right, upKey = _ref1.up, downKey = _ref1.down, spaceKey = _ref1.space; + + Sprite = (function(_super) { + __extends(_Class, _super); + + function _Class() { + _Class.__super__.constructor.call(this, { + image: this.image, + x: 0, + y: 0, + scale: 2 + }); + } + + return _Class; + + })(jaws.Sprite); + + FlippableSprite = (function(_super) { + __extends(_Class, _super); + + function _Class() { + return _Class.__super__.constructor.apply(this, arguments); + } + + _Class.prototype.draw = function() { + this.flipped = this.lr >= 0; + this.x = (screen_x1 + this.px + this.lr) * 2; + this.y = (screen_y1 + this.py - 5) * 2; + return _Class.__super__.draw.call(this); + }; + + return _Class; + + })(Sprite); + + Vaquita = (function(_super) { + __extends(_Class, _super); + + function _Class() { + this.lr = 18; + _Class.__super__.constructor.call(this); + } + + _Class.prototype.draw = function() { + if (this.vx < 0) { + this.lr = -18; + } else if (this.vx > 0) { + this.lr = 18; + } + return _Class.__super__.draw.call(this); + }; + + return _Class; + + })(FlippableSprite); + + AiVaquita = (function(_super) { + __extends(_Class, _super); + + function _Class() { + this.image = Math.random() > 0.5 ? pixyvaquita_105 : pixyvaquita; + _Class.__super__.constructor.call(this); + } + + _Class.prototype.draw = function() { + var rx, ry, s, vx, vy, y; + vx = this.vx + Math.floor(Math.random() * 3) - 1; + vy = this.vy + Math.floor(Math.random() * 3) - 1; + x = this.px; + y = this.py; + rx = 0.5 * x / screen_x1; + ry = 0.5 * y / screen_y1; + if ((s = vx * vx + vy * vy * 2) > 6) { + vx = Math.round(vx * 0.9 - rx); + vy = Math.round(vy * 0.9 - ry); + } + this.px += this.vx = vx; + this.py += this.vy = vy; + return _Class.__super__.draw.call(this); + }; + + return _Class; + + })(Vaquita); + + HeroVaquita = (function(_super) { + var twistleft; + + __extends(_Class, _super); + + twistleft = pixyvaquita_twistleft; + + function _Class() { + this.image = pixyvaquita; + this.time = 0; + _Class.__super__.constructor.call(this); + } + + _Class.prototype.draw = function() { + this.vx = (jaws.pressed[leftKey] ? -1 : 0) + (jaws.pressed[rightKey] ? 1 : 0); + this.vy = (jaws.pressed[upKey] ? -1 : 0) + (jaws.pressed[downKey] ? 1 : 0); + this.px += this.vx; + this.py += this.vy; + if ((this.time++ % 3) === 0) { + if (this.image === twistleft) { + this.image = pixyvaquita; + } else if (this.vx !== 0) { + this.image = twistleft; + } + } + return _Class.__super__.draw.call(this); + }; + + return _Class; + + })(Vaquita); + + Demo.prototype.addVaquita = function() { + var angle, v; + angle = Math.random() * 6.28; + v = new AiVaquita; + v.vx = 0; + v.vy = 0; + v.px = Math.floor(Math.sin(angle) * 300); + v.py = Math.floor(Math.cos(angle) * 300); + v.draw(); + return this.vaquitas.push(v); + }; + + function Demo(vaquitas) { + this.vaquitas = vaquitas != null ? vaquitas : []; } + + Demo.prototype.setup = function() { + var v; + v = new HeroVaquita; + v.px = 0; + v.py = 0; + v.vx = 0; + v.vy = 0; + return this.vaquitas.push(v); + }; + + Demo.prototype.draw = function() { + var v, _j, _len1, _ref2; + jaws.clear(); + if (this.vaquitas.length < 7 || jaws.pressed[spaceKey]) { + this.addVaquita(); + } + _ref2 = this.vaquitas; + for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { + v = _ref2[_j]; + v.draw(); + } + if ((this.gameloop.ticks & 0xff) === 0xff) { + return fps.innerHTML = " - " + this.gameloop.fps + " fps"; + } + }; + + return Demo; + + })(); + if (true) { + jaws.init(); + jaws.setupInput(); + game = new Demo; + gameloop = new jaws.GameLoop(game, { + fps: 24 + }); + return (game.gameloop = gameloop).start(); + } else { + return jaws.start(Demo, { + fps: 25 + }); } - for (_k = 0, _len2 = vaquitas.length; _k < _len2; _k++) { - vq = vaquitas[_k]; - vq.update(); - } - return time++; }; - return setInterval(gameFrame, 40); - })(0, 0); + })(); })(); </script></body></html>
\ No newline at end of file diff --git a/game.html.coffee b/game.html.coffee index d31c1af..4184cca 100644 --- a/game.html.coffee +++ b/game.html.coffee @@ -1,24 +1,16 @@ # Copyright (c) 2013, 2014 Michele Bini -# This program is free software: you can redistribute it and/or modify -# it under the terms of the version 3 of the GNU General Public License -# as published by the Free Software Foundation. +# A game featuring a Vaquita, the smallest, most endagered marine cetacean -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. +# This program is available under the terms of the MIT License -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +version = "0.1.54" { htmlcup } = require 'htmlcup' -version = "0.0.12" - htmlcup[x] = htmlcup.compileTag x for x in [ "svg", "rect", "g", "ellipse", "polygon", "line", "image", "defs", "linearGradient", "stop", "use" ] -title = "Vilma the Vaquita Demo" +title = "Vilma the Vaquita" fs = require 'fs' @@ -36,7 +28,7 @@ frames = gameName = "#{title} v#{version}" -useSvg = true +htmlcup.jsFile = (f)-> @script type:"text/javascript", (fs.readFileSync(f).toString()) genPage = -> htmlcup.html5Page -> @@ -58,6 +50,7 @@ genPage = -> font-family: Helvetica; color:white; color:rgba(255,255,255,0.9); + margin:0; } .banner { border: 5px solid white; @@ -65,14 +58,16 @@ genPage = -> box-shadow: 0 2px 4px blue; margin: 1em; } - p { + footer, p { margin-top:0.418em; margin-bottom:0.418em; margin-left:auto; margin-right:auto; + text-shadow: 0 1px 1px blue; + } + p { width:22em; max-width:100%; - text-shadow: 0 1px 1px blue; } a { /* @@ -164,8 +159,12 @@ genPage = -> @body -> @div class:"centering page", -> @div class:"centered", -> - if useSvg - @svg id:"sea-svgroot", width:"960", height:"720", -> + @div style:"visibility:hidden;position:absolute", -> + @img id:"pixyvaquita", src:pixyvaquita + @img id:"pixyvaquita_105", src:frames._v105 + @img id:"pixyvaquita_twistleft", src:frames.twistleft + @div style:"position:relative", -> + @svg id:"sea-svgroot", width:"960", height:"720", style:"position:absolute;opacity:0.9;z-index:-1000", -> @defs -> @linearGradient id:"grad1", x1:"0%", y1:"0%", x2:"0%", y2:"100%", -> @stop offset:"0%", style:"stop-color:rgb(255,255,255);stop-opacity:1" @@ -173,142 +172,156 @@ genPage = -> @stop offset:"50%", style:"stop-color:rgb(0,80,240);stop-opacity:1" @stop offset:"75%", style:"stop-color:rgb(0,0,180);stop-opacity:1" @stop offset:"100%", style:"stop-color:rgb(0,0,0);stop-opacity:1" - for k,v of frames - @g id:k, -> - @g transform:"translate(-18,-15)", -> - @image width:"50", height:"30", "xlink:href":v @rect x:"0", y:"0", width:"960", height:"720", fill:"url(#grad1)" - @g transform:"scale(2)", -> - @g id:"sea", transform:"translate(240,180)", -> - @use "xlink:href":"#_" - else - @canvas width:"960", height:"720", -> - @div class:"dim", -> + @canvas width:"960", height:"720", -> + @footer class:"dim", -> @span gameName @span " - " @a target:"_blank", href:"index.html", "Learn about Vaquitas" + @span id:"fps" gameObjects = null @script type:"text/javascript", "gameObjects=#{JSON.stringify(gameObjects)};" - @coffeeScript -> - svgroot = document.getElementById("sea-svgroot") + @script type:"text/javascript", "__hasProp = {}.hasOwnProperty; __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };" + @jsFile "jaws/jaws-min.js" + # @jsFile "jaws-assets-named.js" + @coffeeScript -> do -> + # svgroot = document.getElementById("sea-svgroot") + + # reportErrors = (x)-> + # try + # x() + # catch error + # try + # alert error.toString() + # catch error2 + # alert error screen_x1 = 240 screen_y1 = 180 - vaquitas = [ ] - vaquitaObj = - update: (x, y)-> - if !window.abcd - window.abcd = 1 - vx = @vx + Math.floor(Math.random()*3) - 1 - vy = @vy + Math.floor(Math.random()*3) - 1 - x = @x - y = @y - rx = 0.5 * x / screen_x1 - ry = 0.5 * y / screen_y1 - if (s = vx * vx + vy * vy * 2) > 6 - vx = Math.round(vx * 0.9 + rx) - vy = Math.round(vy * 0.9 + ry) - @x = x -= @vx = vx - @y = y -= @vy = vy - if vx > 0 - @scaleX = 1 - else if vx < 0 - @scaleX = -1 - @e.setAttribute "transform", "translate(#{x}, #{y}) scale(#{@scaleX}, 1)" - # m = @m; m.e = x; m.f = y; m.a = @scaleX - sea = document.getElementById "sea" - v = sea.firstChild - - getTransformMatrix = (el)-> - transformListXX = el.transform.baseVal - transformMatrixXX = svgroot.createSVGMatrix() - transformXX = svgroot.createSVGTransform() - transformXX.setMatrix(transformMatrixXX) - transformListXX.initialize(transformXX) - transformXX.matrix - - addVaquita = -> - n = v.cloneNode() - n.setAttribute "opacity", "0.5" - n.href.baseVal = "#_v105" if Math.random(0) > 0.5 - # n.setAttribute "transform", "" - sea.appendChild n - angle = Math.random() * 6.28 - vaquita = - e: n - # m: getTransformMatrix(n) - x: Math.sin(angle) * 300 - y: Math.cos(angle) * 300 - vx: 0 - vy: 0 - scaleX: 1 - __proto__: vaquitaObj - vaquita.update() - vaquitas.push vaquita - - leftKey = 37 - upKey = 38 - rightKey = 39 - downKey = 40 - usedKeys = [ leftKey, upKey, rightKey, downKey ] - - keyDownActions = - 32: addVaquita - - pressedKeys = { } - pressedKeys[k] = 0 for k in usedKeys - - keydown = (event)-> - code = event.keyCode - keyDownActions[ code ]?(event) - pressedKeys[ code ] = 1 - keydown = (event)-> - pressedKeys[ event.keyCode ] = 0 - window.addEventListener 'keydown', keydown, true - window.addEventListener 'keyup', keyup, true - - do (x = 0, y = 0)-> - time = 0 - vx = 0 - vy = 0 - ax = 0 - ay = 0 - # s = 1 - # x = 0 - # y = 0 - scaleX = 1 - scaleY = 1 - - window.cf = currentFrame = v.href - # transformMatrix = getTransformMatrix(v) - # transformMatrix.a = scaleX - # transformMatrix.e = x - # transformMatrix.f = y + + jaws.onload = -> + class Demo + { left: leftKey, right: rightKey, up: upKey, down: downKey, space: spaceKey } = jaws.keyCodes + Sprite = class extends jaws.Sprite + # caller needs to set lr for flip center + constructor: -> + super + image: @image + x: 0 + y: 0 + scale: 2 + FlippableSprite = class extends Sprite + draw: -> + @flipped = @lr >= 0 + @x = (screen_x1 + @px + @lr) * 2 + @y = (screen_y1 + @py - 5) * 2 + super() + Vaquita = class extends FlippableSprite + constructor: -> + @lr = 18 + super() + draw: -> + if @vx < 0 + @lr = - 18 + else if @vx > 0 + @lr = 18 + super() + AiVaquita = class extends Vaquita + constructor: -> + @image = if Math.random() > 0.5 then pixyvaquita_105 else pixyvaquita + super() + draw: -> + vx = @vx + Math.floor(Math.random()*3) - 1 + vy = @vy + Math.floor(Math.random()*3) - 1 + x = @px + y = @py + rx = 0.5 * x / screen_x1 + ry = 0.5 * y / screen_y1 + if (s = vx * vx + vy * vy * 2) > 6 + vx = Math.round(vx * 0.9 - rx) + vy = Math.round(vy * 0.9 - ry) + @px += @vx = vx + @py += @vy = vy + super() + HeroVaquita = class extends Vaquita + twistleft = pixyvaquita_twistleft + constructor: -> + @image = pixyvaquita + @time = 0 + super() + draw: -> + @vx = (if jaws.pressed[leftKey] then -1 else 0) + (if jaws.pressed[rightKey] then 1 else 0) + @vy = (if jaws.pressed[upKey] then -1 else 0) + (if jaws.pressed[downKey] then 1 else 0) + @px += @vx + @py += @vy + if (@time++ % 3) is 0 + if @image is twistleft + @image = pixyvaquita + else if @vx isnt 0 + @image = twistleft + super() + addVaquita: -> + # n = v.cloneNode() + # n.setAttribute "opacity", "0.5" + # n.href.baseVal = "#_v105" if Math.random(0) > 0.5 + # n.setAttribute "transform", "" + # sea.appendChild n + angle = Math.random() * 6.28 + v = new AiVaquita + v.vx = 0 + v.vy = 0 + v.px = Math.floor(Math.sin(angle) * 300) + v.py = Math.floor(Math.cos(angle) * 300) + v.draw() + # vaquita.update() + @vaquitas.push v + constructor: (@vaquitas = [])-> + setup: -> + v = new HeroVaquita # jaws.Sprite x:screen_x1*2, y:screen_y1*2, scale:2, image:pixyvaquita + v.px = 0 + v.py = 0 + v.vx = 0 + v.vy = 0 + @vaquitas.push v + draw: -> + jaws.clear() + @addVaquita() if @vaquitas.length < 7 or jaws.pressed[spaceKey] + v.draw() for v in @vaquitas + if (@gameloop.ticks & 0xff) is 0xff + fps.innerHTML = " - #{@gameloop.fps} fps" + if true + jaws.init() + jaws.setupInput(); + game = new Demo + gameloop = new jaws.GameLoop(game, { fps:24 }) + (game.gameloop = gameloop).start() + else + jaws.start Demo, fps:25 - gameFrame = -> - if (time & 0xff) is 0x00 and vaquitas.length < 4 - addVaquita() - # s += 0.001 - x -= vx = pressedKeys[leftKey] - pressedKeys[rightKey] - y -= pressedKeys[upKey] - pressedKeys[downKey] - if vx > 0 - scaleX = 1 - else if vx < 0 - scaleX = -1 - v.setAttribute("transform", "translate(#{x}, #{y}) scale(#{scaleX}, #{scaleY})") - # # transform = v.transform.baseVal.getItem(0) - # transformMatrix.a = scaleX - # transformMatrix.e = x - # transformMatrix.f = y - if (time % 3) is 0 - if currentFrame.baseVal is "#twistleft" - currentFrame .baseVal = "#_" - else if vx isnt 0 - currentFrame.baseVal = "#twistleft" - # transformList.initialize(transform) - vq.update() for vq in vaquitas - time++ + # gameFrame = -> reportErrors -> + # if (time & 0xff) is 0x00 and vaquitas.length < 4 + # addVaquita() + # # s += 0.001 + # x -= vx = pressedKeys[leftKey] - pressedKeys[rightKey] + # y -= pressedKeys[upKey] - pressedKeys[downKey] + # if vx > 0 + # scaleX = 1 + # else if vx < 0 + # scaleX = -1 + # v.setAttribute("transform", "translate(#{x}, #{y}) scale(#{scaleX}, #{scaleY})") + # # transform = v.transform.baseVal.getItem(0) + # # transformMatrix.a = scaleX + # # transformMatrix.e = x + # # transformMatrix.f = y + # if (time % 3) is 0 + # if currentFrame.baseVal is "#twistleft" + # currentFrame .baseVal = "#_" + # else if vx isnt 0 + # currentFrame.baseVal = "#twistleft" + # # transformList.initialize(transform) + # vq.update() for vq in vaquitas + # time++ - setInterval gameFrame, 40 + # # setInterval gameFrame, 40 genPage() diff --git a/jaws-assets-named.coffee b/jaws-assets-named.coffee new file mode 100644 index 0000000..4a7a5df --- /dev/null +++ b/jaws-assets-named.coffee @@ -0,0 +1,456 @@ +# LGPL-licensed, please consult jawsjs.com +# conversion to coffeescript modification of src_assets.js from 'jawsjs.com' by Michele Bini + +# this supports named assets: like named:ImageName:image.png" + +jaws = ((jaws) -> + + ###* + @fileOverview jaws.assets properties and functions + + Loads and processes image, sound, video, and json assets + (Used internally by JawsJS to create <b>jaws.assets</b>) + + @class Jaws.Assets + @constructor + @property {boolean} bust_cache Add a random argument-string to assets-urls when loading to bypass any cache + @property {boolean} fuchia_to_transparent Convert the color fuchia to transparent when loading .bmp-files + @property {boolean} image_to_canvas Convert all image assets to canvas internally + @property {string} root Rootdir from where all assets are loaded + @property {array} file_type Listing of file postfixes and their associated types + @property {array} can_play Listing of postfixes and (during runtime) populated booleans + ### + + ###* + Returns the length of the resource list + @public + @returns {number} The length of the resource list + ### + + ###* + Set root prefix-path to all assets + + @example + jaws.assets.setRoot("music/").add(["music.mp3", "music.ogg"]).loadAll() + + @public + @param {string} path-prefix for all following assets + @returns {object} self + ### + + ###* + Get one or more resources from their URLs. Supports simple wildcard (you can end a string with "*"). + + @example + jaws.assets.add(["song.mp3", "song.ogg"]) + jaws.assets.get("song.*") // -> Will return song.ogg in firefox and song.mp3 in IE + + @public + @param {string|array} src The resource(s) to retrieve + @returns {array|object} Array or single resource if found in cache. Undefined otherwise. + ### + + # Wildcard? song.*, match against asset-srcs, make sure it's loaded and return content of first match. + + # TODO: self.loaded[src] is false for supported files for some odd reason. + + ###* + Returns if specified resource is currently loading or not + @public + @param {string} src Resource URL + @return {boolean|undefined} If resource is currently loading. Otherwise, undefined. + ### + + ###* + Returns if specified resource is loaded or not + @param src Source URL + @return {boolean|undefined} If specified resource is loaded or not. Otherwise, undefined. + ### + + ###* + Returns lowercase postfix of specified resource + @public + @param {string} src Resource URL + @returns {string} Lowercase postfix of resource + ### + + ###* + Determine type of file (Image, Audio, or Video) from its postfix + @private + @param {string} src Resource URL + @returns {string} Matching type {Image, Audio, Video} or the postfix itself + ### + + ###* + Add URL(s) to asset listing for later loading + @public + @param {string|array|arguments} src The resource URL(s) to add to the asset listing + @example + jaws.assets.add("player.png") + jaws.assets.add(["media/bullet1.png", "media/bullet2.png"]) + jaws.assets.add("foo.png", "bar.png") + jaws.assets.loadAll({onload: start_game}) + ### + + ###* + Iterate through the list of resource URL(s) and load each in turn. + @public + @param {Object} options Object-literal of callback functions + @config {function} [options.onprogress] The function to be called on progress (when one assets of many is loaded) + @config {function} [options.onerror] The function to be called if an error occurs + @config {function} [options.onload] The function to be called when finished + ### + + ###* + Loads a single resource from its given URL + Will attempt to match a resource to known MIME types. + If unknown, loads the file as a blob-object. + + @public + @param {string} src Resource URL + @param {Object} options Object-literal of callback functions + @config {function} [options.onload] Function to be called when assets has loaded + @config {function} [options.onerror] Function to be called if an error occurs + @example + jaws.load("media/foo.png") + jaws.load("http://place.tld/foo.png") + ### + # NOTE: assetLoaded can be called several times during loading. + + #Load everything else as raw blobs... + + # ... But don't load un-supported audio-files. + + # Initial loading callback for all assets for parsing specific filetypes or + # optionally converting images to canvas-objects. + # @private + # @param {EventObject} event The EventObject populated by the calling event + # @see processCallbacks() + + # + # * Only increment load_count ONCE per unique asset. + # * This is needed cause assetLoaded-callback can in certain cases be called several for a single asset... + # * ..and not only Once when it's loaded. + # + + # Called when jaws asset-handler decides that an asset shouldn't be loaded + # For example, an unsupported audio-format won't be loaded. + + # @private + + # Increases the error count and calls processCallbacks with false flag set + # @see processCallbacks() + # @private + # @param {EventObject} event The EventObject populated by the calling event + + # Processes (if set) the callbacks per resource + # @private + # @param {object} asset The asset to be processed + # @param {boolean} ok If an error has occured with the asset loading + # @param {EventObject} event The EventObject populated by the calling event + # @see jaws.start() in core.js + + # Displays the progress of asset handling as an overall percentage of all loading + # (Can be overridden as jaws.assets.displayProgress = function(percent_done) {}) + # @public + # @param {number} percent_done The overall percentage done across all resource handling + + # Make Fuchia (0xFF00FF) transparent (BMPs ONLY) + # @private + # @param {HTMLImageElement} image The Bitmap Image to convert + # @returns {CanvasElement} canvas The translated CanvasElement + + fuchiaToTransparent = (image) -> + return unless jaws.isDrawable(image) + canvas = (if jaws.isImage(image) then jaws.imageToCanvas(image) else image) + context = canvas.getContext("2d") + img_data = context.getImageData(0, 0, canvas.width, canvas.height) + pixels = img_data.data + i = 0 + + while i < pixels.length + # Color: Fuchia + pixels[i + 3] = 0 if pixels[i] is 255 and pixels[i + 1] is 0 and pixels[i + 2] is 255 # Set total see-through transparency + i += 4 + context.putImageData img_data, 0, 0 + canvas + jaws.Assets = Assets = -> + getType = (src) -> + if jaws.isString(src) + postfix = self.getPostfix(src) + (if self.file_type[postfix] then self.file_type[postfix] else postfix) + else + jaws.log.error "jaws.assets.getType: Argument not a String with " + src + return + assetLoaded = (event) -> + asset = @asset + src = asset.src + filetype = getType(asset.src) + try + if filetype is "json" + return if @readyState isnt 4 + self.data[asset.src] = JSON.parse(@responseText) + else if filetype is "image" + new_image = (if self.image_to_canvas then jaws.imageToCanvas(asset.image) else asset.image) + new_image = fuchiaToTransparent(new_image) if self.fuchia_to_transparent and self.getPostfix(asset.src) is "bmp" + self.data[asset.src] = new_image + else if filetype is "audio" and self.can_play[self.getPostfix(asset.src)] + self.data[asset.src] = asset.audio + else if filetype is "video" and self.can_play[self.getPostfix(asset.src)] + self.data[asset.src] = asset.video + else + self.data[asset.src] = @response + catch e + jaws.log.error "Cannot process " + src + " (Message: " + e.message + ", Name: " + e.name + ")" + self.data[asset.src] = null + self.load_count++ unless self.loaded[src] + self.loaded[src] = true + self.loading[src] = false + processCallbacks asset, true, event + return + assetSkipped = (asset) -> + self.loaded[asset.src] = true + self.loading[asset.src] = false + self.load_count++ + processCallbacks asset, true + return + assetError = (event) -> + asset = @asset + self.error_count++ + processCallbacks asset, false, event + return + processCallbacks = (asset, ok, event) -> + percent = parseInt((self.load_count + self.error_count) / self.src_list.length * 100) + if ok + self.onprogress asset.src, percent if self.onprogress + asset.onprogress event if asset.onprogress and event isnt `undefined` + else + self.onerror asset.src, percent if self.onerror + asset.onerror event if asset.onerror and event isnt `undefined` + if percent is 100 + self.onload() if self.onload + self.onprogress = null + self.onerror = null + self.onload = null + return + return new arguments.callee() unless this instanceof arguments.callee + self = this + self.loaded = [] + self.loading = [] + self.src_list = [] + self.data = [] + self.bust_cache = false + self.image_to_canvas = true + self.fuchia_to_transparent = true + self.root = "" + self.file_type = {} + self.file_type["json"] = "json" + self.file_type["wav"] = "audio" + self.file_type["mp3"] = "audio" + self.file_type["ogg"] = "audio" + self.file_type["m4a"] = "audio" + self.file_type["weba"] = "audio" + self.file_type["aac"] = "audio" + self.file_type["mka"] = "audio" + self.file_type["flac"] = "audio" + self.file_type["png"] = "image" + self.file_type["jpg"] = "image" + self.file_type["jpeg"] = "image" + self.file_type["gif"] = "image" + self.file_type["bmp"] = "image" + self.file_type["tiff"] = "image" + self.file_type["mp4"] = "video" + self.file_type["webm"] = "video" + self.file_type["ogv"] = "video" + self.file_type["mkv"] = "video" + self.can_play = {} + try + audioTest = new Audio() + self.can_play["wav"] = !!audioTest.canPlayType("audio/wav; codecs=\"1\"").replace(/^no$/, "") + self.can_play["ogg"] = !!audioTest.canPlayType("audio/ogg; codecs=\"vorbis\"").replace(/^no$/, "") + self.can_play["mp3"] = !!audioTest.canPlayType("audio/mpeg;").replace(/^no$/, "") + self.can_play["m4a"] = !!(audioTest.canPlayType("audio/x-m4a;") or audioTest.canPlayType("audio/aac;")).replace(/^no$/, "") + self.can_play["weba"] = !!audioTest.canPlayType("audio/webm; codecs=\"vorbis\"").replace(/^no$/, "") + self.can_play["aac"] = !!audioTest.canPlayType("audio/aac;").replace(/^no$/, "") + self.can_play["mka"] = !!audioTest.canPlayType("audio/x-matroska;").replace(/^no$/, "") + self.can_play["flac"] = !!audioTest.canPlayType("audio/x-flac;").replace(/^no$/, "") + try + videoTest = document.createElement("video") + self.can_play["mp4"] = !!videoTest.canPlayType("video/mp4;").replace(/^no$/, "") + self.can_play["webm"] = !!videoTest.canPlayType("video/webm; codecs=\"vorbis\"").replace(/^no$/, "") + self.can_play["ogv"] = !!videoTest.canPlayType("video/ogg; codecs=\"vorbis\"").replace(/^no$/, "") + self.can_play["mkv"] = !!videoTest.canPlayType("video/x-matroska;").replace(/^no$/, "") + self.length = -> + self.src_list.length + + self.setRoot = (path) -> + self.root = path + self + + self.get = (src) -> + if jaws.isArray(src) + src.map (i) -> + self.data[i] + + else if jaws.isString(src) + if src[src.length - 1] is "*" + needle = src.replace("*", "") + i = 0 + + while i < self.src_list.length + return self.data[self.src_list[i]] if self.src_list[i].indexOf(needle) is 0 and self.data[self.src_list[i]] + i++ + if self.data[src] + self.data[src] + else + jaws.log.warn "No such asset: " + src, true + else + jaws.log.error "jaws.get: Neither String nor Array. Incorrect URL resource " + src + return + return + + self.isLoading = (src) -> + if jaws.isString(src) + self.loading[src] + else + jaws.log.error "jaws.isLoading: Argument not a String with " + src + return + + self.isLoaded = (src) -> + if jaws.isString(src) + self.loaded[src] + else + jaws.log.error "jaws.isLoaded: Argument not a String with " + src + return + + self.getPostfix = (src) -> + if jaws.isString(src) + src.toLowerCase().match(/.+\.([^?]+)(\?|$)/)[1] + else + jaws.log.error "jaws.assets.getPostfix: Argument not a String with " + src + return + + self.add = (src) -> + list = arguments + list = list[0] if list.length is 1 and jaws.isArray(list[0]) + i = 0 + + while i < list.length + if jaws.isArray(list[i]) + self.add list[i] + else + if jaws.isString(list[i]) + self.src_list.push list[i] + else + jaws.log.error "jaws.assets.add: Neither String nor Array. Incorrect URL resource " + src + i++ + self + + self.loadAll = (options) -> + self.load_count = 0 + self.error_count = 0 + self.onprogress = options.onprogress if options.onprogress and jaws.isFunction(options.onprogress) + self.onerror = options.onerror if options.onerror and jaws.isFunction(options.onerror) + self.onload = options.onload if options.onload and jaws.isFunction(options.onload) + self.src_list.forEach (item) -> + self.load item + return + + self + + self.load = (src, options) -> + options = {} unless options + unless jaws.isString(src) + jaws.log.error "jaws.assets.load: Argument not a String with " + src + return + asset = {} + resolved_src = "" + if parts =/^named:([^:]+):/.exec src + asset.name = parts[1] + src = src.substring parts[0].length + asset.src = src + asset.onload = options.onload + asset.onerror = options.onerror + self.loading[src] = true + parser = RegExp("^((f|ht)tp(s)?:)?//") + if /^[a-z][a-z0-9-]*:/.test(src) + resolved_src = asset.src + else + resolved_src = self.root + asset.src + resolved_src += "?" + parseInt(Math.random() * 10000000) if self.bust_cache + type = getType(asset.src) + if type is "image" + try + asset.image = new Image() + asset.image.asset = asset + asset.image.addEventListener "load", assetLoaded + asset.image.addEventListener "error", assetError + asset.image.src = resolved_src + catch e + jaws.log.error "Cannot load Image resource " + resolved_src + " (Message: " + e.message + ", Name: " + e.name + ")" + else if self.can_play[self.getPostfix(asset.src)] + if type is "audio" + try + asset.audio = new Audio() + asset.audio.asset = asset + asset.audio.addEventListener "error", assetError + asset.audio.addEventListener "canplay", assetLoaded + self.data[asset.src] = asset.audio + asset.audio.src = resolved_src + asset.audio.load() + catch e + jaws.log.error "Cannot load Audio resource " + resolved_src + " (Message: " + e.message + ", Name: " + e.name + ")" + else if type is "video" + try + asset.video = document.createElement("video") + asset.video.asset = asset + self.data[asset.src] = asset.video + asset.video.setAttribute "style", "display:none;" + asset.video.addEventListener "error", assetError + asset.video.addEventListener "canplay", assetLoaded + document.body.appendChild asset.video + asset.video.src = resolved_src + asset.video.load() + catch e + jaws.log.error "Cannot load Video resource " + resolved_src + " (Message: " + e.message + ", Name: " + e.name + ")" + else + if type is "audio" and not self.can_play[self.getPostfix(asset.src)] + assetSkipped asset + return self + try + req = new XMLHttpRequest() + req.asset = asset + req.onreadystatechange = assetLoaded + req.onerror = assetError + req.open "GET", resolved_src, true + req.responseType = "blob" if type isnt "json" + req.send null + catch e + jaws.log.error "Cannot load " + resolved_src + " (Message: " + e.message + ", Name: " + e.name + ")" + self + + self.displayProgress = (percent_done) -> + return unless jaws.isNumber(percent_done) + return unless jaws.context + jaws.context.save() + jaws.context.fillStyle = "black" + jaws.context.fillRect 0, 0, jaws.width, jaws.height + jaws.context.fillStyle = "white" + jaws.context.strokeStyle = "white" + jaws.context.textAlign = "center" + jaws.context.strokeRect 50 - 1, (jaws.height / 2) - 30 - 1, jaws.width - 100 + 2, 60 + 2 + jaws.context.fillRect 50, (jaws.height / 2) - 30, ((jaws.width - 100) / 100) * percent_done, 60 + jaws.context.font = "11px verdana" + jaws.context.fillText "Loading... " + percent_done + "%", jaws.width / 2, jaws.height / 2 - 35 + jaws.context.font = "11px verdana" + jaws.context.fillStyle = "#ccc" + jaws.context.textBaseline = "bottom" + jaws.context.fillText "powered by www.jawsjs.com", jaws.width / 2, jaws.height - 1 + jaws.context.restore() + return + + return + + jaws.assets = new jaws.Assets() + jaws +)(jaws or {}) diff --git a/jaws/jaws-min.js b/jaws/jaws-min.js index 82c1680..79fe719 100644..100755 --- a/jaws/jaws-min.js +++ b/jaws/jaws-min.js @@ -1,2 +1,2 @@ -var jaws=function(t){function e(e){t.mouse_x=e.pageX||e.clientX,t.mouse_y=e.pageY||e.clientY;var i=t.canvas?t.canvas:t.dom;t.mouse_x-=i.offsetLeft,t.mouse_y-=i.offsetTop}var i,s;return t.SpriteList=function(){throw"To use SpriteList() you need to include src/extras/sprite_list.js"},t.Audio=function(){throw"To use jaws.Audio() you need to include src/extras/audio.js"},t.title=function(e){return t.isString(e)?e?i.innerHTML=e:i.innerHTML:void t.log.error("jaws.title: Passed in value is not a String.")},t.unpack=function(){var e=["Sprite","SpriteList","Animation","SpriteSheet","Parallax","pressed","QuadTree"];e.forEach(function(e){window[e]?t.log.warn("jaws.unpack: "+e+" already exists in global namespace."):window[e]=t[e]})},t.log=function(e,i){t.isString(e)||(e=JSON.stringify(e)),t.log.on&&(s&&t.log.use_log_element&&(i?s.innerHTML+=e+"<br />":s.innerHTML=e),console.log&&t.log.use_console&&console.log("JawsJS: ",e))},t.log.on=!0,t.log.use_console=!1,t.log.use_log_element=!0,t.log.warn=function(e){console.warn&&t.log.use_console&&t.log.on?console.warn(e):t.log("[WARNING]: "+JSON.stringify(e),!0)},t.log.error=function(e){console.error&&t.log.use_console&&t.log.on?console.error(e):t.log("[ERROR]: "+JSON.stringify(e),!0)},t.log.info=function(e){console.info&&t.log.use_console&&t.log.on?console.info(e):t.log("[INFO]: "+JSON.stringify(e),!0)},t.log.debug=function(e){console.debug&&t.log.use_console&&t.log.on?console.debug(e):t.log("[DEBUG]: "+JSON.stringify(e),!0)},t.log.clear=function(){s&&(s.innerHTML=""),console.clear&&console.clear()},t.init=function(o){i=document.getElementsByTagName("title")[0],t.url_parameters=t.getUrlParameters(),t.canvas=document.getElementsByTagName("canvas")[0],t.canvas||(t.dom=document.getElementById("canvas")),t.canvas?t.context=t.canvas.getContext("2d"):t.dom?t.dom.style.position="relative":(t.canvas=document.createElement("canvas"),t.canvas.width=o.width,t.canvas.height=o.height,t.context=t.canvas.getContext("2d"),document.body.appendChild(t.canvas)),s=document.getElementById("jaws-log"),t.url_parameters.debug&&(s||(s=document.createElement("div"),s.id="jaws-log",s.style.cssText="overflow: auto; color: #aaaaaa; width: 300px; height: 150px; margin: 40px auto 0px auto; padding: 5px; border: #444444 1px solid; clear: both; font: 10px verdana; text-align: left;",document.body.appendChild(s))),t.url_parameters.bust_cache&&(t.log.info("Busting cache when loading assets"),t.assets.bust_cache=!0),t.context&&t.useCrispScaling(),t.width=t.canvas?t.canvas.width:t.dom.offsetWidth,t.height=t.canvas?t.canvas.height:t.dom.offsetHeight,t.mouse_x=0,t.mouse_y=0,window.addEventListener("mousemove",e)},t.useCrispScaling=function(){t.context.imageSmoothingEnabled=!1,t.context.webkitImageSmoothingEnabled=!1,t.context.mozImageSmoothingEnabled=!1},t.useSmoothScaling=function(){t.context.imageSmoothingEnabled=!0,t.context.webkitImageSmoothingEnabled=!0,t.context.mozImageSmoothingEnabled=!0},t.start=function(e,i,s){function o(e,s){t.log.info(s+"%: "+e,!0),i.loading_screen&&t.assets.displayProgress(s)}function n(e,i){t.log.info(i+"%: Error loading asset "+e,!0)}function a(){t.log.info("all assets loaded",!0),t.switchGameState(e||window,{fps:r},s)}i||(i={});var r=i.fps||60;return void 0===i.loading_screen&&(i.loading_screen=!0),i.width||(i.width=500),i.height||(i.height=300),t.init(i),t.isFunction(e)||t.isObject(e)?t.isObject(s)||void 0===s?(i.loading_screen&&t.assets.displayProgress(0),t.log.info("setupInput()",!0),t.setupInput(),t.log.info("assets.loadAll()",!0),void(t.assets.length()>0?t.assets.loadAll({onprogress:o,onerror:n,onload:a}):a())):void t.log.error("jaws.start: The setup options for the game state is not an object."):void t.log.error("jaws.start: Passed in GameState is niether function or object")},t.switchGameState=function(e,i,s){if(void 0===i&&(i={}),t.isFunction(e)&&(e=new e),!t.isObject(e))return void t.log.error("jaws.switchGameState: Passed in GameState should be a Function or an Object.");var o=i&&i.fps||t.game_loop&&t.game_loop.fps||60,n=i.setup;t.game_loop&&t.game_loop.stop(),t.clearKeyCallbacks(),t.previous_game_state=t.game_state,t.game_state=e,t.game_loop=new t.GameLoop(e,{fps:o,setup:n},s),t.game_loop.start()},t.imageToCanvas=function(e){if(t.isCanvas(e))return e;if(!t.isImage(e))return void t.log.error("jaws.imageToCanvas: Passed in object is not an Image.");var i=document.createElement("canvas");i.src=e.src,i.width=e.width,i.height=e.height;var s=i.getContext("2d");return s.drawImage(e,0,0,e.width,e.height),i},t.forceArray=function(t){return Array.isArray(t)?t:[t]},t.clear=function(){t.context.clearRect(0,0,t.width,t.height)},t.fill=function(e){t.context.fillStyle=e,t.context.fillRect(0,0,t.width,t.height)},t.draw=function(){var e=arguments;1==e.length&&t.isArray(e[0])&&(e=e[0]);for(var i=0;i<e.length;i++)t.isArray(e[i])?t.draw(e[i]):e[i].draw&&e[i].draw()},t.update=function(){var e=arguments;1==e.length&&t.isArray(e[0])&&(e=e[0]);for(var i=0;i<e.length;i++)t.isArray(e[i])?t.update(e[i]):e[i].update&&e[i].update()},t.isImage=function(t){return"[object HTMLImageElement]"===Object.prototype.toString.call(t)},t.isCanvas=function(t){return"[object HTMLCanvasElement]"===Object.prototype.toString.call(t)},t.isDrawable=function(e){return t.isImage(e)||t.isCanvas(e)},t.isString=function(t){return"string"==typeof t||"object"==typeof t&&t.constructor===String},t.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},t.isArray=function(t){return t?!(-1===t.constructor.toString().indexOf("Array")):!1},t.isObject=function(t){return null!==t&&"object"==typeof t},t.isFunction=function(t){return"[object Function]"===Object.prototype.toString.call(t)},t.isRegExp=function(t){return t instanceof RegExp},t.isOutsideCanvas=function(e){return e.x&&e.y?e.x<0||e.y<0||e.x>t.width||e.y>t.height:void 0},t.forceInsideCanvas=function(e){e.x&&e.y&&(e.x<0&&(e.x=0),e.x>t.width&&(e.x=t.width),e.y<0&&(e.y=0),e.y>t.height&&(e.y=t.height))},t.getUrlParameters=function(){for(var t,e=[],i=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),s=0;s<i.length;s++)t=i[s].split("="),e.push(t[0]),e[t[0]]=t[1];return e},t.parseOptions=function(e,i,s){e.options=i;for(var o in i)void 0===s[o]&&t.log.warn("jaws.parseOptions: Unsupported property "+o+"for "+e.constructor);for(var o in s)t.isFunction(s[o])&&(s[o]=s[o]()),e[o]=void 0!==i[o]?i[o]:t.clone(s[o])},t.clone=function(e){return t.isArray(e)?e.slice(0):t.isObject(e)?JSON.parse(JSON.stringify(e)):e},t.imageToCanvasContext=function(e){var i=document.createElement("canvas");i.width=e.width,i.height=e.height;var s=i.getContext("2d");return t.context&&(s.imageSmoothingEnabled=t.context.mozImageSmoothingEnabled,s.webkitImageSmoothingEnabled=t.context.mozImageSmoothingEnabled,s.mozImageSmoothingEnabled=t.context.mozImageSmoothingEnabled),s.drawImage(e,0,0,i.width,i.height),s},t.retroScaleImage=function(e,i){var s=t.isImage(e)?t.imageToCanvas(e):e,o=s.getContext("2d"),n=o.getImageData(0,0,s.width,s.height).data,a=document.createElement("canvas");a.width=e.width*i,a.height=e.height*i;for(var r=a.getContext("2d"),h=r.createImageData(a.width,a.height),c=h.width,l=h.height,u=0;l>u;u+=1)for(var d=Math.floor(u/i),f=u*h.width,p=d*e.width,g=0;c>g;g+=1){var m=Math.floor(g/i),w=4*(f+g),y=4*(p+m);h.data[w]=n[y],h.data[w+1]=n[y+1],h.data[w+2]=n[y+2],h.data[w+3]=n[y+3]}return r.putImageData(h,0,0),a},t}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws);var jaws=function(t){function e(){h={}}function i(t){event=t?t:window.event;var e=l[event.keyCode];null!=e&&(e=e.split(" "),e.forEach(function(e){h[e]=!1,d[e]&&(d[e](e),t.preventDefault()),g[e]&&t.preventDefault()}))}function s(t){event=t?t:window.event;var e=l[event.keyCode];null!=e&&(e=e.split(" "),e.forEach(function(e){h[e]=!0,u[e]&&(u[e](e),t.preventDefault()),g[e]&&t.preventDefault()}))}function o(t){event=t?t:window.event;var e=f[event.button];"Microsoft Internet Explorer"==navigator.appName&&(e=p[event.button]),h[e]=!0,u[e]&&(u[e](e),t.preventDefault())}function n(t){event=t?t:window.event;var e=f[event.button];"Microsoft Internet Explorer"==navigator.appName&&(e=p[event.button]),h[e]=!1,d[e]&&(d[e](e),t.preventDefault())}function a(e){event=e?e:window.event,h.left_mouse_button=!0,t.mouse_x=e.touches[0].pageX-t.canvas.offsetLeft,t.mouse_y=e.touches[0].pageY-t.canvas.offsetTop}function r(e){event=e?e:window.event,h.left_mouse_button=!1,t.mouse_x=void 0,t.mouse_y=void 0}var h={},c={},l=[],u=[],d=[],f=[],p=[];t.setupInput=function(){var h=[];h[8]="backspace",h[9]="tab",h[13]="enter",h[16]="shift",h[17]="ctrl",h[18]="alt",h[19]="pause",h[20]="capslock",h[27]="esc",h[32]="space",h[33]="pageup",h[34]="pagedown",h[35]="end",h[36]="home",h[37]="left",h[38]="up",h[39]="right",h[40]="down",h[45]="insert",h[46]="delete",h[91]="left_window_key leftwindowkey",h[92]="right_window_key rightwindowkey",h[93]="select_key selectkey",h[106]="multiply *",h[107]="add plus +",h[109]="subtract minus -",h[110]="decimalpoint",h[111]="divide /",h[144]="numlock",h[145]="scrollock",h[186]="semicolon ;",h[187]="equalsign =",h[188]="comma ,",h[189]="dash -",h[190]="period .",h[191]="forwardslash /",h[192]="graveaccent `",h[219]="openbracket [",h[220]="backslash \\",h[221]="closebracket ]",h[222]="singlequote '";var c=[];c[0]="left_mouse_button",c[1]="center_mouse_button",c[2]="right_mouse_button";var u=[];u[1]="left_mouse_button",u[2]="right_mouse_button",u[4]="center_mouse_button",f=c,p=u;for(var d=["numpad0","numpad1","numpad2","numpad3","numpad4","numpad5","numpad6","numpad7","numpad8","numpad9"],g=["f1","f2","f3","f4","f5","f6","f7","f8","f9"],m=["0","1","2","3","4","5","6","7","8","9"],w=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],y=0;m[y];y++)h[48+y]=m[y];for(var y=0;w[y];y++)h[65+y]=w[y];for(var y=0;d[y];y++)h[96+y]=d[y];for(var y=0;g[y];y++)h[112+y]=g[y];l=h,window.addEventListener("keydown",s),window.addEventListener("keyup",i);var x=t.canvas||t.dom;x.addEventListener("mousedown",o,!1),x.addEventListener("mouseup",n,!1),x.addEventListener("touchstart",a,!1),x.addEventListener("touchend",r,!1),window.addEventListener("blur",e,!1),document.oncontextmenu=function(){return!1}};var g=[];return t.preventDefaultKeys=function(){var e=arguments;1==e.length&&t.isArray(e[0])&&(e=e[0]);for(var i=0;i<e.length;i++)g[e[i]]=!0},t.pressed=function(e,i){return t.isString(e)&&(e=e.split(" ")),i?e.every(function(t){return h[t]}):e.some(function(t){return h[t]})},t.pressedWithoutRepeat=function(e,i){return t.pressed(e,i)?c[e]?void 0:(c[e]=!0,!0):(c[e]=!1,!1)},t.on_keydown=function(e,i){if(t.isArray(e))for(var s=0;e[s];s++)u[e[s]]=i;else u[e]=i},t.on_keyup=function(e,i){if(t.isArray(e))for(var s=0;e[s];s++)d[e[s]]=i;else d[e]=i},t.clearKeyCallbacks=function(){d=[],u=[]},t}(jaws||{}),jaws=function(t){function e(e){if(t.isDrawable(e)){for(var i=t.isImage(e)?t.imageToCanvas(e):e,s=i.getContext("2d"),o=s.getImageData(0,0,i.width,i.height),n=o.data,a=0;a<n.length;a+=4)255===n[a]&&0===n[a+1]&&255===n[a+2]&&(n[a+3]=0);return s.putImageData(o,0,0),i}}return t.Assets=function(){function i(e){if(t.isString(e)){var i=r.getPostfix(e);return r.file_type[i]?r.file_type[i]:i}t.log.error("jaws.assets.getType: Argument not a String with "+e)}function s(s){var o=this.asset,n=o.src,h=i(o.src);try{if("json"===h){if(4!==this.readyState)return;r.data[o.src]=JSON.parse(this.responseText)}else if("image"===h){var c=r.image_to_canvas?t.imageToCanvas(o.image):o.image;r.fuchia_to_transparent&&"bmp"===r.getPostfix(o.src)&&(c=e(c)),r.data[o.src]=c}else r.data[o.src]="audio"===h&&r.can_play[r.getPostfix(o.src)]?o.audio:"video"===h&&r.can_play[r.getPostfix(o.src)]?o.video:this.response}catch(l){t.log.error("Cannot process "+n+" (Message: "+l.message+", Name: "+l.name+")"),r.data[o.src]=null}r.loaded[n]||r.load_count++,r.loaded[n]=!0,r.loading[n]=!1,a(o,!0,s)}function o(t){r.loaded[t.src]=!0,r.loading[t.src]=!1,r.load_count++,a(t,!0)}function n(t){var e=this.asset;r.error_count++,a(e,!1,t)}function a(t,e,i){var s=parseInt((r.load_count+r.error_count)/r.src_list.length*100);e?(r.onprogress&&r.onprogress(t.src,s),t.onprogress&&void 0!==i&&t.onprogress(i)):(r.onerror&&r.onerror(t.src,s),t.onerror&&void 0!==i&&t.onerror(i)),100===s&&(r.onload&&r.onload(),r.onprogress=null,r.onerror=null,r.onload=null)}if(!(this instanceof arguments.callee))return new arguments.callee;var r=this;r.loaded=[],r.loading=[],r.src_list=[],r.data=[],r.bust_cache=!1,r.image_to_canvas=!0,r.fuchia_to_transparent=!0,r.root="",r.file_type={},r.file_type.json="json",r.file_type.wav="audio",r.file_type.mp3="audio",r.file_type.ogg="audio",r.file_type.m4a="audio",r.file_type.weba="audio",r.file_type.aac="audio",r.file_type.mka="audio",r.file_type.flac="audio",r.file_type.png="image",r.file_type.jpg="image",r.file_type.jpeg="image",r.file_type.gif="image",r.file_type.bmp="image",r.file_type.tiff="image",r.file_type.mp4="video",r.file_type.webm="video",r.file_type.ogv="video",r.file_type.mkv="video",r.can_play={};try{var h=new Audio;r.can_play.wav=!!h.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),r.can_play.ogg=!!h.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),r.can_play.mp3=!!h.canPlayType("audio/mpeg;").replace(/^no$/,""),r.can_play.m4a=!!(h.canPlayType("audio/x-m4a;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),r.can_play.weba=!!h.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,""),r.can_play.aac=!!h.canPlayType("audio/aac;").replace(/^no$/,""),r.can_play.mka=!!h.canPlayType("audio/x-matroska;").replace(/^no$/,""),r.can_play.flac=!!h.canPlayType("audio/x-flac;").replace(/^no$/,"")}catch(c){}try{var l=document.createElement("video");r.can_play.mp4=!!l.canPlayType("video/mp4;").replace(/^no$/,""),r.can_play.webm=!!l.canPlayType('video/webm; codecs="vorbis"').replace(/^no$/,""),r.can_play.ogv=!!l.canPlayType('video/ogg; codecs="vorbis"').replace(/^no$/,""),r.can_play.mkv=!!l.canPlayType("video/x-matroska;").replace(/^no$/,"")}catch(c){}r.length=function(){return r.src_list.length},r.setRoot=function(t){return r.root=t,r},r.get=function(e){if(t.isArray(e))return e.map(function(t){return r.data[t]});if(!t.isString(e))return void t.log.error("jaws.get: Neither String nor Array. Incorrect URL resource "+e);if("*"===e[e.length-1])for(var i=e.replace("*",""),s=0;s<r.src_list.length;s++)if(0==r.src_list[s].indexOf(i)&&r.data[r.src_list[s]])return r.data[r.src_list[s]];return r.data[e]?r.data[e]:void t.log.warn("No such asset: "+e,!0)},r.isLoading=function(e){return t.isString(e)?r.loading[e]:void t.log.error("jaws.isLoading: Argument not a String with "+e)},r.isLoaded=function(e){return t.isString(e)?r.loaded[e]:void t.log.error("jaws.isLoaded: Argument not a String with "+e)},r.getPostfix=function(e){return t.isString(e)?e.toLowerCase().match(/.+\.([^?]+)(\?|$)/)[1]:void t.log.error("jaws.assets.getPostfix: Argument not a String with "+e)},r.add=function(e){var i=arguments;1==i.length&&t.isArray(i[0])&&(i=i[0]);for(var s=0;s<i.length;s++)t.isArray(i[s])?r.add(i[s]):t.isString(i[s])?r.src_list.push(i[s]):t.log.error("jaws.assets.add: Neither String nor Array. Incorrect URL resource "+e);return r},r.loadAll=function(e){return r.load_count=0,r.error_count=0,e.onprogress&&t.isFunction(e.onprogress)&&(r.onprogress=e.onprogress),e.onerror&&t.isFunction(e.onerror)&&(r.onerror=e.onerror),e.onload&&t.isFunction(e.onload)&&(r.onload=e.onload),r.src_list.forEach(function(t){r.load(t)}),r},r.load=function(e,a){if(a||(a={}),!t.isString(e))return void t.log.error("jaws.assets.load: Argument not a String with "+e);var h={},c="";h.src=e,h.onload=a.onload,h.onerror=a.onerror,r.loading[e]=!0;var l=RegExp("^((f|ht)tp(s)?:)?//");c=l.test(e)?h.src:r.root+h.src,r.bust_cache&&(c+="?"+parseInt(1e7*Math.random()));var u=i(h.src);if("image"===u)try{h.image=new Image,h.image.asset=h,h.image.addEventListener("load",s),h.image.addEventListener("error",n),h.image.src=c}catch(d){t.log.error("Cannot load Image resource "+c+" (Message: "+d.message+", Name: "+d.name+")")}else if(r.can_play[r.getPostfix(h.src)]){if("audio"===u)try{h.audio=new Audio,h.audio.asset=h,h.audio.addEventListener("error",n),h.audio.addEventListener("canplay",s),r.data[h.src]=h.audio,h.audio.src=c,h.audio.load()}catch(d){t.log.error("Cannot load Audio resource "+c+" (Message: "+d.message+", Name: "+d.name+")")}else if("video"===u)try{h.video=document.createElement("video"),h.video.asset=h,r.data[h.src]=h.video,h.video.setAttribute("style","display:none;"),h.video.addEventListener("error",n),h.video.addEventListener("canplay",s),document.body.appendChild(h.video),h.video.src=c,h.video.load()}catch(d){t.log.error("Cannot load Video resource "+c+" (Message: "+d.message+", Name: "+d.name+")")}}else{if("audio"===u&&!r.can_play[r.getPostfix(h.src)])return o(h),r;try{var f=new XMLHttpRequest;f.asset=h,f.onreadystatechange=s,f.onerror=n,f.open("GET",c,!0),"json"!==u&&(f.responseType="blob"),f.send(null)}catch(d){t.log.error("Cannot load "+c+" (Message: "+d.message+", Name: "+d.name+")")}}return r},r.displayProgress=function(e){t.isNumber(e)&&t.context&&(t.context.save(),t.context.fillStyle="black",t.context.fillRect(0,0,t.width,t.height),t.context.fillStyle="white",t.context.strokeStyle="white",t.context.textAlign="center",t.context.strokeRect(49,t.height/2-30-1,t.width-100+2,62),t.context.fillRect(50,t.height/2-30,(t.width-100)/100*e,60),t.context.font="11px verdana",t.context.fillText("Loading... "+e+"%",t.width/2,t.height/2-35),t.context.font="11px verdana",t.context.fillStyle="#ccc",t.context.textBaseline="bottom",t.context.fillText("powered by www.jawsjs.com",t.width/2,t.height-1),t.context.restore())}},t.assets=new t.Assets,t}(jaws||{});if("undefined"!=typeof require)var jaws=require("./core.js");var jaws=function(t){function e(t){this.size=t,this.values=new Array(this.size),this.value,this.add=function(t){if(this.values.length>this.size){this.values.splice(0,1),this.value=0;for(var e=0;this.values[e];e++)this.value+=this.values[e];this.value=this.value/this.size}return this.values.push(t),this},this.get=function(){return parseInt(this.value)}}return window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,16.666)}}(),t.GameLoop=function(i,s,o){if(!(this instanceof arguments.callee))return new arguments.callee(i,s);this.tick_duration=0,this.fps=0,this.ticks=0;var n,a=!1,r=!1,h=this,c=new e(20);this.runtime=function(){return this.last_tick-this.first_tick},this.start=function(){t.log.info("Game loop start",!0),this.first_tick=(new Date).getTime(),this.current_tick=(new Date).getTime(),this.last_tick=(new Date).getTime(),s.setup!==!1&&i.setup&&i.setup(o),step_delay=1e3/s.fps,60==s.fps?requestAnimFrame(this.loop):n=setInterval(this.loop,step_delay)},this.loop=function(){h.current_tick=(new Date).getTime(),h.tick_duration=h.current_tick-h.last_tick,h.fps=c.add(1e3/h.tick_duration).get(),r||a||(i.update&&i.update(),i.draw&&i.draw(),h.ticks++),60!=s.fps||r||requestAnimFrame(h.loop),h.last_tick=h.current_tick},this.pause=function(){a=!0},this.unpause=function(){a=!1},this.stop=function(){n&&clearInterval(n),r=!0}},t}(jaws||{}),jaws=function(t){var e=0;return t.Rect=function(t,i,s,o){return this instanceof arguments.callee?(this.x=t,this.y=i,this.width=s,this.height=o,this.right=t+s-e,void(this.bottom=i+o-e)):new arguments.callee(t,i,s,o)},t.Rect.prototype.getPosition=function(){return[this.x,this.y]},t.Rect.prototype.move=function(t,e){return this.x+=t,this.y+=e,this.right+=t,this.bottom+=e,this},t.Rect.prototype.moveTo=function(t,i){return this.x=t,this.y=i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.resize=function(t,i){return this.width+=t,this.height+=i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.clone=function(){return new t.Rect(this.x,this.y,this.width,this.height)},t.Rect.prototype.shrink=function(t,i){return this.x+=t,this.y+=i,this.width-=t+t,this.height-=i+i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.resizeTo=function(t,i){return this.width=t,this.height=i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.draw=function(){return t.context.strokeStyle="red",t.context.strokeRect(this.x-.5,this.y-.5,this.width,this.height),this},t.Rect.prototype.collidePoint=function(t,e){return t>=this.x&&t<=this.right&&e>=this.y&&e<=this.bottom},t.Rect.prototype.collideRect=function(t){return(this.x>=t.x&&this.x<=t.right||t.x>=this.x&&t.x<=this.right)&&(this.y>=t.y&&this.y<=t.bottom||t.y>=this.y&&t.y<=this.bottom)},t.Rect.prototype.toString=function(){return"[Rect "+this.x+", "+this.y+", "+this.width+", "+this.height+"]"},t}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.Rect);var jaws=function(jaws){return jaws.Sprite=function(t){return this instanceof arguments.callee?(this.set(t),void(this.context=t.context?t.context:jaws.context)):new arguments.callee(t)},jaws.Sprite.prototype.default_options={x:0,y:0,alpha:1,angle:0,flipped:!1,anchor_x:0,anchor_y:0,image:null,image_path:null,anchor:null,scale_image:null,damping:1,scale_x:1,scale_y:1,scale:1,color:"#ddd",width:16,height:16,_constructor:null,context:null,data:null},jaws.Sprite.prototype.set=function(t){if(jaws.isString(this.image)&&(this.image_path=this.image),jaws.parseOptions(this,t,this.default_options),this.scale&&(this.scale_x=this.scale_y=this.scale),this.image&&this.setImage(this.image),this.scale_image&&this.scaleImage(this.scale_image),this.anchor&&this.setAnchor(this.anchor),!this.image&&this.color&&this.width&&this.height){var e=document.createElement("canvas"),i=e.getContext("2d");e.width=this.width,e.height=this.height,i.fillStyle=this.color,i.fillRect(0,0,this.width,this.height),this.image=e}return this.cacheOffsets(),this},jaws.Sprite.prototype.clone=function(object){var constructor=this._constructor?eval(this._constructor):this.constructor,new_sprite=new constructor(this.attributes());return new_sprite._constructor=this._constructor||this.constructor.name,new_sprite},jaws.Sprite.prototype.setImage=function(t){var e=this;return jaws.isDrawable(t)?(this.image=t,this.cacheOffsets()):(jaws.assets.isLoaded(t)?(this.image=jaws.assets.get(t),this.cacheOffsets()):(jaws.log.warn("Image '"+t+"' not preloaded with jaws.assets.add(). Image and a working sprite.rect() will be delayed."),jaws.assets.load(t,{onload:function(){e.image=jaws.assets.get(t),e.cacheOffsets()}})),this)},jaws.Sprite.prototype.stepToWhile=function(t,e,i){var s=1,o=t<this.x?-s:s,n=e<this.y?-s:s;t=parseInt(t),e=parseInt(e);for(var a=!1,r=!1;;)if(a===!1&&(this.x!=t&&(this.x+=o),i(this)||(this.x-=o,a=!0)),r===!1&&(this.y!=e&&(this.y+=n),i(this)||(this.y-=n,r=!0)),(a||this.x==t)&&(r||this.y==e))return{x:a,y:r}},jaws.Sprite.prototype.stepWhile=function(t,e,i){return this.stepToWhile(this.x+t,this.y+e,i)},jaws.Sprite.prototype.flip=function(){return this.flipped=this.flipped?!1:!0,this},jaws.Sprite.prototype.flipTo=function(t){return this.flipped=t,this},jaws.Sprite.prototype.rotate=function(t){return this.angle+=t,this},jaws.Sprite.prototype.rotateTo=function(t){return this.angle=t,this},jaws.Sprite.prototype.moveTo=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),this.x=t,this.y=e,this},jaws.Sprite.prototype.move=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),t&&(this.x+=t),e&&(this.y+=e),this},jaws.Sprite.prototype.scaleAll=function(t){return this.scale_x*=t,this.scale_y*=t,this.cacheOffsets()},jaws.Sprite.prototype.scaleTo=function(t){return this.scale_x=this.scale_y=t,this.cacheOffsets()},jaws.Sprite.prototype.scaleWidth=function(t){return this.scale_x*=t,this.cacheOffsets()},jaws.Sprite.prototype.scaleHeight=function(t){return this.scale_y*=t,this.cacheOffsets()},jaws.Sprite.prototype.setX=function(t){return this.x=t,this},jaws.Sprite.prototype.setY=function(t){return this.y=t,this},jaws.Sprite.prototype.setTop=function(t){return this.y=t+this.top_offset,this},jaws.Sprite.prototype.setBottom=function(t){return this.y=t-this.bottom_offset,this},jaws.Sprite.prototype.setLeft=function(t){return this.x=t+this.left_offset,this},jaws.Sprite.prototype.setRight=function(t){return this.x=t-this.right_offset,this},jaws.Sprite.prototype.setWidth=function(t){return this.scale_x=t/this.image.width,this.cacheOffsets()},jaws.Sprite.prototype.setHeight=function(t){return this.scale_y=t/this.image.height,this.cacheOffsets()},jaws.Sprite.prototype.resize=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),this.scale_x=(this.width+t)/this.image.width,this.scale_y=(this.height+e)/this.image.height,this.cacheOffsets()},jaws.Sprite.prototype.resizeTo=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),this.scale_x=t/this.image.width,this.scale_y=e/this.image.height,this.cacheOffsets()},jaws.Sprite.prototype.setAnchor=function(t){var e={top_left:[0,0],left_top:[0,0],center_left:[0,.5],left_center:[0,.5],bottom_left:[0,1],left_bottom:[0,1],top_center:[.5,0],center_top:[.5,0],center_center:[.5,.5],center:[.5,.5],bottom_center:[.5,1],center_bottom:[.5,1],top_right:[1,0],right_top:[1,0],center_right:[1,.5],right_center:[1,.5],bottom_right:[1,1],right_bottom:[1,1]};return(a=e[t])&&(this.anchor_x=a[0],this.anchor_y=a[1],this.image&&this.cacheOffsets()),this},jaws.Sprite.prototype.cacheOffsets=function(){return this.image?(this.width=this.image.width*this.scale_x,this.height=this.image.height*this.scale_y,this.left_offset=this.width*this.anchor_x,this.top_offset=this.height*this.anchor_y,this.right_offset=this.width*(1-this.anchor_x),this.bottom_offset=this.height*(1-this.anchor_y),this.cached_rect&&this.cached_rect.resizeTo(this.width,this.height),this):void 0},jaws.Sprite.prototype.rect=function(){return!this.cached_rect&&this.width&&(this.cached_rect=new jaws.Rect(this.x,this.y,this.width,this.height)),this.cached_rect&&this.cached_rect.moveTo(this.x-this.left_offset,this.y-this.top_offset),this.cached_rect},jaws.Sprite.prototype.draw=function(){return this.image?(this.context.save(),this.context.translate(this.x,this.y),0!=this.angle&&jaws.context.rotate(this.angle*Math.PI/180),this.flipped&&this.context.scale(-1,1),this.context.globalAlpha=this.alpha,this.context.translate(-this.left_offset,-this.top_offset),this.context.drawImage(this.image,0,0,this.width,this.height),this.context.restore(),this):this},jaws.Sprite.prototype.scaleImage=function(t){return this.image?(this.setImage(jaws.retroScaleImage(this.image,t)),this):void 0},jaws.Sprite.prototype.asCanvasContext=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");return jaws.context&&(e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled),e.drawImage(this.image,0,0,this.width,this.height),e},jaws.Sprite.prototype.asCanvas=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");return jaws.context&&(e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled),e.drawImage(this.image,0,0,this.width,this.height),t},jaws.Sprite.prototype.toString=function(){return"[Sprite "+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width+", "+this.height+"]"},jaws.Sprite.prototype.attributes=function(){var t={};return t._constructor=this._constructor||"jaws.Sprite",t.x=parseFloat(this.x.toFixed(2)),t.y=parseFloat(this.y.toFixed(2)),t.image=this.image_path,t.alpha=this.alpha,t.flipped=this.flipped,t.angle=parseFloat(this.angle.toFixed(2)),t.scale_x=this.scale_x,t.scale_y=this.scale_y,t.anchor_x=this.anchor_x,t.anchor_y=this.anchor_y,null!==this.data&&(t.data=jaws.clone(this.data)),t},jaws.Sprite.parse=function(objects){function parseArray(array){array.forEach(function(data){var constructor=data._constructor?eval(data._constructor):data.constructor;if(jaws.isFunction(constructor)){jaws.log.info("Creating "+data._constructor+"("+data.toString()+")",!0);var object=new constructor(data);object._constructor=data._constructor||data.constructor.name,sprites.push(object)}})}var sprites=[];return jaws.isArray(objects)?objects.every(function(t){return t._constructor})?parseArray(objects):sprites=objects:jaws.isString(objects)&&(parseArray(JSON.parse(objects)),jaws.log.info(objects)),sprites},jaws.Sprite.prototype.toJSON=function(){return JSON.stringify(this.attributes())},jaws}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.Sprite);var jaws=function(t){function e(t,e,i,s,o){var n=document.createElement("canvas");n.width=s,n.height=o;var a=n.getContext("2d");return a.drawImage(t,e,i,s,o,0,0,n.width,n.height),n}return t.SpriteSheet=function(i){if(!(this instanceof arguments.callee))return new arguments.callee(i);if(t.parseOptions(this,i,this.default_options),t.isString(this.image)&&!i.frame_size){var s=new RegExp("_(\\d+)x(\\d+)","g"),o=s.exec(this.image);this.frame_size=[],this.frame_size[0]=parseInt(o[1]),this.frame_size[1]=parseInt(o[2])}if(this.image=t.isDrawable(this.image)?this.image:t.assets.data[this.image],this.scale_image){var n=t.isDrawable(this.image)?this.image:t.assets.get(this.image);this.frame_size[0]*=this.scale_image,this.frame_size[1]*=this.scale_image,this.image=t.retroScaleImage(n,this.scale_image)}if(this.frames=[],"down"==this.orientation)for(var a=this.offset;a<this.image.width;a+=this.frame_size[0])for(var r=0;r<this.image.height;r+=this.frame_size[1])this.frames.push(e(this.image,a,r,this.frame_size[0],this.frame_size[1]));else for(var r=this.offset;r<this.image.height;r+=this.frame_size[1])for(var a=0;a<this.image.width;a+=this.frame_size[0])this.frames.push(e(this.image,a,r,this.frame_size[0],this.frame_size[1]))},t.SpriteSheet.prototype.default_options={image:null,orientation:"down",frame_size:[32,32],offset:0,scale_image:null},t.SpriteSheet.prototype.toString=function(){return"[SpriteSheet "+this.frames.length+" frames]"},t}(jaws||{}),jaws=function(t){return t.Animation=function(e){if(!(this instanceof arguments.callee))return new arguments.callee(e);if(t.parseOptions(this,e,this.default_options),e.sprite_sheet){var i=new t.SpriteSheet({image:e.sprite_sheet,scale_image:this.scale_image,frame_size:this.frame_size,orientation:this.orientation,offset:this.offset});this.frames=i.frames,this.frame_size=i.frame_size}if(e.scale_image){var s=t.isDrawable(e.sprite_sheet)?e.sprite_sheet:t.assets.get(e.sprite_sheet);this.frame_size[0]*=e.scale_image,this.frame_size[1]*=e.scale_image,e.sprite_sheet=t.retroScaleImage(s,e.scale_image)}if(this.current_tick=(new Date).getTime(),this.last_tick=(new Date).getTime(),this.sum_tick=0,e.subsets){this.subsets={};for(subset in e.subsets)start_stop=e.subsets[subset],this.subsets[subset]=this.slice(start_stop[0],start_stop[1])}},t.Animation.prototype.default_options={frames:[],subsets:[],frame_duration:100,index:0,loop:1,bounce:0,frame_direction:1,frame_size:null,orientation:"down",on_end:null,offset:0,scale_image:null,sprite_sheet:null},t.Animation.prototype.subset=function(t){return this.subsets[t]},t.Animation.prototype.update=function(){return this.current_tick=(new Date).getTime(),this.sum_tick+=this.current_tick-this.last_tick,this.last_tick=this.current_tick,this.sum_tick>this.frame_duration&&(this.index+=this.frame_direction,this.sum_tick=0),(this.index>=this.frames.length||this.index<0)&&(this.bounce?(this.frame_direction=-this.frame_direction,this.index+=2*this.frame_direction):this.loop?this.index=this.frame_direction<0?this.frames.length-1:0:(this.index-=this.frame_direction,this.on_end&&(this.on_end(),this.on_end=null))),this},t.Animation.prototype.slice=function(e,i){var s={};return s.frame_duration=this.frame_duration,s.loop=this.loop,s.bounce=this.bounce,s.on_end=this.on_end,s.frame_direction=this.frame_direction,s.frames=this.frames.slice().slice(e,i),new t.Animation(s) -},t.Animation.prototype.next=function(){return this.update(),this.frames[this.index]},t.Animation.prototype.atLastFrame=function(){return this.index==this.frames.length-1},t.Animation.prototype.atFirstFrame=function(){return 0==this.index},t.Animation.prototype.currentFrame=function(){return this.frames[this.index]},t.Animation.prototype.toString=function(){return"[Animation, "+this.frames.length+" frames]"},t}(jaws||{});if("undefined"!=typeof require)var jaws=require("./core.js");var jaws=function(t){function e(t,e){for(var i=function(e){return void 0!==t.isSpriteList?t.at(e):t[e]},s=[],o=new Array(e),n=0;e>n;n++)o[n]=n;for(var n=e-1,a=t.length;n>=0;a=t.length){for(s.push(o.map(i));n>=0&&o[n]===a-1;)n--,a--;if(n>=0){o[n]+=1;for(var r=n+1;e>r;r++)o[r]=o[r-1]+1;n=e-1}}return s}return t.collideOneWithOne=function(e,i){return e.radius&&i.radius&&e!==i&&t.collideCircles(e,i)?!0:e.rect&&i.rect&&e!==i&&t.collideRects(e.rect(),i.rect())?!0:!1},t.collideOneWithMany=function(e,i,s){var o=[];if(s){for(var n=0;n<i.length;n++)t.collideOneWithOne(e,i[n])&&(s(e,i[n]),o.push(i[n]));return o}return i.filter(function(i){return t.collideOneWithOne(e,i)})},t.collideManyWithMany=function(i,s,o){var n=[];return i===s?e(i,2).forEach(function(e){t.collideOneWithOne(e[0],e[1])&&(o?o(e[0],e[1]):n.push([e[0],e[1]]))}):i.forEach(function(e){s.forEach(function(i){t.collideOneWithOne(e,i)&&(o?o(e,i):n.push([e,i]))})}),n},t.collideCircles=function(e,i){return t.distanceBetween(e,i)<e.radius+i.radius},t.collideRects=function(t,e){return(t.x>=e.x&&t.x<=e.right||e.x>=t.x&&e.x<=t.right)&&(t.y>=e.y&&t.y<=e.bottom||e.y>=t.y&&e.y<=t.bottom)},t.distanceBetween=function(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))},t.collide=function(e,i,s){if((e.rect||e.radius)&&i.forEach)return t.collideOneWithMany(e,i,s).length>0;if(e.forEach&&i.forEach)return t.collideManyWithMany(e,i,s).length>0;if(e.forEach&&(i.rect||i.radius))return t.collideOneWithMany(i,e,s).length>0;if(e.rect&&i.rect||e.radius&&i.radius){var o=t.collideOneWithOne(e,i);if(!s||!o)return o;s(e,i)}},t}(jaws||{}),jaws=function(t){return t.PixelMap=function(e){return this instanceof arguments.callee?(this.options=e,this.scale=e.scale||1,this.x=e.x||0,this.y=e.y||0,e.image?(this.setContext(e.image),e.scale_image&&this.setContext(t.retroScaleImage(this.context.canvas,e.scale_image)),this.width=this.context.canvas.width*this.scale,this.height=this.context.canvas.height*this.scale):t.log.warn("PixelMap needs an image to work with"),this.named_colors=[],void this.update()):new arguments.callee(e)},t.PixelMap.prototype.setContext=function(e){var e=t.isDrawable(e)?e:t.assets.get(e);this.context=t.imageToCanvasContext(e)},t.PixelMap.prototype.update=function(t,e,i,s){if((void 0===t||0>t)&&(t=0),(void 0===e||0>e)&&(e=0),(void 0===i||i>this.width)&&(i=this.width),(void 0===s||s>this.height)&&(s=this.height),0==arguments.length)this.data=this.context.getImageData(t,e,i,s).data;else for(var o=this.context.getImageData(t,e,i,s).data,n=0,a=4*this.width,r=e*this.width*4+4*t,h=4*i,c=0;s>c;c++){for(var l=0;h>l;l++)this.data[r+l]=o[n++];r+=a}},t.PixelMap.prototype.draw=function(){t.context.drawImage(this.context.canvas,this.x,this.y,this.width,this.height)},t.PixelMap.prototype.namedColorAtRect=function(t,e){for(var i=t.x,s=t.y;i<t.right-1;i++)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);for(;s<t.bottom-1;s++)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);for(;i>t.x;i--)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);for(;s>t.y;s--)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);return!1},t.PixelMap.prototype.at=function(t,e){t=parseInt(t),e=parseInt(e),0>e&&(e=0);var i=e*this.width*4+4*t,s=this.data[i],o=this.data[i+1],n=this.data[i+2],a=this.data[i+3];return[s,o,n,a]},t.PixelMap.prototype.namedColorAt=function(t,e){for(var i=this.at(t,e),s=0;s<this.named_colors.length;s++){var o=this.named_colors[s].name,n=this.named_colors[s].color;if(n[0]==i[0]&&n[1]==i[1]&&n[2]==i[2]&&n[3]==i[3])return o}},t.PixelMap.prototype.nameColor=function(t,e){this.named_colors.push({name:e,color:t})},t}(jaws||{}),jaws=function(t){return t.Parallax=function(e){return this instanceof arguments.callee?void t.parseOptions(this,e,this.default_options):new arguments.callee(e)},t.Parallax.prototype.default_options={width:function(){return t.width},height:function(){return t.height},scale:1,repeat_x:null,repeat_y:null,camera_x:0,camera_y:0,layers:[]},t.Parallax.prototype.draw=function(){for(var t,e,i=0;i<this.layers.length;i++)for(t=this.layers[i],e=this.repeat_x?-(this.camera_x/t.damping%t.width):-(this.camera_x/t.damping),t.y=this.repeat_y?-(this.camera_y/t.damping%t.height):-(this.camera_y/t.damping),t.x=e;t.y<this.height;){for(;t.x<this.width&&(t.x+t.width>=0&&t.y+t.height>=0&&t.draw(),t.x=t.x+t.width,this.repeat_x););if(t.y=t.y+t.height,t.x=e,!this.repeat_y)break}},t.Parallax.prototype.addLayer=function(e){var i=new t.ParallaxLayer(e);i.scaleAll(this.scale),this.layers.push(i)},t.Parallax.prototype.toString=function(){return"[Parallax "+this.x+", "+this.y+". "+this.layers.length+" layers]"},t.ParallaxLayer=function(e){return this instanceof arguments.callee?(this.damping=e.damping||0,void t.Sprite.call(this,e)):new arguments.callee(e)},t.ParallaxLayer.prototype=t.Sprite.prototype,t}(jaws||{}),jaws=function(jaws){return jaws.Text=function(t){return this instanceof arguments.callee?(this.set(t),t.context&&(this.context=t.context),void(t.context||jaws.context&&(this.context=jaws.context))):new arguments.callee(t)},jaws.Text.prototype.default_options={x:0,y:0,alpha:1,angle:0,anchor_x:0,anchor_y:0,anchor:"top_left",damping:1,style:"normal",fontFace:"serif",fontSize:12,color:"black",textAlign:"start",textBaseline:"alphabetic",text:"",wordWrap:!1,width:function(){return jaws.width},height:function(){return jaws.height},shadowColor:null,shadowBlur:null,shadowOffsetX:null,shadowOffsetY:null,_constructor:null},jaws.Text.prototype.set=function(t){return jaws.parseOptions(this,t,this.default_options),this.anchor&&this.setAnchor(this.anchor),this.cacheOffsets(),this},jaws.Text.prototype.clone=function(){var constructor=this._constructor?eval(this._constructor):this.constructor,new_sprite=new constructor(this.attributes());return new_sprite._constructor=this._constructor||this.constructor.name,new_sprite},jaws.Text.prototype.rotate=function(t){return this.angle+=t,this},jaws.Text.prototype.rotateTo=function(t){return this.angle=t,this},jaws.Text.prototype.moveTo=function(t,e){return this.x=t,this.y=e,this},jaws.Text.prototype.move=function(t,e){return t&&(this.x+=t),e&&(this.y+=e),this},jaws.Text.prototype.setX=function(t){return this.x=t,this},jaws.Text.prototype.setY=function(t){return this.y=t,this},jaws.Text.prototype.setTop=function(t){return this.y=t+this.top_offset,this},jaws.Text.prototype.setBottom=function(t){return this.y=t-this.bottom_offset,this},jaws.Text.prototype.setLeft=function(t){return this.x=t+this.left_offset,this},jaws.Text.prototype.setRight=function(t){return this.x=t-this.right_offset,this},jaws.Text.prototype.setWidth=function(t){return this.width=t,this.cacheOffsets(),this},jaws.Text.prototype.setHeight=function(t){return this.height=t,this.cacheOffsets(),this},jaws.Text.prototype.resize=function(t,e){return this.width+=t,this.height+=e,this.cacheOffsets(),this},jaws.Text.prototype.resizeTo=function(t,e){return this.width=t,this.height=e,this.cacheOffsets(),this},jaws.Text.prototype.setAnchor=function(t){var e={top_left:[0,0],left_top:[0,0],center_left:[0,.5],left_center:[0,.5],bottom_left:[0,1],left_bottom:[0,1],top_center:[.5,0],center_top:[.5,0],center_center:[.5,.5],center:[.5,.5],bottom_center:[.5,1],center_bottom:[.5,1],top_right:[1,0],right_top:[1,0],center_right:[1,.5],right_center:[1,.5],bottom_right:[1,1],right_bottom:[1,1]};return e.hasOwnProperty(t)&&(this.anchor_x=e[t][0],this.anchor_y=e[t][1],this.cacheOffsets()),this},jaws.Text.prototype.cacheOffsets=function(){return this.left_offset=this.width*this.anchor_x,this.top_offset=this.height*this.anchor_y,this.right_offset=this.width*(1-this.anchor_x),this.bottom_offset=this.height*(1-this.anchor_y),this.cached_rect&&this.cached_rect.resizeTo(this.width,this.height),this},jaws.Text.prototype.rect=function(){return!this.cached_rect&&this.width&&(this.cached_rect=new jaws.Rect(this.x,this.y,this.width,this.height)),this.cached_rect&&this.cached_rect.moveTo(this.x-this.left_offset,this.y-this.top_offset),this.cached_rect},jaws.Text.prototype.draw=function(){this.context.save(),0!==this.angle&&this.context.rotate(this.angle*Math.PI/180),this.context.globalAlpha=this.alpha,this.context.translate(-this.left_offset,-this.top_offset),this.context.fillStyle=this.color,this.context.font=this.style+" "+this.fontSize+"px "+this.fontFace,this.context.textBaseline=this.textBaseline,this.context.textAlign=this.textAlign,this.shadowColor&&(this.context.shadowColor=this.shadowColor),this.shadowBlur&&(this.context.shadowBlur=this.shadowBlur),this.shadowOffsetX&&(this.context.shadowOffsetX=this.shadowOffsetX),this.shadowOffsetY&&(this.context.shadowOffsetY=this.shadowOffsetY);var t=this.y,e=this.x;if(this.wordWrap)for(var i=this.text.split(" "),s="",o=0;o<i.length;o++){var n=s+i[o]+" ",a=this.context.measureText(n);this.y<t+this.height&&(a.width>this.width?(this.context.fillText(s,this.x,this.y),s=i[o]+" ",this.y+=this.fontSize):s=n,this.context.fillText(s,this.x,this.y))}else if(this.context.measureText(this.text).width<this.width)this.context.fillText(this.text,this.x,this.y);else for(var i=this.text.split(" "),s=" ",o=0;o<i.length;o++){var n=s+i[o]+" ";this.context.measureText(n).width<Math.abs(this.width-this.x)&&(this.context.fillText(n,this.x,this.y),s=i[o]+" ",s=n)}return this.y=t,this.x=e,this.context.restore(),this},jaws.Text.prototype.asCanvasContext=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled,this.context.fillStyle=this.color,this.context.font=this.style+this.fontSize+"px "+this.fontFace,this.context.textBaseline=this.textBaseline,this.context.textAlign=this.textAlign,this.shadowColor&&(this.context.shadowColor=this.shadowColor),this.shadowBlur&&(this.context.shadowBlur=this.shadowBlur),this.shadowOffsetX&&(this.context.shadowOffsetX=this.shadowOffsetX),this.shadowOffsetY&&(this.context.shadowOffsetY=this.shadowOffsetY);var i=this.y,s=this.x;if(this.wordWrap)for(var o=this.text.split(" "),n="",a=0;a<o.length;a++){var r=n+o[a]+" ",h=this.context.measureText(r);this.y<i+this.height&&(h.width>this.width?(this.context.fillText(n,this.x,this.y),n=o[a]+" ",this.y+=this.fontSize):n=r,this.context.fillText(n,this.x,this.y))}else if(this.context.measureText(this.text).width<this.width)this.context.fillText(this.text,this.x,this.y);else for(var o=this.text.split(" "),n=" ",a=0;a<o.length;a++){var r=n+o[a]+" ";this.context.measureText(r).width<Math.abs(this.width-this.x)&&(this.context.fillText(r,this.x,this.y),n=o[a]+" ",n=r)}return this.y=i,this.x=s,e},jaws.Text.prototype.asCanvas=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled,this.context.fillStyle=this.color,this.context.font=this.style+this.fontSize+"px "+this.fontFace,this.context.textBaseline=this.textBaseline,this.context.textAlign=this.textAlign,this.shadowColor&&(this.context.shadowColor=this.shadowColor),this.shadowBlur&&(this.context.shadowBlur=this.shadowBlur),this.shadowOffsetX&&(this.context.shadowOffsetX=this.shadowOffsetX),this.shadowOffsetY&&(this.context.shadowOffsetY=this.shadowOffsetY);var i=this.y,s=this.x;if(this.wordWrap)for(var o=this.text.split(" "),n="",a=0;a<o.length;a++){var r=n+o[a]+" ",h=e.measureText(r);this.y<i+this.height&&(h.width>this.width?(e.fillText(n,this.x,this.y),n=o[a]+" ",this.y+=this.fontSize):n=r,e.fillText(n,this.x,this.y))}else if(e.measureText(this.text).width<this.width)this.context.fillText(this.text,this.x,this.y);else for(var o=this.text.split(" "),n=" ",a=0;a<o.length;a++){var r=n+o[a]+" ";e.measureText(r).width<Math.abs(this.width-this.x)&&(e.fillText(r,this.x,this.y),n=o[a]+" ",n=r)}return this.y=i,this.x=s,t},jaws.Text.prototype.toString=function(){return"[Text "+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width+", "+this.height+"]"},jaws.Text.prototype.attributes=function(){var t=this.options;return t._constructor=this._constructor||"jaws.Text",t.x=parseFloat(this.x.toFixed(2)),t.y=parseFloat(this.y.toFixed(2)),t.text=this.text,t.alpha=this.alpha,t.angle=parseFloat(this.angle.toFixed(2)),t.anchor_x=this.anchor_x,t.anchor_y=this.anchor_y,t.style=this.style,t.fontSize=this.fontSize,t.fontFace=this.fontFace,t.color=this.color,t.textAlign=this.textAlign,t.textBaseline=this.textBaseline,t.wordWrap=this.wordWrap,t.width=this.width,t.height=this.height,t},jaws.Text.prototype.toJSON=function(){return JSON.stringify(this.attributes())},jaws}(jaws||{});if("undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.Text),"undefined"!=typeof require)var jaws=require("./core.js");var jaws=function(t){return t.QuadTree=function(e){this.depth=arguments[1]||0,this.bounds=e||new t.Rect(0,0,t.width,t.height),this.nodes=[],this.objects=[]},t.QuadTree.prototype.clear=function(){this.objects=[];for(var t=0;t<this.nodes.length;t++)"undefined"!=typeof this.nodes[t]&&(this.nodes[t].clear(),delete this.nodes[t])},t.QuadTree.prototype.split=function(){var e=Math.round(this.bounds.width/2),i=Math.round(this.bounds.height/2),s=this.bounds.x,o=this.bounds.y;this.nodes[0]=new t.QuadTree(new t.Rect(s+e,o,e,i),this.depth+1),this.nodes[1]=new t.QuadTree(new t.Rect(s,o,e,i),this.depth+1),this.nodes[2]=new t.QuadTree(new t.Rect(s,o+i,e,i),this.depth+1),this.nodes[3]=new t.QuadTree(new t.Rect(s+e,o+i,e,i),this.depth+1)},t.QuadTree.prototype.getIndex=function(t){var e=-1,i=this.bounds.x+this.bounds.width/2,s=this.bounds.y+this.bounds.height/2,o=t.y<s&&t.y+t.height<s,n=t.y>s;return t.x<i&&t.x+t.width<i?o?e=1:n&&(e=2):t.x>i&&(o?e=0:n&&(e=3)),e},t.QuadTree.prototype.insert=function(t){if(t.hasOwnProperty("x")||t.hasOwnProperty("y")||t.hasOwnProperty("width")||t.hasOwnProperty("height")){if("undefined"!=typeof this.nodes[0]){var e=this.getIndex(t);if(-1!==e)return void this.nodes[e].insert(t)}this.objects.push(t),"undefined"==typeof this.nodes[0]&&this.split();for(var i=0;i<this.objects.length;){var e=this.getIndex(this.objects[i]);-1!==e?this.nodes[e].insert(this.objects.splice(i,1)[0]):i++}}},t.QuadTree.prototype.retrieve=function(t){if(t.hasOwnProperty("x")||t.hasOwnProperty("y")||t.hasOwnProperty("width")||t.hasOwnProperty("height")){var e=this.getIndex(t),i=this.objects;if("undefined"!=typeof this.nodes[0])if(-1!==e)i=i.concat(this.nodes[e].retrieve(t));else for(var s=0;s<this.nodes.length;s++)i=i.concat(this.nodes[s].retrieve(t));return i}},t.QuadTree.prototype.collide=function(e,i,s){var o=!1,n=new t.QuadTree,a=[];return e.forEach||(a.push(e),e=a),i.forEach||(a=[],a.push(i),i=a),i.forEach(function(t){n.insert(t)}),e.forEach(function(e){t.collide(e,n.retrieve(e),s)&&(o=!0)}),n.clear(),o},t}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.QuadTree),window.addEventListener("load",function(){jaws.onload&&jaws.onload()},!1);
\ No newline at end of file +var jaws=function(t){function e(e){t.mouse_x=e.pageX||e.clientX,t.mouse_y=e.pageY||e.clientY;var i=t.canvas?t.canvas:t.dom;t.mouse_x-=i.offsetLeft,t.mouse_y-=i.offsetTop}var i,s;return t.SpriteList=function(){throw"To use SpriteList() you need to include src/extras/sprite_list.js"},t.Audio=function(){throw"To use jaws.Audio() you need to include src/extras/audio.js"},t.title=function(e){return t.isString(e)?e?i.innerHTML=e:i.innerHTML:void t.log.error("jaws.title: Passed in value is not a String.")},t.unpack=function(){var e=["Sprite","SpriteList","Animation","SpriteSheet","Parallax","pressed","QuadTree"];e.forEach(function(e){window[e]?t.log.warn("jaws.unpack: "+e+" already exists in global namespace."):window[e]=t[e]})},t.log=function(e,i){t.isString(e)||(e=JSON.stringify(e)),t.log.on&&(s&&t.log.use_log_element&&(i?s.innerHTML+=e+"<br />":s.innerHTML=e),console.log&&t.log.use_console&&console.log("JawsJS: ",e))},t.log.on=!0,t.log.use_console=!1,t.log.use_log_element=!0,t.log.warn=function(e){console.warn&&t.log.use_console&&t.log.on?console.warn(e):t.log("[WARNING]: "+JSON.stringify(e),!0)},t.log.error=function(e){console.error&&t.log.use_console&&t.log.on?console.error(e):t.log("[ERROR]: "+JSON.stringify(e),!0)},t.log.info=function(e){console.info&&t.log.use_console&&t.log.on?console.info(e):t.log("[INFO]: "+JSON.stringify(e),!0)},t.log.debug=function(e){console.debug&&t.log.use_console&&t.log.on?console.debug(e):t.log("[DEBUG]: "+JSON.stringify(e),!0)},t.log.clear=function(){s&&(s.innerHTML=""),console.clear&&console.clear()},t.init=function(o){i=document.getElementsByTagName("title")[0],t.url_parameters=t.getUrlParameters(),t.canvas=document.getElementsByTagName("canvas")[0],t.canvas||(t.dom=document.getElementById("canvas")),t.canvas?t.context=t.canvas.getContext("2d"):t.dom?t.dom.style.position="relative":(t.canvas=document.createElement("canvas"),t.canvas.width=o.width,t.canvas.height=o.height,t.context=t.canvas.getContext("2d"),document.body.appendChild(t.canvas)),s=document.getElementById("jaws-log"),t.url_parameters.debug&&(s||(s=document.createElement("div"),s.id="jaws-log",s.style.cssText="overflow: auto; color: #aaaaaa; width: 300px; height: 150px; margin: 40px auto 0px auto; padding: 5px; border: #444444 1px solid; clear: both; font: 10px verdana; text-align: left;",document.body.appendChild(s))),t.url_parameters.bust_cache&&(t.log.info("Busting cache when loading assets"),t.assets.bust_cache=!0),t.context&&t.useCrispScaling(),t.width=t.canvas?t.canvas.width:t.dom.offsetWidth,t.height=t.canvas?t.canvas.height:t.dom.offsetHeight,t.mouse_x=0,t.mouse_y=0,window.addEventListener("mousemove",e)},t.useCrispScaling=function(){t.context.imageSmoothingEnabled=!1,t.context.webkitImageSmoothingEnabled=!1,t.context.mozImageSmoothingEnabled=!1},t.useSmoothScaling=function(){t.context.imageSmoothingEnabled=!0,t.context.webkitImageSmoothingEnabled=!0,t.context.mozImageSmoothingEnabled=!0},t.start=function(e,i,s){function o(e,s){t.log.info(s+"%: "+e,!0),i.loading_screen&&t.assets.displayProgress(s)}function n(e,i){t.log.info(i+"%: Error loading asset "+e,!0)}function a(){t.log.info("all assets loaded",!0),t.switchGameState(e||window,{fps:r},s)}i||(i={});var r=i.fps||60;return void 0===i.loading_screen&&(i.loading_screen=!0),i.width||(i.width=500),i.height||(i.height=300),t.init(i),t.isFunction(e)||t.isObject(e)?t.isObject(s)||void 0===s?(i.loading_screen&&t.assets.displayProgress(0),t.log.info("setupInput()",!0),t.setupInput(),t.log.info("assets.loadAll()",!0),void(t.assets.length()>0?t.assets.loadAll({onprogress:o,onerror:n,onload:a}):a())):void t.log.error("jaws.start: The setup options for the game state is not an object."):void t.log.error("jaws.start: Passed in GameState is niether function or object")},t.switchGameState=function(e,i,s){if(void 0===i&&(i={}),t.isFunction(e)&&(e=new e),!t.isObject(e))return void t.log.error("jaws.switchGameState: Passed in GameState should be a Function or an Object.");var o=i&&i.fps||t.game_loop&&t.game_loop.fps||60,n=i.setup;t.game_loop&&t.game_loop.stop(),t.clearKeyCallbacks(),t.previous_game_state=t.game_state,t.game_state=e,t.game_loop=new t.GameLoop(e,{fps:o,setup:n},s),t.game_loop.start()},t.imageToCanvas=function(e){if(t.isCanvas(e))return e;if(!t.isImage(e))return void t.log.error("jaws.imageToCanvas: Passed in object is not an Image.");var i=document.createElement("canvas");i.src=e.src,i.width=e.width,i.height=e.height;var s=i.getContext("2d");return s.drawImage(e,0,0,e.width,e.height),i},t.forceArray=function(t){return Array.isArray(t)?t:[t]},t.clear=function(){t.context.clearRect(0,0,t.width,t.height)},t.fill=function(e){t.context.fillStyle=e,t.context.fillRect(0,0,t.width,t.height)},t.draw=function(){var e=arguments;1==e.length&&t.isArray(e[0])&&(e=e[0]);for(var i=0;i<e.length;i++)t.isArray(e[i])?t.draw(e[i]):e[i].draw&&e[i].draw()},t.update=function(){var e=arguments;1==e.length&&t.isArray(e[0])&&(e=e[0]);for(var i=0;i<e.length;i++)t.isArray(e[i])?t.update(e[i]):e[i].update&&e[i].update()},t.isImage=function(t){return"[object HTMLImageElement]"===Object.prototype.toString.call(t)},t.isCanvas=function(t){return"[object HTMLCanvasElement]"===Object.prototype.toString.call(t)},t.isDrawable=function(e){return t.isImage(e)||t.isCanvas(e)},t.isString=function(t){return"string"==typeof t||"object"==typeof t&&t.constructor===String},t.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},t.isArray=function(t){return t?!(-1===t.constructor.toString().indexOf("Array")):!1},t.isObject=function(t){return null!==t&&"object"==typeof t},t.isFunction=function(t){return"[object Function]"===Object.prototype.toString.call(t)},t.isRegExp=function(t){return t instanceof RegExp},t.isOutsideCanvas=function(e){return e.x&&e.y?e.x<0||e.y<0||e.x>t.width||e.y>t.height:void 0},t.forceInsideCanvas=function(e){e.x&&e.y&&(e.x<0&&(e.x=0),e.x>t.width&&(e.x=t.width),e.y<0&&(e.y=0),e.y>t.height&&(e.y=t.height))},t.getUrlParameters=function(){for(var t,e=[],i=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),s=0;s<i.length;s++)t=i[s].split("="),e.push(t[0]),e[t[0]]=t[1];return e},t.parseOptions=function(e,i,s){e.options=i;for(var o in i)void 0===s[o]&&t.log.warn("jaws.parseOptions: Unsupported property "+o+"for "+e.constructor);for(var o in s)t.isFunction(s[o])&&(s[o]=s[o]()),e[o]=void 0!==i[o]?i[o]:t.clone(s[o])},t.clone=function(e){return t.isArray(e)?e.slice(0):t.isObject(e)?JSON.parse(JSON.stringify(e)):e},t.imageToCanvasContext=function(e){var i=document.createElement("canvas");i.width=e.width,i.height=e.height;var s=i.getContext("2d");return t.context&&(s.imageSmoothingEnabled=t.context.mozImageSmoothingEnabled,s.webkitImageSmoothingEnabled=t.context.mozImageSmoothingEnabled,s.mozImageSmoothingEnabled=t.context.mozImageSmoothingEnabled),s.drawImage(e,0,0,i.width,i.height),s},t.retroScaleImage=function(e,i){var s=t.isImage(e)?t.imageToCanvas(e):e,o=s.getContext("2d"),n=o.getImageData(0,0,s.width,s.height).data,a=document.createElement("canvas");a.width=e.width*i,a.height=e.height*i;for(var r=a.getContext("2d"),h=r.createImageData(a.width,a.height),c=h.width,l=h.height,u=0;l>u;u+=1)for(var d=Math.floor(u/i),f=u*h.width,p=d*e.width,g=0;c>g;g+=1){var m=Math.floor(g/i),w=4*(f+g),x=4*(p+m);h.data[w]=n[x],h.data[w+1]=n[x+1],h.data[w+2]=n[x+2],h.data[w+3]=n[x+3]}return r.putImageData(h,0,0),a},t}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws);var jaws=function(t){function e(){for(var t in h)delete h[t]}function i(t){var e=e=t.keyCode;h[e]=!1,d[e]?(d[e](e),t.preventDefault()):g[e]&&t.preventDefault()}function s(t){var e=e=t.keyCode;h[e]=!0,u[e]?(u[e](e),t.preventDefault()):g[e]&&t.preventDefault()}function o(t){var e=f[t.button];"Microsoft Internet Explorer"==navigator.appName&&(e=p[t.button]),h[e]=!0,u[e]&&(u[e](e),t.preventDefault())}function n(t){var e=f[t.button];"Microsoft Internet Explorer"==navigator.appName&&(e=p[t.button]),h[e]=!1,d[e]&&(d[e](e),t.preventDefault())}function a(e){h.left_mouse_button=!0,t.mouse_x=e.touches[0].pageX-t.canvas.offsetLeft,t.mouse_y=e.touches[0].pageY-t.canvas.offsetTop}function r(){h.left_mouse_button=!1,t.mouse_x=void 0,t.mouse_y=void 0}var h={},c={0:"48",1:"49",2:"50",3:"51",4:"52",5:"53",6:"54",7:"55",8:"56",9:"57",backspace:"8",tab:"9",enter:"13",shift:"16",ctrl:"17",alt:"18",pause:"19",caps_lock:"20",esc:"27",space:"32",page_up:"33",page_down:"34",end:"35",home:"36",left:"37",up:"38",right:"39",down:"40",insert:"45","delete":"46",a:"65",b:"66",c:"67",d:"68",e:"69",f:"70",g:"71",h:"72",i:"73",j:"74",k:"75",l:"76",m:"77",n:"78",o:"79",p:"80",q:"81",r:"82",s:"83",t:"84",u:"85",v:"86",w:"87",x:"88",y:"89",z:"90",windows_left:"91",windows_right:"92",select:"93",numpad0:"96",numpad1:"97",numpad2:"98",numpad3:"99",numpad4:"100",numpad5:"101",numpad6:"102",numpad7:"103",numpad8:"104",numpad9:"105",asterisk:"106",plus:"107",minus:"109",decimal_point:"110",divide:"111",f1:"112",f2:"113",f3:"114",f4:"115",f5:"116",f6:"117",f7:"118",f8:"119",f9:"120",numlock:"144",scrollock:"145",semicolon:"186",equals:"187",comma:"188",dash:"189",period:"190",slash:"191",grave_accent:"192",open_bracket:"219",backslash:"220",close_bracket:"221",single_quote:"222"},l={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"caps_lock",27:"esc",32:"space",33:"page_up",34:"page_down",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"windows_left",92:"windows_right",93:"select",96:"numpad0",97:"numpad1",98:"numpad2",99:"numpad3",100:"numpad4",101:"numpad5",102:"numpad6",103:"numpad7",104:"numpad8",105:"numpad9",106:"asterisk",107:"plus",109:"minus",110:"decimal_point",111:"divide",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",144:"numlock",145:"scrollock",186:"semicolon",187:"equals",188:"comma",189:"dash",190:"period",191:"slash",192:"grave_accent",219:"open_bracket",220:"backslash",221:"close_bracket",222:"single_quote"},u=[],d=[],f=[],p=[],g=[];return t.setupInput=function(){var h=[];h[0]="left_mouse_button",h[1]="center_mouse_button",h[2]="right_mouse_button";var c=[];c[1]="left_mouse_button",c[2]="right_mouse_button",c[4]="center_mouse_button",f=h,p=c,window.addEventListener("keydown",s),window.addEventListener("keyup",i);var l=t.canvas||t.dom;l.addEventListener("mousedown",o,!1),l.addEventListener("mouseup",n,!1),l.addEventListener("touchstart",a,!1),l.addEventListener("touchend",r,!1),window.addEventListener("blur",e,!1),document.oncontextmenu=function(){return!1}},t.preventDefaultKeys=function(){for(var t=arguments,e=0;e<t.length;e++)g[t[e]]=!0},t.pressed=h,t.keyCodes=c,t.keycodeNames=l,t.on_keydown=function(e,i){if(t.isArray(e))for(var s=0;e[s];s++)u[e[s]]=i;else u[e]=i},t.on_keyup=function(e,i){if(t.isArray(e))for(var s=0;e[s];s++)d[e[s]]=i;else d[e]=i},t.clearKeyCallbacks=function(){d=[],u=[]},t}(jaws||{}),jaws=function(t){function e(e){if(t.isDrawable(e)){for(var i=t.isImage(e)?t.imageToCanvas(e):e,s=i.getContext("2d"),o=s.getImageData(0,0,i.width,i.height),n=o.data,a=0;a<n.length;a+=4)255===n[a]&&0===n[a+1]&&255===n[a+2]&&(n[a+3]=0);return s.putImageData(o,0,0),i}}return t.Assets=function(){function i(e){if(t.isString(e)){var i=r.getPostfix(e);return r.file_type[i]?r.file_type[i]:i}t.log.error("jaws.assets.getType: Argument not a String with "+e)}function s(s){var o=this.asset,n=o.src,h=i(o.src);try{if("json"===h){if(4!==this.readyState)return;r.data[o.src]=JSON.parse(this.responseText)}else if("image"===h){var c=r.image_to_canvas?t.imageToCanvas(o.image):o.image;r.fuchia_to_transparent&&"bmp"===r.getPostfix(o.src)&&(c=e(c)),r.data[o.src]=c}else r.data[o.src]="audio"===h&&r.can_play[r.getPostfix(o.src)]?o.audio:"video"===h&&r.can_play[r.getPostfix(o.src)]?o.video:this.response}catch(l){t.log.error("Cannot process "+n+" (Message: "+l.message+", Name: "+l.name+")"),r.data[o.src]=null}r.loaded[n]||r.load_count++,r.loaded[n]=!0,r.loading[n]=!1,a(o,!0,s)}function o(t){r.loaded[t.src]=!0,r.loading[t.src]=!1,r.load_count++,a(t,!0)}function n(t){var e=this.asset;r.error_count++,a(e,!1,t)}function a(t,e,i){var s=parseInt((r.load_count+r.error_count)/r.src_list.length*100);e?(r.onprogress&&r.onprogress(t.src,s),t.onprogress&&void 0!==i&&t.onprogress(i)):(r.onerror&&r.onerror(t.src,s),t.onerror&&void 0!==i&&t.onerror(i)),100===s&&(r.onload&&r.onload(),r.onprogress=null,r.onerror=null,r.onload=null)}if(!(this instanceof arguments.callee))return new arguments.callee;var r=this;r.loaded=[],r.loading=[],r.src_list=[],r.data=[],r.bust_cache=!1,r.image_to_canvas=!0,r.fuchia_to_transparent=!0,r.root="",r.file_type={},r.file_type.json="json",r.file_type.wav="audio",r.file_type.mp3="audio",r.file_type.ogg="audio",r.file_type.m4a="audio",r.file_type.weba="audio",r.file_type.aac="audio",r.file_type.mka="audio",r.file_type.flac="audio",r.file_type.png="image",r.file_type.jpg="image",r.file_type.jpeg="image",r.file_type.gif="image",r.file_type.bmp="image",r.file_type.tiff="image",r.file_type.mp4="video",r.file_type.webm="video",r.file_type.ogv="video",r.file_type.mkv="video",r.can_play={};try{var h=new Audio;r.can_play.wav=!!h.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),r.can_play.ogg=!!h.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),r.can_play.mp3=!!h.canPlayType("audio/mpeg;").replace(/^no$/,""),r.can_play.m4a=!!(h.canPlayType("audio/x-m4a;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),r.can_play.weba=!!h.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,""),r.can_play.aac=!!h.canPlayType("audio/aac;").replace(/^no$/,""),r.can_play.mka=!!h.canPlayType("audio/x-matroska;").replace(/^no$/,""),r.can_play.flac=!!h.canPlayType("audio/x-flac;").replace(/^no$/,"")}catch(c){}try{var l=document.createElement("video");r.can_play.mp4=!!l.canPlayType("video/mp4;").replace(/^no$/,""),r.can_play.webm=!!l.canPlayType('video/webm; codecs="vorbis"').replace(/^no$/,""),r.can_play.ogv=!!l.canPlayType('video/ogg; codecs="vorbis"').replace(/^no$/,""),r.can_play.mkv=!!l.canPlayType("video/x-matroska;").replace(/^no$/,"")}catch(c){}r.length=function(){return r.src_list.length},r.setRoot=function(t){return r.root=t,r},r.get=function(e){if(t.isArray(e))return e.map(function(t){return r.data[t]});if(!t.isString(e))return void t.log.error("jaws.get: Neither String nor Array. Incorrect URL resource "+e);if("*"===e[e.length-1])for(var i=e.replace("*",""),s=0;s<r.src_list.length;s++)if(0==r.src_list[s].indexOf(i)&&r.data[r.src_list[s]])return r.data[r.src_list[s]];return r.data[e]?r.data[e]:void t.log.warn("No such asset: "+e,!0)},r.isLoading=function(e){return t.isString(e)?r.loading[e]:void t.log.error("jaws.isLoading: Argument not a String with "+e)},r.isLoaded=function(e){return t.isString(e)?r.loaded[e]:void t.log.error("jaws.isLoaded: Argument not a String with "+e)},r.getPostfix=function(e){return t.isString(e)?e.toLowerCase().match(/.+\.([^?]+)(\?|$)/)[1]:void t.log.error("jaws.assets.getPostfix: Argument not a String with "+e)},r.add=function(e){var i=arguments;1==i.length&&t.isArray(i[0])&&(i=i[0]);for(var s=0;s<i.length;s++)t.isArray(i[s])?r.add(i[s]):t.isString(i[s])?r.src_list.push(i[s]):t.log.error("jaws.assets.add: Neither String nor Array. Incorrect URL resource "+e);return r},r.loadAll=function(e){return r.load_count=0,r.error_count=0,e.onprogress&&t.isFunction(e.onprogress)&&(r.onprogress=e.onprogress),e.onerror&&t.isFunction(e.onerror)&&(r.onerror=e.onerror),e.onload&&t.isFunction(e.onload)&&(r.onload=e.onload),r.src_list.forEach(function(t){r.load(t)}),r},r.load=function(e,a){if(a||(a={}),!t.isString(e))return void t.log.error("jaws.assets.load: Argument not a String with "+e);var h={},c="";h.src=e,h.onload=a.onload,h.onerror=a.onerror,r.loading[e]=!0;var l=RegExp("^((f|ht)tp(s)?:)?//");c=l.test(e)?h.src:r.root+h.src,r.bust_cache&&(c+="?"+parseInt(1e7*Math.random()));var u=i(h.src);if("image"===u)try{h.image=new Image,h.image.asset=h,h.image.addEventListener("load",s),h.image.addEventListener("error",n),h.image.src=c}catch(d){t.log.error("Cannot load Image resource "+c+" (Message: "+d.message+", Name: "+d.name+")")}else if(r.can_play[r.getPostfix(h.src)]){if("audio"===u)try{h.audio=new Audio,h.audio.asset=h,h.audio.addEventListener("error",n),h.audio.addEventListener("canplay",s),r.data[h.src]=h.audio,h.audio.src=c,h.audio.load()}catch(d){t.log.error("Cannot load Audio resource "+c+" (Message: "+d.message+", Name: "+d.name+")")}else if("video"===u)try{h.video=document.createElement("video"),h.video.asset=h,r.data[h.src]=h.video,h.video.setAttribute("style","display:none;"),h.video.addEventListener("error",n),h.video.addEventListener("canplay",s),document.body.appendChild(h.video),h.video.src=c,h.video.load()}catch(d){t.log.error("Cannot load Video resource "+c+" (Message: "+d.message+", Name: "+d.name+")")}}else{if("audio"===u&&!r.can_play[r.getPostfix(h.src)])return o(h),r;try{var f=new XMLHttpRequest;f.asset=h,f.onreadystatechange=s,f.onerror=n,f.open("GET",c,!0),"json"!==u&&(f.responseType="blob"),f.send(null)}catch(d){t.log.error("Cannot load "+c+" (Message: "+d.message+", Name: "+d.name+")")}}return r},r.displayProgress=function(e){t.isNumber(e)&&t.context&&(t.context.save(),t.context.fillStyle="black",t.context.fillRect(0,0,t.width,t.height),t.context.fillStyle="white",t.context.strokeStyle="white",t.context.textAlign="center",t.context.strokeRect(49,t.height/2-30-1,t.width-100+2,62),t.context.fillRect(50,t.height/2-30,(t.width-100)/100*e,60),t.context.font="11px verdana",t.context.fillText("Loading... "+e+"%",t.width/2,t.height/2-35),t.context.font="11px verdana",t.context.fillStyle="#ccc",t.context.textBaseline="bottom",t.context.fillText("powered by www.jawsjs.com",t.width/2,t.height-1),t.context.restore())}},t.assets=new t.Assets,t}(jaws||{});if("undefined"!=typeof require)var jaws=require("./core.js");var jaws=function(t){function e(t){this.size=t,this.values=new Array(this.size),this.value,this.add=function(t){if(this.values.length>this.size){this.values.splice(0,1),this.value=0;for(var e=0;this.values[e];e++)this.value+=this.values[e];this.value=this.value/this.size}return this.values.push(t),this},this.get=function(){return parseInt(this.value)}}return window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,16.666)}}(),t.GameLoop=function(i,s,o){if(!(this instanceof arguments.callee))return new arguments.callee(i,s);this.tick_duration=0,this.fps=0,this.ticks=0;var n,a=!1,r=!1,h=this,c=new e(20);this.runtime=function(){return this.last_tick-this.first_tick},this.start=function(){t.log.info("Game loop start",!0),this.first_tick=(new Date).getTime(),this.current_tick=(new Date).getTime(),this.last_tick=(new Date).getTime(),s.setup!==!1&&i.setup&&i.setup(o),step_delay=1e3/s.fps,60==s.fps?requestAnimFrame(this.loop):n=setInterval(this.loop,step_delay)},this.loop=function(){h.current_tick=(new Date).getTime(),h.tick_duration=h.current_tick-h.last_tick,h.fps=c.add(1e3/h.tick_duration).get(),r||a||(i.update&&i.update(),i.draw&&i.draw(),h.ticks++),60!=s.fps||r||requestAnimFrame(h.loop),h.last_tick=h.current_tick},this.pause=function(){a=!0},this.unpause=function(){a=!1},this.stop=function(){n&&clearInterval(n),r=!0}},t}(jaws||{}),jaws=function(t){var e=0;return t.Rect=function(t,i,s,o){return this instanceof arguments.callee?(this.x=t,this.y=i,this.width=s,this.height=o,this.right=t+s-e,void(this.bottom=i+o-e)):new arguments.callee(t,i,s,o)},t.Rect.prototype.getPosition=function(){return[this.x,this.y]},t.Rect.prototype.move=function(t,e){return this.x+=t,this.y+=e,this.right+=t,this.bottom+=e,this},t.Rect.prototype.moveTo=function(t,i){return this.x=t,this.y=i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.resize=function(t,i){return this.width+=t,this.height+=i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.clone=function(){return new t.Rect(this.x,this.y,this.width,this.height)},t.Rect.prototype.shrink=function(t,i){return this.x+=t,this.y+=i,this.width-=t+t,this.height-=i+i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.resizeTo=function(t,i){return this.width=t,this.height=i,this.right=this.x+this.width-e,this.bottom=this.y+this.height-e,this},t.Rect.prototype.draw=function(){return t.context.strokeStyle="red",t.context.strokeRect(this.x-.5,this.y-.5,this.width,this.height),this},t.Rect.prototype.collidePoint=function(t,e){return t>=this.x&&t<=this.right&&e>=this.y&&e<=this.bottom},t.Rect.prototype.collideRect=function(t){return(this.x>=t.x&&this.x<=t.right||t.x>=this.x&&t.x<=this.right)&&(this.y>=t.y&&this.y<=t.bottom||t.y>=this.y&&t.y<=this.bottom)},t.Rect.prototype.toString=function(){return"[Rect "+this.x+", "+this.y+", "+this.width+", "+this.height+"]"},t}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.Rect);var jaws=function(jaws){return jaws.Sprite=function(t){return this instanceof arguments.callee?(this.set(t),void(this.context=t.context?t.context:jaws.context)):new arguments.callee(t)},jaws.Sprite.prototype.default_options={x:0,y:0,alpha:1,angle:0,flipped:!1,anchor_x:0,anchor_y:0,image:null,image_path:null,anchor:null,scale_image:null,damping:1,scale_x:1,scale_y:1,scale:1,color:"#ddd",width:16,height:16,_constructor:null,context:null,data:null},jaws.Sprite.prototype.set=function(t){if(jaws.isString(this.image)&&(this.image_path=this.image),jaws.parseOptions(this,t,this.default_options),this.scale&&(this.scale_x=this.scale_y=this.scale),this.image&&this.setImage(this.image),this.scale_image&&this.scaleImage(this.scale_image),this.anchor&&this.setAnchor(this.anchor),!this.image&&this.color&&this.width&&this.height){var e=document.createElement("canvas"),i=e.getContext("2d");e.width=this.width,e.height=this.height,i.fillStyle=this.color,i.fillRect(0,0,this.width,this.height),this.image=e}return this.cacheOffsets(),this},jaws.Sprite.prototype.clone=function(object){var constructor=this._constructor?eval(this._constructor):this.constructor,new_sprite=new constructor(this.attributes());return new_sprite._constructor=this._constructor||this.constructor.name,new_sprite},jaws.Sprite.prototype.setImage=function(t){var e=this;return jaws.isDrawable(t)?(this.image=t,this.cacheOffsets()):(jaws.assets.isLoaded(t)?(this.image=jaws.assets.get(t),this.cacheOffsets()):(jaws.log.warn("Image '"+t+"' not preloaded with jaws.assets.add(). Image and a working sprite.rect() will be delayed."),jaws.assets.load(t,{onload:function(){e.image=jaws.assets.get(t),e.cacheOffsets()}})),this)},jaws.Sprite.prototype.stepToWhile=function(t,e,i){var s=1,o=t<this.x?-s:s,n=e<this.y?-s:s;t=parseInt(t),e=parseInt(e);for(var a=!1,r=!1;;)if(a===!1&&(this.x!=t&&(this.x+=o),i(this)||(this.x-=o,a=!0)),r===!1&&(this.y!=e&&(this.y+=n),i(this)||(this.y-=n,r=!0)),(a||this.x==t)&&(r||this.y==e))return{x:a,y:r}},jaws.Sprite.prototype.stepWhile=function(t,e,i){return this.stepToWhile(this.x+t,this.y+e,i)},jaws.Sprite.prototype.flip=function(){return this.flipped=this.flipped?!1:!0,this},jaws.Sprite.prototype.flipTo=function(t){return this.flipped=t,this},jaws.Sprite.prototype.rotate=function(t){return this.angle+=t,this},jaws.Sprite.prototype.rotateTo=function(t){return this.angle=t,this},jaws.Sprite.prototype.moveTo=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),this.x=t,this.y=e,this},jaws.Sprite.prototype.move=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),t&&(this.x+=t),e&&(this.y+=e),this},jaws.Sprite.prototype.scaleAll=function(t){return this.scale_x*=t,this.scale_y*=t,this.cacheOffsets()},jaws.Sprite.prototype.scaleTo=function(t){return this.scale_x=this.scale_y=t,this.cacheOffsets()},jaws.Sprite.prototype.scaleWidth=function(t){return this.scale_x*=t,this.cacheOffsets()},jaws.Sprite.prototype.scaleHeight=function(t){return this.scale_y*=t,this.cacheOffsets()},jaws.Sprite.prototype.setX=function(t){return this.x=t,this},jaws.Sprite.prototype.setY=function(t){return this.y=t,this},jaws.Sprite.prototype.setTop=function(t){return this.y=t+this.top_offset,this},jaws.Sprite.prototype.setBottom=function(t){return this.y=t-this.bottom_offset,this},jaws.Sprite.prototype.setLeft=function(t){return this.x=t+this.left_offset,this},jaws.Sprite.prototype.setRight=function(t){return this.x=t-this.right_offset,this},jaws.Sprite.prototype.setWidth=function(t){return this.scale_x=t/this.image.width,this.cacheOffsets()},jaws.Sprite.prototype.setHeight=function(t){return this.scale_y=t/this.image.height,this.cacheOffsets()},jaws.Sprite.prototype.resize=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),this.scale_x=(this.width+t)/this.image.width,this.scale_y=(this.height+e)/this.image.height,this.cacheOffsets()},jaws.Sprite.prototype.resizeTo=function(t,e){return jaws.isArray(t)&&void 0===e&&(e=t[1],t=t[0]),this.scale_x=t/this.image.width,this.scale_y=e/this.image.height,this.cacheOffsets()},jaws.Sprite.prototype.setAnchor=function(t){var e={top_left:[0,0],left_top:[0,0],center_left:[0,.5],left_center:[0,.5],bottom_left:[0,1],left_bottom:[0,1],top_center:[.5,0],center_top:[.5,0],center_center:[.5,.5],center:[.5,.5],bottom_center:[.5,1],center_bottom:[.5,1],top_right:[1,0],right_top:[1,0],center_right:[1,.5],right_center:[1,.5],bottom_right:[1,1],right_bottom:[1,1]};return(a=e[t])&&(this.anchor_x=a[0],this.anchor_y=a[1],this.image&&this.cacheOffsets()),this},jaws.Sprite.prototype.cacheOffsets=function(){return this.image?(this.width=this.image.width*this.scale_x,this.height=this.image.height*this.scale_y,this.left_offset=this.width*this.anchor_x,this.top_offset=this.height*this.anchor_y,this.right_offset=this.width*(1-this.anchor_x),this.bottom_offset=this.height*(1-this.anchor_y),this.cached_rect&&this.cached_rect.resizeTo(this.width,this.height),this):void 0},jaws.Sprite.prototype.rect=function(){return!this.cached_rect&&this.width&&(this.cached_rect=new jaws.Rect(this.x,this.y,this.width,this.height)),this.cached_rect&&this.cached_rect.moveTo(this.x-this.left_offset,this.y-this.top_offset),this.cached_rect},jaws.Sprite.prototype.draw=function(){return this.image?(this.context.save(),this.context.translate(this.x,this.y),0!=this.angle&&jaws.context.rotate(this.angle*Math.PI/180),this.flipped&&this.context.scale(-1,1),this.context.globalAlpha=this.alpha,this.context.translate(-this.left_offset,-this.top_offset),this.context.drawImage(this.image,0,0,this.width,this.height),this.context.restore(),this):this},jaws.Sprite.prototype.scaleImage=function(t){return this.image?(this.setImage(jaws.retroScaleImage(this.image,t)),this):void 0},jaws.Sprite.prototype.asCanvasContext=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");return jaws.context&&(e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled),e.drawImage(this.image,0,0,this.width,this.height),e},jaws.Sprite.prototype.asCanvas=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");return jaws.context&&(e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled),e.drawImage(this.image,0,0,this.width,this.height),t},jaws.Sprite.prototype.toString=function(){return"[Sprite "+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width+", "+this.height+"]"},jaws.Sprite.prototype.attributes=function(){var t={};return t._constructor=this._constructor||"jaws.Sprite",t.x=parseFloat(this.x.toFixed(2)),t.y=parseFloat(this.y.toFixed(2)),t.image=this.image_path,t.alpha=this.alpha,t.flipped=this.flipped,t.angle=parseFloat(this.angle.toFixed(2)),t.scale_x=this.scale_x,t.scale_y=this.scale_y,t.anchor_x=this.anchor_x,t.anchor_y=this.anchor_y,null!==this.data&&(t.data=jaws.clone(this.data)),t},jaws.Sprite.parse=function(objects){function parseArray(array){array.forEach(function(data){var constructor=data._constructor?eval(data._constructor):data.constructor;if(jaws.isFunction(constructor)){jaws.log.info("Creating "+data._constructor+"("+data.toString()+")",!0);var object=new constructor(data);object._constructor=data._constructor||data.constructor.name,sprites.push(object)}})}var sprites=[];return jaws.isArray(objects)?objects.every(function(t){return t._constructor})?parseArray(objects):sprites=objects:jaws.isString(objects)&&(parseArray(JSON.parse(objects)),jaws.log.info(objects)),sprites},jaws.Sprite.prototype.toJSON=function(){return JSON.stringify(this.attributes())},jaws}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.Sprite);var jaws=function(t){function e(t,e,i,s,o){var n=document.createElement("canvas");n.width=s,n.height=o;var a=n.getContext("2d");return a.drawImage(t,e,i,s,o,0,0,n.width,n.height),n}return t.SpriteSheet=function(i){if(!(this instanceof arguments.callee))return new arguments.callee(i);if(t.parseOptions(this,i,this.default_options),t.isString(this.image)&&!i.frame_size){var s=new RegExp("_(\\d+)x(\\d+)","g"),o=s.exec(this.image);this.frame_size=[],this.frame_size[0]=parseInt(o[1]),this.frame_size[1]=parseInt(o[2])}if(this.image=t.isDrawable(this.image)?this.image:t.assets.data[this.image],this.scale_image){var n=t.isDrawable(this.image)?this.image:t.assets.get(this.image);this.frame_size[0]*=this.scale_image,this.frame_size[1]*=this.scale_image,this.image=t.retroScaleImage(n,this.scale_image)}if(this.frames=[],"down"==this.orientation)for(var a=this.offset;a<this.image.width;a+=this.frame_size[0])for(var r=0;r<this.image.height;r+=this.frame_size[1])this.frames.push(e(this.image,a,r,this.frame_size[0],this.frame_size[1]));else for(var r=this.offset;r<this.image.height;r+=this.frame_size[1])for(var a=0;a<this.image.width;a+=this.frame_size[0])this.frames.push(e(this.image,a,r,this.frame_size[0],this.frame_size[1]))},t.SpriteSheet.prototype.default_options={image:null,orientation:"down",frame_size:[32,32],offset:0,scale_image:null},t.SpriteSheet.prototype.toString=function(){return"[SpriteSheet "+this.frames.length+" frames]"},t}(jaws||{}),jaws=function(t){return t.Animation=function(e){if(!(this instanceof arguments.callee))return new arguments.callee(e);if(t.parseOptions(this,e,this.default_options),e.sprite_sheet){var i=new t.SpriteSheet({image:e.sprite_sheet,scale_image:this.scale_image,frame_size:this.frame_size,orientation:this.orientation,offset:this.offset});this.frames=i.frames,this.frame_size=i.frame_size}if(e.scale_image){var s=t.isDrawable(e.sprite_sheet)?e.sprite_sheet:t.assets.get(e.sprite_sheet);this.frame_size[0]*=e.scale_image,this.frame_size[1]*=e.scale_image,e.sprite_sheet=t.retroScaleImage(s,e.scale_image)}if(this.current_tick=(new Date).getTime(),this.last_tick=(new Date).getTime(),this.sum_tick=0,e.subsets){this.subsets={};for(subset in e.subsets)start_stop=e.subsets[subset],this.subsets[subset]=this.slice(start_stop[0],start_stop[1])}},t.Animation.prototype.default_options={frames:[],subsets:[],frame_duration:100,index:0,loop:1,bounce:0,frame_direction:1,frame_size:null,orientation:"down",on_end:null,offset:0,scale_image:null,sprite_sheet:null},t.Animation.prototype.subset=function(t){return this.subsets[t]},t.Animation.prototype.update=function(){return this.current_tick=(new Date).getTime(),this.sum_tick+=this.current_tick-this.last_tick,this.last_tick=this.current_tick,this.sum_tick>this.frame_duration&&(this.index+=this.frame_direction,this.sum_tick=0),(this.index>=this.frames.length||this.index<0)&&(this.bounce?(this.frame_direction=-this.frame_direction,this.index+=2*this.frame_direction):this.loop?this.index=this.frame_direction<0?this.frames.length-1:0:(this.index-=this.frame_direction,this.on_end&&(this.on_end(),this.on_end=null))),this +},t.Animation.prototype.slice=function(e,i){var s={};return s.frame_duration=this.frame_duration,s.loop=this.loop,s.bounce=this.bounce,s.on_end=this.on_end,s.frame_direction=this.frame_direction,s.frames=this.frames.slice().slice(e,i),new t.Animation(s)},t.Animation.prototype.next=function(){return this.update(),this.frames[this.index]},t.Animation.prototype.atLastFrame=function(){return this.index==this.frames.length-1},t.Animation.prototype.atFirstFrame=function(){return 0==this.index},t.Animation.prototype.currentFrame=function(){return this.frames[this.index]},t.Animation.prototype.toString=function(){return"[Animation, "+this.frames.length+" frames]"},t}(jaws||{});if("undefined"!=typeof require)var jaws=require("./core.js");var jaws=function(t){function e(t,e){for(var i=function(e){return void 0!==t.isSpriteList?t.at(e):t[e]},s=[],o=new Array(e),n=0;e>n;n++)o[n]=n;for(var n=e-1,a=t.length;n>=0;a=t.length){for(s.push(o.map(i));n>=0&&o[n]===a-1;)n--,a--;if(n>=0){o[n]+=1;for(var r=n+1;e>r;r++)o[r]=o[r-1]+1;n=e-1}}return s}return t.collideOneWithOne=function(e,i){return e.radius&&i.radius&&e!==i&&t.collideCircles(e,i)?!0:e.rect&&i.rect&&e!==i&&t.collideRects(e.rect(),i.rect())?!0:!1},t.collideOneWithMany=function(e,i,s){var o=[];if(s){for(var n=0;n<i.length;n++)t.collideOneWithOne(e,i[n])&&(s(e,i[n]),o.push(i[n]));return o}return i.filter(function(i){return t.collideOneWithOne(e,i)})},t.collideManyWithMany=function(i,s,o){var n=[];return i===s?e(i,2).forEach(function(e){t.collideOneWithOne(e[0],e[1])&&(o?o(e[0],e[1]):n.push([e[0],e[1]]))}):i.forEach(function(e){s.forEach(function(i){t.collideOneWithOne(e,i)&&(o?o(e,i):n.push([e,i]))})}),n},t.collideCircles=function(e,i){return t.distanceBetween(e,i)<e.radius+i.radius},t.collideRects=function(t,e){return(t.x>=e.x&&t.x<=e.right||e.x>=t.x&&e.x<=t.right)&&(t.y>=e.y&&t.y<=e.bottom||e.y>=t.y&&e.y<=t.bottom)},t.distanceBetween=function(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))},t.collide=function(e,i,s){if((e.rect||e.radius)&&i.forEach)return t.collideOneWithMany(e,i,s).length>0;if(e.forEach&&i.forEach)return t.collideManyWithMany(e,i,s).length>0;if(e.forEach&&(i.rect||i.radius))return t.collideOneWithMany(i,e,s).length>0;if(e.rect&&i.rect||e.radius&&i.radius){var o=t.collideOneWithOne(e,i);if(!s||!o)return o;s(e,i)}},t}(jaws||{}),jaws=function(t){return t.PixelMap=function(e){return this instanceof arguments.callee?(this.options=e,this.scale=e.scale||1,this.x=e.x||0,this.y=e.y||0,e.image?(this.setContext(e.image),e.scale_image&&this.setContext(t.retroScaleImage(this.context.canvas,e.scale_image)),this.width=this.context.canvas.width*this.scale,this.height=this.context.canvas.height*this.scale):t.log.warn("PixelMap needs an image to work with"),this.named_colors=[],void this.update()):new arguments.callee(e)},t.PixelMap.prototype.setContext=function(e){var e=t.isDrawable(e)?e:t.assets.get(e);this.context=t.imageToCanvasContext(e)},t.PixelMap.prototype.update=function(t,e,i,s){if((void 0===t||0>t)&&(t=0),(void 0===e||0>e)&&(e=0),(void 0===i||i>this.width)&&(i=this.width),(void 0===s||s>this.height)&&(s=this.height),0==arguments.length)this.data=this.context.getImageData(t,e,i,s).data;else for(var o=this.context.getImageData(t,e,i,s).data,n=0,a=4*this.width,r=e*this.width*4+4*t,h=4*i,c=0;s>c;c++){for(var l=0;h>l;l++)this.data[r+l]=o[n++];r+=a}},t.PixelMap.prototype.draw=function(){t.context.drawImage(this.context.canvas,this.x,this.y,this.width,this.height)},t.PixelMap.prototype.namedColorAtRect=function(t,e){for(var i=t.x,s=t.y;i<t.right-1;i++)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);for(;s<t.bottom-1;s++)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);for(;i>t.x;i--)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);for(;s>t.y;s--)if(this.namedColorAt(i,s)==e||void 0===e)return this.namedColorAt(i,s);return!1},t.PixelMap.prototype.at=function(t,e){t=parseInt(t),e=parseInt(e),0>e&&(e=0);var i=e*this.width*4+4*t,s=this.data[i],o=this.data[i+1],n=this.data[i+2],a=this.data[i+3];return[s,o,n,a]},t.PixelMap.prototype.namedColorAt=function(t,e){for(var i=this.at(t,e),s=0;s<this.named_colors.length;s++){var o=this.named_colors[s].name,n=this.named_colors[s].color;if(n[0]==i[0]&&n[1]==i[1]&&n[2]==i[2]&&n[3]==i[3])return o}},t.PixelMap.prototype.nameColor=function(t,e){this.named_colors.push({name:e,color:t})},t}(jaws||{}),jaws=function(t){return t.Parallax=function(e){return this instanceof arguments.callee?void t.parseOptions(this,e,this.default_options):new arguments.callee(e)},t.Parallax.prototype.default_options={width:function(){return t.width},height:function(){return t.height},scale:1,repeat_x:null,repeat_y:null,camera_x:0,camera_y:0,layers:[]},t.Parallax.prototype.draw=function(){for(var t,e,i=0;i<this.layers.length;i++)for(t=this.layers[i],e=this.repeat_x?-(this.camera_x/t.damping%t.width):-(this.camera_x/t.damping),t.y=this.repeat_y?-(this.camera_y/t.damping%t.height):-(this.camera_y/t.damping),t.x=e;t.y<this.height;){for(;t.x<this.width&&(t.x+t.width>=0&&t.y+t.height>=0&&t.draw(),t.x=t.x+t.width,this.repeat_x););if(t.y=t.y+t.height,t.x=e,!this.repeat_y)break}},t.Parallax.prototype.addLayer=function(e){var i=new t.ParallaxLayer(e);i.scaleAll(this.scale),this.layers.push(i)},t.Parallax.prototype.toString=function(){return"[Parallax "+this.x+", "+this.y+". "+this.layers.length+" layers]"},t.ParallaxLayer=function(e){return this instanceof arguments.callee?(this.damping=e.damping||0,void t.Sprite.call(this,e)):new arguments.callee(e)},t.ParallaxLayer.prototype=t.Sprite.prototype,t}(jaws||{}),jaws=function(jaws){return jaws.Text=function(t){return this instanceof arguments.callee?(this.set(t),t.context&&(this.context=t.context),void(t.context||jaws.context&&(this.context=jaws.context))):new arguments.callee(t)},jaws.Text.prototype.default_options={x:0,y:0,alpha:1,angle:0,anchor_x:0,anchor_y:0,anchor:"top_left",damping:1,style:"normal",fontFace:"serif",fontSize:12,color:"black",textAlign:"start",textBaseline:"alphabetic",text:"",wordWrap:!1,width:function(){return jaws.width},height:function(){return jaws.height},shadowColor:null,shadowBlur:null,shadowOffsetX:null,shadowOffsetY:null,_constructor:null},jaws.Text.prototype.set=function(t){return jaws.parseOptions(this,t,this.default_options),this.anchor&&this.setAnchor(this.anchor),this.cacheOffsets(),this},jaws.Text.prototype.clone=function(){var constructor=this._constructor?eval(this._constructor):this.constructor,new_sprite=new constructor(this.attributes());return new_sprite._constructor=this._constructor||this.constructor.name,new_sprite},jaws.Text.prototype.rotate=function(t){return this.angle+=t,this},jaws.Text.prototype.rotateTo=function(t){return this.angle=t,this},jaws.Text.prototype.moveTo=function(t,e){return this.x=t,this.y=e,this},jaws.Text.prototype.move=function(t,e){return t&&(this.x+=t),e&&(this.y+=e),this},jaws.Text.prototype.setX=function(t){return this.x=t,this},jaws.Text.prototype.setY=function(t){return this.y=t,this},jaws.Text.prototype.setTop=function(t){return this.y=t+this.top_offset,this},jaws.Text.prototype.setBottom=function(t){return this.y=t-this.bottom_offset,this},jaws.Text.prototype.setLeft=function(t){return this.x=t+this.left_offset,this},jaws.Text.prototype.setRight=function(t){return this.x=t-this.right_offset,this},jaws.Text.prototype.setWidth=function(t){return this.width=t,this.cacheOffsets(),this},jaws.Text.prototype.setHeight=function(t){return this.height=t,this.cacheOffsets(),this},jaws.Text.prototype.resize=function(t,e){return this.width+=t,this.height+=e,this.cacheOffsets(),this},jaws.Text.prototype.resizeTo=function(t,e){return this.width=t,this.height=e,this.cacheOffsets(),this},jaws.Text.prototype.setAnchor=function(t){var e={top_left:[0,0],left_top:[0,0],center_left:[0,.5],left_center:[0,.5],bottom_left:[0,1],left_bottom:[0,1],top_center:[.5,0],center_top:[.5,0],center_center:[.5,.5],center:[.5,.5],bottom_center:[.5,1],center_bottom:[.5,1],top_right:[1,0],right_top:[1,0],center_right:[1,.5],right_center:[1,.5],bottom_right:[1,1],right_bottom:[1,1]};return e.hasOwnProperty(t)&&(this.anchor_x=e[t][0],this.anchor_y=e[t][1],this.cacheOffsets()),this},jaws.Text.prototype.cacheOffsets=function(){return this.left_offset=this.width*this.anchor_x,this.top_offset=this.height*this.anchor_y,this.right_offset=this.width*(1-this.anchor_x),this.bottom_offset=this.height*(1-this.anchor_y),this.cached_rect&&this.cached_rect.resizeTo(this.width,this.height),this},jaws.Text.prototype.rect=function(){return!this.cached_rect&&this.width&&(this.cached_rect=new jaws.Rect(this.x,this.y,this.width,this.height)),this.cached_rect&&this.cached_rect.moveTo(this.x-this.left_offset,this.y-this.top_offset),this.cached_rect},jaws.Text.prototype.draw=function(){this.context.save(),0!==this.angle&&this.context.rotate(this.angle*Math.PI/180),this.context.globalAlpha=this.alpha,this.context.translate(-this.left_offset,-this.top_offset),this.context.fillStyle=this.color,this.context.font=this.style+" "+this.fontSize+"px "+this.fontFace,this.context.textBaseline=this.textBaseline,this.context.textAlign=this.textAlign,this.shadowColor&&(this.context.shadowColor=this.shadowColor),this.shadowBlur&&(this.context.shadowBlur=this.shadowBlur),this.shadowOffsetX&&(this.context.shadowOffsetX=this.shadowOffsetX),this.shadowOffsetY&&(this.context.shadowOffsetY=this.shadowOffsetY);var t=this.y,e=this.x;if(this.wordWrap)for(var i=this.text.split(" "),s="",o=0;o<i.length;o++){var n=s+i[o]+" ",a=this.context.measureText(n);this.y<t+this.height&&(a.width>this.width?(this.context.fillText(s,this.x,this.y),s=i[o]+" ",this.y+=this.fontSize):s=n,this.context.fillText(s,this.x,this.y))}else if(this.context.measureText(this.text).width<this.width)this.context.fillText(this.text,this.x,this.y);else for(var i=this.text.split(" "),s=" ",o=0;o<i.length;o++){var n=s+i[o]+" ";this.context.measureText(n).width<Math.abs(this.width-this.x)&&(this.context.fillText(n,this.x,this.y),s=i[o]+" ",s=n)}return this.y=t,this.x=e,this.context.restore(),this},jaws.Text.prototype.asCanvasContext=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled,this.context.fillStyle=this.color,this.context.font=this.style+this.fontSize+"px "+this.fontFace,this.context.textBaseline=this.textBaseline,this.context.textAlign=this.textAlign,this.shadowColor&&(this.context.shadowColor=this.shadowColor),this.shadowBlur&&(this.context.shadowBlur=this.shadowBlur),this.shadowOffsetX&&(this.context.shadowOffsetX=this.shadowOffsetX),this.shadowOffsetY&&(this.context.shadowOffsetY=this.shadowOffsetY);var i=this.y,s=this.x;if(this.wordWrap)for(var o=this.text.split(" "),n="",a=0;a<o.length;a++){var r=n+o[a]+" ",h=this.context.measureText(r);this.y<i+this.height&&(h.width>this.width?(this.context.fillText(n,this.x,this.y),n=o[a]+" ",this.y+=this.fontSize):n=r,this.context.fillText(n,this.x,this.y))}else if(this.context.measureText(this.text).width<this.width)this.context.fillText(this.text,this.x,this.y);else for(var o=this.text.split(" "),n=" ",a=0;a<o.length;a++){var r=n+o[a]+" ";this.context.measureText(r).width<Math.abs(this.width-this.x)&&(this.context.fillText(r,this.x,this.y),n=o[a]+" ",n=r)}return this.y=i,this.x=s,e},jaws.Text.prototype.asCanvas=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");e.mozImageSmoothingEnabled=jaws.context.mozImageSmoothingEnabled,this.context.fillStyle=this.color,this.context.font=this.style+this.fontSize+"px "+this.fontFace,this.context.textBaseline=this.textBaseline,this.context.textAlign=this.textAlign,this.shadowColor&&(this.context.shadowColor=this.shadowColor),this.shadowBlur&&(this.context.shadowBlur=this.shadowBlur),this.shadowOffsetX&&(this.context.shadowOffsetX=this.shadowOffsetX),this.shadowOffsetY&&(this.context.shadowOffsetY=this.shadowOffsetY);var i=this.y,s=this.x;if(this.wordWrap)for(var o=this.text.split(" "),n="",a=0;a<o.length;a++){var r=n+o[a]+" ",h=e.measureText(r);this.y<i+this.height&&(h.width>this.width?(e.fillText(n,this.x,this.y),n=o[a]+" ",this.y+=this.fontSize):n=r,e.fillText(n,this.x,this.y))}else if(e.measureText(this.text).width<this.width)this.context.fillText(this.text,this.x,this.y);else for(var o=this.text.split(" "),n=" ",a=0;a<o.length;a++){var r=n+o[a]+" ";e.measureText(r).width<Math.abs(this.width-this.x)&&(e.fillText(r,this.x,this.y),n=o[a]+" ",n=r)}return this.y=i,this.x=s,t},jaws.Text.prototype.toString=function(){return"[Text "+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width+", "+this.height+"]"},jaws.Text.prototype.attributes=function(){var t=this.options;return t._constructor=this._constructor||"jaws.Text",t.x=parseFloat(this.x.toFixed(2)),t.y=parseFloat(this.y.toFixed(2)),t.text=this.text,t.alpha=this.alpha,t.angle=parseFloat(this.angle.toFixed(2)),t.anchor_x=this.anchor_x,t.anchor_y=this.anchor_y,t.style=this.style,t.fontSize=this.fontSize,t.fontFace=this.fontFace,t.color=this.color,t.textAlign=this.textAlign,t.textBaseline=this.textBaseline,t.wordWrap=this.wordWrap,t.width=this.width,t.height=this.height,t},jaws.Text.prototype.toJSON=function(){return JSON.stringify(this.attributes())},jaws}(jaws||{});if("undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.Text),"undefined"!=typeof require)var jaws=require("./core.js");var jaws=function(t){return t.QuadTree=function(e){this.depth=arguments[1]||0,this.bounds=e||new t.Rect(0,0,t.width,t.height),this.nodes=[],this.objects=[]},t.QuadTree.prototype.clear=function(){this.objects=[];for(var t=0;t<this.nodes.length;t++)"undefined"!=typeof this.nodes[t]&&(this.nodes[t].clear(),delete this.nodes[t])},t.QuadTree.prototype.split=function(){var e=Math.round(this.bounds.width/2),i=Math.round(this.bounds.height/2),s=this.bounds.x,o=this.bounds.y;this.nodes[0]=new t.QuadTree(new t.Rect(s+e,o,e,i),this.depth+1),this.nodes[1]=new t.QuadTree(new t.Rect(s,o,e,i),this.depth+1),this.nodes[2]=new t.QuadTree(new t.Rect(s,o+i,e,i),this.depth+1),this.nodes[3]=new t.QuadTree(new t.Rect(s+e,o+i,e,i),this.depth+1)},t.QuadTree.prototype.getIndex=function(t){var e=-1,i=this.bounds.x+this.bounds.width/2,s=this.bounds.y+this.bounds.height/2,o=t.y<s&&t.y+t.height<s,n=t.y>s;return t.x<i&&t.x+t.width<i?o?e=1:n&&(e=2):t.x>i&&(o?e=0:n&&(e=3)),e},t.QuadTree.prototype.insert=function(t){if(t.hasOwnProperty("x")||t.hasOwnProperty("y")||t.hasOwnProperty("width")||t.hasOwnProperty("height")){if("undefined"!=typeof this.nodes[0]){var e=this.getIndex(t);if(-1!==e)return void this.nodes[e].insert(t)}this.objects.push(t),"undefined"==typeof this.nodes[0]&&this.split();for(var i=0;i<this.objects.length;){var e=this.getIndex(this.objects[i]);-1!==e?this.nodes[e].insert(this.objects.splice(i,1)[0]):i++}}},t.QuadTree.prototype.retrieve=function(t){if(t.hasOwnProperty("x")||t.hasOwnProperty("y")||t.hasOwnProperty("width")||t.hasOwnProperty("height")){var e=this.getIndex(t),i=this.objects;if("undefined"!=typeof this.nodes[0])if(-1!==e)i=i.concat(this.nodes[e].retrieve(t));else for(var s=0;s<this.nodes.length;s++)i=i.concat(this.nodes[s].retrieve(t));return i}},t.QuadTree.prototype.collide=function(e,i,s){var o=!1,n=new t.QuadTree,a=[];return e.forEach||(a.push(e),e=a),i.forEach||(a=[],a.push(i),i=a),i.forEach(function(t){n.insert(t)}),e.forEach(function(e){t.collide(e,n.retrieve(e),s)&&(o=!0)}),n.clear(),o},t}(jaws||{});"undefined"!=typeof module&&"exports"in module&&(module.exports=jaws.QuadTree),window.addEventListener("load",function(){jaws.onload&&jaws.onload()},!1);
\ No newline at end of file diff --git a/jaws/jaws.js b/jaws/jaws.js index 9b3ebd4..2090b4e 100644..100755 --- a/jaws/jaws.js +++ b/jaws/jaws.js @@ -1,4 +1,4 @@ -/* Built at: Sun Oct 05 2014 16:32:43 GMT+0200 (CEST) */ +/* Built at: Sun Oct 05 2014 18:48:22 GMT+0200 (CEST) */ /** * @namespace JawsJS core functions. * @@ -717,62 +717,18 @@ var jaws = (function(jaws) { var pressed_keys = {} var previously_pressed_keys = {} - var keycode_to_string = [] + var keyCodes = {"0":"48","1":"49","2":"50","3":"51","4":"52","5":"53","6":"54","7":"55","8":"56","9":"57","backspace":"8","tab":"9","enter":"13","shift":"16","ctrl":"17","alt":"18","pause":"19","caps_lock":"20","esc":"27","space":"32","page_up":"33","page_down":"34","end":"35","home":"36","left":"37","up":"38","right":"39","down":"40","insert":"45","delete":"46","a":"65","b":"66","c":"67","d":"68","e":"69","f":"70","g":"71","h":"72","i":"73","j":"74","k":"75","l":"76","m":"77","n":"78","o":"79","p":"80","q":"81","r":"82","s":"83","t":"84","u":"85","v":"86","w":"87","x":"88","y":"89","z":"90","windows_left":"91","windows_right":"92","select":"93","numpad0":"96","numpad1":"97","numpad2":"98","numpad3":"99","numpad4":"100","numpad5":"101","numpad6":"102","numpad7":"103","numpad8":"104","numpad9":"105","asterisk":"106","plus":"107","minus":"109","decimal_point":"110","divide":"111","f1":"112","f2":"113","f3":"114","f4":"115","f5":"116","f6":"117","f7":"118","f8":"119","f9":"120","numlock":"144","scrollock":"145","semicolon":"186","equals":"187","comma":"188","dash":"189","period":"190","slash":"191","grave_accent":"192","open_bracket":"219","backslash":"220","close_bracket":"221","single_quote":"222"}; + var keycodeNames = {"8":"backspace","9":"tab","13":"enter","16":"shift","17":"ctrl","18":"alt","19":"pause","20":"caps_lock","27":"esc","32":"space","33":"page_up","34":"page_down","35":"end","36":"home","37":"left","38":"up","39":"right","40":"down","45":"insert","46":"delete","48":"0","49":"1","50":"2","51":"3","52":"4","53":"5","54":"6","55":"7","56":"8","57":"9","65":"a","66":"b","67":"c","68":"d","69":"e","70":"f","71":"g","72":"h","73":"i","74":"j","75":"k","76":"l","77":"m","78":"n","79":"o","80":"p","81":"q","82":"r","83":"s","84":"t","85":"u","86":"v","87":"w","88":"x","89":"y","90":"z","91":"windows_left","92":"windows_right","93":"select","96":"numpad0","97":"numpad1","98":"numpad2","99":"numpad3","100":"numpad4","101":"numpad5","102":"numpad6","103":"numpad7","104":"numpad8","105":"numpad9","106":"asterisk","107":"plus","109":"minus","110":"decimal_point","111":"divide","112":"f1","113":"f2","114":"f3","115":"f4","116":"f5","117":"f6","118":"f7","119":"f8","120":"f9","144":"numlock","145":"scrollock","186":"semicolon","187":"equals","188":"comma","189":"dash","190":"period","191":"slash","192":"grave_accent","219":"open_bracket","220":"backslash","221":"close_bracket","222":"single_quote"}; var on_keydown_callbacks = [] var on_keyup_callbacks = [] var mousebuttoncode_to_string = [] var ie_mousebuttoncode_to_string = [] + var prevent_default_keys = [] /** @private * Map all javascript keycodes to easy-to-remember letters/words */ jaws.setupInput = function() { - var k = [] - - k[8] = "backspace" - k[9] = "tab" - k[13] = "enter" - k[16] = "shift" - k[17] = "ctrl" - k[18] = "alt" - k[19] = "pause" - k[20] = "capslock" - k[27] = "esc" - k[32] = "space" - k[33] = "pageup" - k[34] = "pagedown" - k[35] = "end" - k[36] = "home" - k[37] = "left" - k[38] = "up" - k[39] = "right" - k[40] = "down" - k[45] = "insert" - k[46] = "delete" - - k[91] = "left_window_key leftwindowkey" - k[92] = "right_window_key rightwindowkey" - k[93] = "select_key selectkey" - k[106] = "multiply *" - k[107] = "add plus +" - k[109] = "subtract minus -" - k[110] = "decimalpoint" - k[111] = "divide /" - - k[144] = "numlock" - k[145] = "scrollock" - k[186] = "semicolon ;" - k[187] = "equalsign =" - k[188] = "comma ," - k[189] = "dash -" - k[190] = "period ." - k[191] = "forwardslash /" - k[192] = "graveaccent `" - k[219] = "openbracket [" - k[220] = "backslash \\" - k[221] = "closebracket ]" - k[222] = "singlequote '" - var m = [] m[0] = "left_mouse_button" @@ -787,20 +743,8 @@ jaws.setupInput = function() { mousebuttoncode_to_string = m ie_mousebuttoncode_to_string = ie_m; - - var numpadkeys = ["numpad0","numpad1","numpad2","numpad3","numpad4","numpad5","numpad6","numpad7","numpad8","numpad9"] - var fkeys = ["f1","f2","f3","f4","f5","f6","f7","f8","f9"] - var numbers = ["0","1","2","3","4","5","6","7","8","9"] - var letters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] - for(var i = 0; numbers[i]; i++) { k[48+i] = numbers[i] } - for(var i = 0; letters[i]; i++) { k[65+i] = letters[i] } - for(var i = 0; numpadkeys[i]; i++) { k[96+i] = numpadkeys[i] } - for(var i = 0; fkeys[i]; i++) { k[112+i] = fkeys[i] } - - keycode_to_string = k - - window.addEventListener("keydown", handleKeyDown) - window.addEventListener("keyup", handleKeyUp) + window.addEventListener("keydown", handleKeyDown); + window.addEventListener("keyup", handleKeyUp); var jawswindow = jaws.canvas || jaws.dom jawswindow.addEventListener("mousedown", handleMouseDown, false); @@ -818,57 +762,53 @@ jaws.setupInput = function() { * Reset input-hash. Called when game is blurred so a key-controlled player doesn't keep on moving when the game isn't focused. */ function resetPressedKeys(e) { - pressed_keys = {}; + for (var x in pressed_keys) { + delete pressed_keys[x]; + } } /** @private * handle event "onkeydown" by remembering what key was pressed */ function handleKeyUp(e) { - event = (e) ? e : window.event - var human_names = keycode_to_string[event.keyCode]; - if (human_names == null) return; - human_names = human_names.split(" "); - human_names.forEach( function(human_name) { - pressed_keys[human_name] = false - if(on_keyup_callbacks[human_name]) { - on_keyup_callbacks[human_name](human_name) - e.preventDefault() - } - if(prevent_default_keys[human_name]) { e.preventDefault() } - }); + /* event = (e) ? e : window.event; */ /* Seems unnecessary because e is assumed to be non-null later */ + var code = code = e.keyCode; + pressed_keys[code] = false; + if (on_keyup_callbacks[code]) { + on_keyup_callbacks[code](code) + e.preventDefault() + } else if (prevent_default_keys[code]) { + e.preventDefault(); + } } /** @private * handle event "onkeydown" by remembering what key was un-pressed */ function handleKeyDown(e) { - event = (e) ? e : window.event - var human_names = keycode_to_string[event.keyCode]; - if (human_names == null) return; - human_names = human_names.split(" "); - human_names.forEach( function(human_name) { - pressed_keys[human_name] = true - if(on_keydown_callbacks[human_name]) { - on_keydown_callbacks[human_name](human_name) - e.preventDefault() - } - if(prevent_default_keys[human_name]) { e.preventDefault() } - }); + /* event = (e) ? e : window.event; */ /* Seems unnecessary because e is assumed to be non-null later */ + var code = code = e.keyCode; + pressed_keys[code] = true; + if (on_keydown_callbacks[code]) { + on_keydown_callbacks[code](code); + e.preventDefault(); + } else if (prevent_default_keys[code]) { + e.preventDefault(); + } } /** @private * handle event "onmousedown" by remembering what button was pressed */ function handleMouseDown(e) { - event = (e) ? e : window.event - var human_name = mousebuttoncode_to_string[event.button] // 0 1 2 + /* event = (e) ? e : window.event; */ /* Seems unnecessary because e is assumed to be non-null later */ + var human_name = mousebuttoncode_to_string[e.button]; // 0 1 2 if (navigator.appName == "Microsoft Internet Explorer"){ - human_name = ie_mousebuttoncode_to_string[event.button]; + human_name = ie_mousebuttoncode_to_string[e.button]; } pressed_keys[human_name] = true if(on_keydown_callbacks[human_name]) { - on_keydown_callbacks[human_name](human_name) - e.preventDefault() + on_keydown_callbacks[human_name](human_name); + e.preventDefault(); } } @@ -877,16 +817,16 @@ function handleMouseDown(e) { * handle event "onmouseup" by remembering what button was un-pressed */ function handleMouseUp(e) { - event = (e) ? e : window.event - var human_name = mousebuttoncode_to_string[event.button] + /* event = (e) ? e : window.event; */ /* Seems unnecessary because e is assumed to be non-null later */ + var human_name = mousebuttoncode_to_string[e.button] if (navigator.appName == "Microsoft Internet Explorer"){ - human_name = ie_mousebuttoncode_to_string[event.button]; + human_name = ie_mousebuttoncode_to_string[e.button]; } - pressed_keys[human_name] = false + pressed_keys[human_name] = false; if(on_keyup_callbacks[human_name]) { - on_keyup_callbacks[human_name](human_name) - e.preventDefault() + on_keyup_callbacks[human_name](human_name); + e.preventDefault(); } } @@ -894,7 +834,7 @@ function handleMouseUp(e) { * handle event "touchstart" by remembering what button was pressed */ function handleTouchStart(e) { - event = (e) ? e : window.event + /* event = (e) ? e : window.event; */ /* Seems unnecessary because e is assumed to be non-null later */ pressed_keys["left_mouse_button"] = true jaws.mouse_x = e.touches[0].pageX - jaws.canvas.offsetLeft; jaws.mouse_y = e.touches[0].pageY - jaws.canvas.offsetTop; @@ -905,14 +845,11 @@ function handleTouchStart(e) { * handle event "touchend" by remembering what button was pressed */ function handleTouchEnd(e) { - event = (e) ? e : window.event - pressed_keys["left_mouse_button"] = false - jaws.mouse_x = undefined; - jaws.mouse_y = undefined; - + pressed_keys["left_mouse_button"] = false; + jaws.mouse_x = undefined; + jaws.mouse_y = undefined; } -var prevent_default_keys = [] /** * Prevents default browseraction for given keys. * @example @@ -920,62 +857,39 @@ var prevent_default_keys = [] */ jaws.preventDefaultKeys = function(array_of_strings) { var list = arguments; - if(list.length == 1 && jaws.isArray(list[0])) list = list[0]; - for(var i=0; i < list.length; i++) { prevent_default_keys[list[i]] = true; } } /** - * Check if *keys* are pressed. Second argument specifies use of logical AND when checking multiple keys. - * @example - * jaws.pressed("left a"); // returns true if left arrow key OR a is pressed - * jaws.pressed("ctrl c", true); // returns true if ctrl AND a is pressed + * Array: If a key is currently pressed, the value associated to the key is true, otherwise false or not present. */ -jaws.pressed = function(keys, logical_and) { - if(jaws.isString(keys)) { keys = keys.split(" ") } - if(logical_and) { return keys.every( function(key) { return pressed_keys[key] } ) } - else { return keys.some( function(key) { return pressed_keys[key] } ) } -} +jaws.pressed = pressed_keys; /** - * Check if *keys* are pressed, but only return true Once for any given keys. Once keys have been released, pressedWithoutRepeat can return true again when keys are pressed. - * Second argument specifies use of logical AND when checking multiple keys. - * @example - * if(jaws.pressedWithoutRepeat("space")) { player.jump() } // with this in the gameloop player will only jump once even if space is held down + * Mapping key names to codes, and vice-versa */ -jaws.pressedWithoutRepeat = function(keys, logical_and) { - if( jaws.pressed(keys, logical_and) ) { - if(!previously_pressed_keys[keys]) { - previously_pressed_keys[keys] = true - return true - } - } - else { - previously_pressed_keys[keys] = false - return false - } -} +jaws.keyCodes = keyCodes; +jaws.keycodeNames = keycodeNames; /** * sets up a callback for a key (or array of keys) to call when it's pressed down * * @example * // call goLeft() when left arrow key is pressed - * jaws.on_keypress("left", goLeft) + * jaws.on_keypress(jaws.keyCode("left"), goLeft) * * // call fireWeapon() when SPACE or CTRL is pressed - * jaws.on_keypress(["space","ctrl"], fireWeapon) + * jaws.on_keypress([jaws.keyCodes["space"],jaws.keyCodes["ctrl"]], fireWeapon) */ jaws.on_keydown = function(key, callback) { - if(jaws.isArray(key)) { - for(var i=0; key[i]; i++) { - on_keydown_callbacks[key[i]] = callback + if (jaws.isArray(key)) { + for (var i=0; key[i]; i++) { + on_keydown_callbacks[key[i]] = callback; } - } - else { - on_keydown_callbacks[key] = callback + } else { + on_keydown_callbacks[key] = callback; } } @@ -983,13 +897,12 @@ jaws.on_keydown = function(key, callback) { * sets up a callback when a key (or array of keys) to call when it's released */ jaws.on_keyup = function(key, callback) { - if(jaws.isArray(key)) { - for(var i=0; key[i]; i++) { - on_keyup_callbacks[key[i]] = callback + if (jaws.isArray(key)) { + for (var i=0; key[i]; i++) { + on_keyup_callbacks[key[i]] = callback; } - } - else { - on_keyup_callbacks[key] = callback + } else { + on_keyup_callbacks[key] = callback; } } @@ -997,8 +910,8 @@ jaws.on_keyup = function(key, callback) { * Clean up all callbacks set by on_keydown / on_keyup */ jaws.clearKeyCallbacks = function() { - on_keyup_callbacks = [] - on_keydown_callbacks = [] + on_keyup_callbacks = []; + on_keydown_callbacks = []; } return jaws; diff --git a/jaws/src/input.js b/jaws/src/input.js index 263d793..fd3195f 100755 --- a/jaws/src/input.js +++ b/jaws/src/input.js @@ -2,62 +2,18 @@ var jaws = (function(jaws) { var pressed_keys = {} var previously_pressed_keys = {} - var keycode_to_string = [] + var keyCodes = {"0":"48","1":"49","2":"50","3":"51","4":"52","5":"53","6":"54","7":"55","8":"56","9":"57","backspace":"8","tab":"9","enter":"13","shift":"16","ctrl":"17","alt":"18","pause":"19","caps_lock":"20","esc":"27","space":"32","page_up":"33","page_down":"34","end":"35","home":"36","left":"37","up":"38","right":"39","down":"40","insert":"45","delete":"46","a":"65","b":"66","c":"67","d":"68","e":"69","f":"70","g":"71","h":"72","i":"73","j":"74","k":"75","l":"76","m":"77","n":"78","o":"79","p":"80","q":"81","r":"82","s":"83","t":"84","u":"85","v":"86","w":"87","x":"88","y":"89","z":"90","windows_left":"91","windows_right":"92","select":"93","numpad0":"96","numpad1":"97","numpad2":"98","numpad3":"99","numpad4":"100","numpad5":"101","numpad6":"102","numpad7":"103","numpad8":"104","numpad9":"105","asterisk":"106","plus":"107","minus":"109","decimal_point":"110","divide":"111","f1":"112","f2":"113","f3":"114","f4":"115","f5":"116","f6":"117","f7":"118","f8":"119","f9":"120","numlock":"144","scrollock":"145","semicolon":"186","equals":"187","comma":"188","dash":"189","period":"190","slash":"191","grave_accent":"192","open_bracket":"219","backslash":"220","close_bracket":"221","single_quote":"222"}; + var keycodeNames = {"8":"backspace","9":"tab","13":"enter","16":"shift","17":"ctrl","18":"alt","19":"pause","20":"caps_lock","27":"esc","32":"space","33":"page_up","34":"page_down","35":"end","36":"home","37":"left","38":"up","39":"right","40":"down","45":"insert","46":"delete","48":"0","49":"1","50":"2","51":"3","52":"4","53":"5","54":"6","55":"7","56":"8","57":"9","65":"a","66":"b","67":"c","68":"d","69":"e","70":"f","71":"g","72":"h","73":"i","74":"j","75":"k","76":"l","77":"m","78":"n","79":"o","80":"p","81":"q","82":"r","83":"s","84":"t","85":"u","86":"v","87":"w","88":"x","89":"y","90":"z","91":"windows_left","92":"windows_right","93":"select","96":"numpad0","97":"numpad1","98":"numpad2","99":"numpad3","100":"numpad4","101":"numpad5","102":"numpad6","103":"numpad7","104":"numpad8","105":"numpad9","106":"asterisk","107":"plus","109":"minus","110":"decimal_point","111":"divide","112":"f1","113":"f2","114":"f3","115":"f4","116":"f5","117":"f6","118":"f7","119":"f8","120":"f9","144":"numlock","145":"scrollock","186":"semicolon","187":"equals","188":"comma","189":"dash","190":"period","191":"slash","192":"grave_accent","219":"open_bracket","220":"backslash","221":"close_bracket","222":"single_quote"}; var on_keydown_callbacks = [] var on_keyup_callbacks = [] var mousebuttoncode_to_string = [] var ie_mousebuttoncode_to_string = [] + var prevent_default_keys = [] /** @private * Map all javascript keycodes to easy-to-remember letters/words */ jaws.setupInput = function() { - var k = [] - - k[8] = "backspace" - k[9] = "tab" - k[13] = "enter" - k[16] = "shift" - k[17] = "ctrl" - k[18] = "alt" - k[19] = "pause" - k[20] = "capslock" - k[27] = "esc" - k[32] = "space" - k[33] = "pageup" - k[34] = "pagedown" - k[35] = "end" - k[36] = "home" - k[37] = "left" - k[38] = "up" - k[39] = "right" - k[40] = "down" - k[45] = "insert" - k[46] = "delete" - - k[91] = "left_window_key leftwindowkey" - k[92] = "right_window_key rightwindowkey" - k[93] = "select_key selectkey" - k[106] = "multiply *" - k[107] = "add plus +" - k[109] = "subtract minus -" - k[110] = "decimalpoint" - k[111] = "divide /" - - k[144] = "numlock" - k[145] = "scrollock" - k[186] = "semicolon ;" - k[187] = "equalsign =" - k[188] = "comma ," - k[189] = "dash -" - k[190] = "period ." - k[191] = "forwardslash /" - k[192] = "graveaccent `" - k[219] = "openbracket [" - k[220] = "backslash \\" - k[221] = "closebracket ]" - k[222] = "singlequote '" - var m = [] m[0] = "left_mouse_button" @@ -72,20 +28,8 @@ jaws.setupInput = function() { mousebuttoncode_to_string = m ie_mousebuttoncode_to_string = ie_m; - - var numpadkeys = ["numpad0","numpad1","numpad2","numpad3","numpad4","numpad5","numpad6","numpad7","numpad8","numpad9"] - var fkeys = ["f1","f2","f3","f4","f5","f6","f7","f8","f9"] - var numbers = ["0","1","2","3","4","5","6","7","8","9"] - var letters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] - for(var i = 0; numbers[i]; i++) { k[48+i] = numbers[i] } - for(var i = 0; letters[i]; i++) { k[65+i] = letters[i] } - for(var i = 0; numpadkeys[i]; i++) { k[96+i] = numpadkeys[i] } - for(var i = 0; fkeys[i]; i++) { k[112+i] = fkeys[i] } - - keycode_to_string = k - - window.addEventListener("keydown", handleKeyDown) - window.addEventListener("keyup", handleKeyUp) + window.addEventListener("keydown", handleKeyDown); + window.addEventListener("keyup", handleKeyUp); var jawswindow = jaws.canvas || jaws.dom jawswindow.addEventListener("mousedown", handleMouseDown, false); @@ -103,57 +47,53 @@ jaws.setupInput = function() { * Reset input-hash. Called when game is blurred so a key-controlled player doesn't keep on moving when the game isn't focused. */ function resetPressedKeys(e) { - pressed_keys = {}; + for (var x in pressed_keys) { + delete pressed_keys[x]; + } } /** @private * handle event "onkeydown" by remembering what key was pressed */ function handleKeyUp(e) { - event = (e) ? e : window.event - var human_names = keycode_to_string[event.keyCode]; - if (human_names == null) return; - human_names = human_names.split(" "); - human_names.forEach( function(human_name) { - pressed_keys[human_name] = false - if(on_keyup_callbacks[human_name]) { - on_keyup_callbacks[human_name](human_name) - e.preventDefault() - } - if(prevent_default_keys[human_name]) { e.preventDefault() } - }); + /* event = (e) ? e : window.event; */ /* Seems unnecessary because e is assumed to be non-null later */ + var code = code = e.keyCode; + pressed_keys[code] = false; + if (on_keyup_callbacks[code]) { + on_keyup_callbacks[code](code) + e.preventDefault() + } else if (prevent_default_keys[code]) { + e.preventDefault(); + } } /** @private * handle event "onkeydown" by remembering what key was un-pressed */ function handleKeyDown(e) { - event = (e) ? e : window.event - var human_names = keycode_to_string[event.keyCode]; - if (human_names == null) return; - human_names = human_names.split(" "); - human_names.forEach( function(human_name) { - pressed_keys[human_name] = true - if(on_keydown_callbacks[human_name]) { - on_keydown_callbacks[human_name](human_name) - e.preventDefault() - } - if(prevent_default_keys[human_name]) { e.preventDefault() } - }); + /* event = (e) ? e : window.event; */ /* Seems unnecessary because e is assumed to be non-null later */ + var code = code = e.keyCode; + pressed_keys[code] = true; + if (on_keydown_callbacks[code]) { + on_keydown_callbacks[code](code); + e.preventDefault(); + } else if (prevent_default_keys[code]) { + e.preventDefault(); + } } /** @private * handle event "onmousedown" by remembering what button was pressed */ function handleMouseDown(e) { - event = (e) ? e : window.event - var human_name = mousebuttoncode_to_string[event.button] // 0 1 2 + /* event = (e) ? e : window.event; */ /* Seems unnecessary because e is assumed to be non-null later */ + var human_name = mousebuttoncode_to_string[e.button]; // 0 1 2 if (navigator.appName == "Microsoft Internet Explorer"){ - human_name = ie_mousebuttoncode_to_string[event.button]; + human_name = ie_mousebuttoncode_to_string[e.button]; } pressed_keys[human_name] = true if(on_keydown_callbacks[human_name]) { - on_keydown_callbacks[human_name](human_name) - e.preventDefault() + on_keydown_callbacks[human_name](human_name); + e.preventDefault(); } } @@ -162,16 +102,16 @@ function handleMouseDown(e) { * handle event "onmouseup" by remembering what button was un-pressed */ function handleMouseUp(e) { - event = (e) ? e : window.event - var human_name = mousebuttoncode_to_string[event.button] + /* event = (e) ? e : window.event; */ /* Seems unnecessary because e is assumed to be non-null later */ + var human_name = mousebuttoncode_to_string[e.button] if (navigator.appName == "Microsoft Internet Explorer"){ - human_name = ie_mousebuttoncode_to_string[event.button]; + human_name = ie_mousebuttoncode_to_string[e.button]; } - pressed_keys[human_name] = false + pressed_keys[human_name] = false; if(on_keyup_callbacks[human_name]) { - on_keyup_callbacks[human_name](human_name) - e.preventDefault() + on_keyup_callbacks[human_name](human_name); + e.preventDefault(); } } @@ -179,7 +119,7 @@ function handleMouseUp(e) { * handle event "touchstart" by remembering what button was pressed */ function handleTouchStart(e) { - event = (e) ? e : window.event + /* event = (e) ? e : window.event; */ /* Seems unnecessary because e is assumed to be non-null later */ pressed_keys["left_mouse_button"] = true jaws.mouse_x = e.touches[0].pageX - jaws.canvas.offsetLeft; jaws.mouse_y = e.touches[0].pageY - jaws.canvas.offsetTop; @@ -190,14 +130,11 @@ function handleTouchStart(e) { * handle event "touchend" by remembering what button was pressed */ function handleTouchEnd(e) { - event = (e) ? e : window.event - pressed_keys["left_mouse_button"] = false - jaws.mouse_x = undefined; - jaws.mouse_y = undefined; - + pressed_keys["left_mouse_button"] = false; + jaws.mouse_x = undefined; + jaws.mouse_y = undefined; } -var prevent_default_keys = [] /** * Prevents default browseraction for given keys. * @example @@ -205,62 +142,39 @@ var prevent_default_keys = [] */ jaws.preventDefaultKeys = function(array_of_strings) { var list = arguments; - if(list.length == 1 && jaws.isArray(list[0])) list = list[0]; - for(var i=0; i < list.length; i++) { prevent_default_keys[list[i]] = true; } } /** - * Check if *keys* are pressed. Second argument specifies use of logical AND when checking multiple keys. - * @example - * jaws.pressed("left a"); // returns true if left arrow key OR a is pressed - * jaws.pressed("ctrl c", true); // returns true if ctrl AND a is pressed + * Array: If a key is currently pressed, the value associated to the key is true, otherwise false or not present. */ -jaws.pressed = function(keys, logical_and) { - if(jaws.isString(keys)) { keys = keys.split(" ") } - if(logical_and) { return keys.every( function(key) { return pressed_keys[key] } ) } - else { return keys.some( function(key) { return pressed_keys[key] } ) } -} +jaws.pressed = pressed_keys; /** - * Check if *keys* are pressed, but only return true Once for any given keys. Once keys have been released, pressedWithoutRepeat can return true again when keys are pressed. - * Second argument specifies use of logical AND when checking multiple keys. - * @example - * if(jaws.pressedWithoutRepeat("space")) { player.jump() } // with this in the gameloop player will only jump once even if space is held down + * Mapping key names to codes, and vice-versa */ -jaws.pressedWithoutRepeat = function(keys, logical_and) { - if( jaws.pressed(keys, logical_and) ) { - if(!previously_pressed_keys[keys]) { - previously_pressed_keys[keys] = true - return true - } - } - else { - previously_pressed_keys[keys] = false - return false - } -} +jaws.keyCodes = keyCodes; +jaws.keycodeNames = keycodeNames; /** * sets up a callback for a key (or array of keys) to call when it's pressed down * * @example * // call goLeft() when left arrow key is pressed - * jaws.on_keypress("left", goLeft) + * jaws.on_keypress(jaws.keyCode("left"), goLeft) * * // call fireWeapon() when SPACE or CTRL is pressed - * jaws.on_keypress(["space","ctrl"], fireWeapon) + * jaws.on_keypress([jaws.keyCodes["space"],jaws.keyCodes["ctrl"]], fireWeapon) */ jaws.on_keydown = function(key, callback) { - if(jaws.isArray(key)) { - for(var i=0; key[i]; i++) { - on_keydown_callbacks[key[i]] = callback + if (jaws.isArray(key)) { + for (var i=0; key[i]; i++) { + on_keydown_callbacks[key[i]] = callback; } - } - else { - on_keydown_callbacks[key] = callback + } else { + on_keydown_callbacks[key] = callback; } } @@ -268,13 +182,12 @@ jaws.on_keydown = function(key, callback) { * sets up a callback when a key (or array of keys) to call when it's released */ jaws.on_keyup = function(key, callback) { - if(jaws.isArray(key)) { - for(var i=0; key[i]; i++) { - on_keyup_callbacks[key[i]] = callback + if (jaws.isArray(key)) { + for (var i=0; key[i]; i++) { + on_keyup_callbacks[key[i]] = callback; } - } - else { - on_keyup_callbacks[key] = callback + } else { + on_keyup_callbacks[key] = callback; } } @@ -282,8 +195,8 @@ jaws.on_keyup = function(key, callback) { * Clean up all callbacks set by on_keydown / on_keyup */ jaws.clearKeyCallbacks = function() { - on_keyup_callbacks = [] - on_keydown_callbacks = [] + on_keyup_callbacks = []; + on_keydown_callbacks = []; } return jaws; |
