app.min.js 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. function initSplash() {
  2. gameState = "splash", allowSound && !muted && music.play(), initStartScreen()
  3. }
  4. function initStartScreen() {
  5. document.getElementById('moregame').style.display='none';
  6. gameState = "start", gameScore = 0, userInput.addHitArea("mute", butEventHandler, null, {type: "rect",aRect: [336, 0, canvas.width, 48]}, !0), background = new Elements.Background(assetLib.getData("background"), canvas.width, canvas.height);
  7. var a = {oImgData: assetLib.getData("playBut"),aPos: [canvas.width / 2, 370]}, b = {oImgData: assetLib.getData("moreGamesBut"),aPos: [canvas.width / 2, 480]};
  8. userInput.addHitArea("startGame", butEventHandler, null, {type: "image",oImageData: a.oImgData,aCentrePos: a.aPos}), userInput.addHitArea("moreGames", butEventHandler, null, {type: "image",oImageData: b.oImgData,aCentrePos: b.aPos});
  9. var c = new Array(a, b);
  10. panel = new Elements.Panel(assetLib.getData("panels"), assetLib.getData("thinNumbers"), assetLib.getData("fatNumbers"), gameState, c, canvas.width, canvas.height), panel.startTween(), aDots = new Array;
  11. for (var d = 0; 6 > d; d++) {
  12. var e = new Elements.Dot(assetLib.getData("dot"), assetLib.getData("pop"), d, d, canvas.width, canvas.height);
  13. e.x = Math.random() * canvas.width, e.y = Math.random() * canvas.height, aDots.push(e)
  14. }
  15. previousTime = (new Date).getTime(), updateStartScreenEvent()
  16. }
  17. function initPreGame() {
  18. gameState = "tutorial";
  19. for (var a = 0; a < aTutorials.length; a++)
  20. if (aTutorials[a].gameNum == gameNum && !aTutorials[a].shown) {
  21. background = new Elements.Background(assetLib.getData("background"), canvas.width, canvas.height), userInput.addHitArea("continue", butEventHandler, null, {type: "rect",aRect: [100, 265, 220, 345]});
  22. var b = {oImgData: assetLib.getData("playBut"),aPos: [canvas.width / 2, 465]};
  23. userInput.addHitArea("continue", butEventHandler, null, {type: "image",oImageData: b.oImgData,aCentrePos: b.aPos});
  24. var c = new Array(b);
  25. return panel = new Elements.Panel(assetLib.getData("panels"), assetLib.getData("thinNumbers"), assetLib.getData("fatNumbers"), aTutorials[a].panelType, c, canvas.width, canvas.height), panel.startTween(), previousTime = (new Date).getTime(), updateTutorialEvent(), void 0
  26. }
  27. initGame()
  28. }
  29. function initGame() {
  30. gameState = "game", allowSound && music.volume(.5), background = new Elements.Background(assetLib.getData("background"), canvas.width, canvas.height), userInput.addHitArea("pause", butEventHandler, null, {type: "rect",aRect: [294, 0, 336, 48]}, !0), hud = new Elements.Hud(assetLib.getData("hud"), assetLib.getData("thinNumbers"), assetLib.getData("fatNumbers"), canvas.width, canvas.height), aDots = new Array, aSelected = new Array, gameTime = 60, gameScore = 0, blockTap = !1, longestChain = 0, balloonsPopped = 0, lastSelectedDot = null;
  31. for (var a = 0; 42 > a; a++) {
  32. var b = new Elements.Dot(assetLib.getData("dot"), assetLib.getData("pop"), a, getNewDotType(), canvas.width, canvas.height);
  33. b.targX = Math.round(62 * (a % 6) + 36), b.targY = Math.round(getYPosFromId(a)), b.fall(), userInput.addHitArea("dotHit", butEventHandler, {id: a,isDraggable: !0}, {type: "rect",aRect: [b.x - 22, b.targY - 22, b.x + 22, b.targY + 22]}), aDots.push(b)
  34. }
  35. background.startScroll(20), userInput.addHitArea("mouseUp", butEventHandler, {multiTouch: !0}, {type: "rect",aRect: [0, 0, canvas.width, canvas.height]}), previousTime = (new Date).getTime(), updateGameEvent()
  36. }
  37. function butEventHandler(a, b) {
  38. switch (a) {
  39. case "langSelect":
  40. console.log(b.lang), curLang = b.lang, ctx.clearRect(0, 0, canvas.width, canvas.height), userInput.removeHitArea("langSelect"), initLoadAssets();
  41. break;
  42. case "startGame":
  43. playSound("click"), userInput.removeHitArea("startGame"), userInput.removeHitArea("moreGames"), initPreGame();
  44. break;
  45. case "moreGames":
  46. clickMore();
  47. break;
  48. case "dotHit":
  49. if (blockTap)
  50. break;
  51. if (b.isBeingDragged) {
  52. if (null == lastSelectedDot)
  53. break;
  54. lastSelectedDot = aDots[b.id].trySelect(lastSelectedDot);
  55. for (var c = -1, d = 0; d < aSelected.length; d++)
  56. aSelected[d] == lastSelectedDot && (c = d);
  57. if (-1 == c)
  58. aSelected.push(lastSelectedDot), playSound("drag");
  59. else
  60. for (var d = c + 1; d < aSelected.length; d++)
  61. aSelected[d].unSelect(), aSelected.splice(d, 1), d -= 1
  62. } else
  63. aDots[b.id].type < 6 && (aDots[b.id].select(), lastSelectedDot = aDots[b.id], aSelected = new Array(lastSelectedDot), playSound("drag"));
  64. break;
  65. case "mouseUp":
  66. if (!b.isDown) {
  67. if (blockTap)
  68. break;
  69. if (aSelected.length >= 3) {
  70. for (var e = 0, f = aSelected.length, g = !1, d = 0; f > d; d++) {
  71. if (7 == aSelected[d].type || 9 == aSelected[d].type) {
  72. g = !0;
  73. for (var h = 0; 6 > h; h++) {
  74. for (var i = !0, j = 0; j < aSelected.length; j++)
  75. aSelected[j] == aDots[6 * Math.floor(aSelected[d].id / 6) + h] && (i = !1);
  76. i && aSelected.push(aDots[6 * Math.floor(aSelected[d].id / 6) + h])
  77. }
  78. }
  79. if (8 == aSelected[d].type || 9 == aSelected[d].type) {
  80. g = !0;
  81. for (var h = 0; 7 > h; h++) {
  82. for (var i = !0, j = 0; j < aSelected.length; j++)
  83. aSelected[j] == aDots[aSelected[d].id % 6 + 6 * h] && (i = !1);
  84. i && aSelected.push(aDots[aSelected[d].id % 6 + 6 * h])
  85. }
  86. }
  87. }
  88. sortThis(aSelected);
  89. for (var d = 0; d < aSelected.length; d++)
  90. 10 == aSelected[d].type ? e++ : 11 == aSelected[d].type && (gameTime += 5), aSelected[d].hit(d / aSelected.length);
  91. longestChain = Math.max(aSelected.length, longestChain), balloonsPopped += aSelected.length, g ? playSound("explode") : 3 == aSelected.length ? playSound("pop1") : aSelected.length < 7 ? playSound("pop2") : playSound("pop3"), updateScore(10 * f * f + 100 * aSelected.length + 2 * e * 100 * aSelected.length), blockTap = !0, background.startScroll(aSelected.length)
  92. } else {
  93. for (var d = 0; d < aSelected.length; d++)
  94. aSelected[d].unSelect();
  95. aSelected = new Array
  96. }
  97. removedDots = 0, lastSelectedDot = null
  98. }
  99. break;
  100. case "continue":
  101. playSound("click"), userInput.removeHitArea("continue"), initGame();
  102. break;
  103. case "newGame":
  104. playSound("click"), userInput.removeHitArea("pause"), userInput.removeHitArea("newGame"), userInput.removeHitArea("quitFromEnd"), gameNum++, initPreGame();
  105. break;
  106. case "quitFromEnd":
  107. playSound("click"), userInput.removeHitArea("pause"), userInput.removeHitArea("newGame"), userInput.removeHitArea("quitFromEnd"), initStartScreen();
  108. break;
  109. case "mute":
  110. playSound("click"), toggleMute();
  111. break;
  112. case "pause":
  113. case "resumeFromPause":
  114. playSound("click"), toggleManualPause();
  115. break;
  116. case "quitFromPause":
  117. playSound("click"), toggleManualPause(), userInput.removeHitArea("pause"), userInput.removeHitArea("dotHit"), userInput.removeHitArea("mouseUp"), userInput.removeHitArea("quitFromPause"), userInput.removeHitArea("resumeFromPause"), gameScore = 0, initStartScreen()
  118. }
  119. }
  120. function sortThis(a) {
  121. a.sort(function(a, b) {
  122. var c = a.id, d = b.id;
  123. return d > c ? -1 : c > d ? 1 : 0
  124. })
  125. }
  126. function updateScore(a) {
  127. gameScore += a, hud.updateScore(gameScore)
  128. }
  129. function initGameOver() {
  130. gameState = "gameOver", allowSound && music.volume(.25), userInput.removeHitArea("dotHit"), userInput.removeHitArea("mouseUp"), playSound("timesUp"), background = new Elements.Background(assetLib.getData("background"), canvas.width, canvas.height);
  131. var a = {oImgData: assetLib.getData("playBut"),aPos: [263, 465]}, b = {oImgData: assetLib.getData("quitBut"),aPos: [120, 465]};
  132. userInput.addHitArea("newGame", butEventHandler, null, {type: "image",oImageData: a.oImgData,aCentrePos: a.aPos}), userInput.addHitArea("quitFromEnd", butEventHandler, null, {type: "image",oImageData: b.oImgData,aCentrePos: b.aPos});
  133. var c = new Array(a, b);
  134. panel = new Elements.Panel(assetLib.getData("panels"), assetLib.getData("thinNumbers"), assetLib.getData("fatNumbers"), gameState, c, canvas.width, canvas.height), panel.startTween(), highScore = Math.max(gameScore, highScore);
  135. try {
  136. window.kaisergames.submitHighscore(0, gameScore);
  137. } catch (d) {
  138. }
  139. panel.oScoreData = {gameScore: gameScore,longestChain: longestChain,balloonsPopped: balloonsPopped,highScore: highScore}, previousTime = (new Date).getTime(), updateGameOver();
  140. dp_submitScore(gameScore);
  141. document.getElementById('moregame').style.display='block';
  142. }
  143. function replaceDots() {
  144. for (var a = 0; a < aSelected.length; a++) {
  145. for (var b = 6; aSelected[a].id + b < 42 && !aDots[aSelected[a].id + b].canHit; )
  146. b += 6;
  147. aSelected[a].id > 36 || aSelected[a].id + b >= 42 ? aDots[aSelected[a].id].replaceWithNewDot(getNewDotType()) : (aDots[aSelected[a].id].replaceWithExistingDot(aDots[aSelected[a].id + b]), renderSprite(aDots[aSelected[a].id]), aDots[aSelected[a].id + b].canHit && (aDots[aSelected[a].id + b].canHit = !1, aSelected.push(aDots[aSelected[a].id + b]), sortThis(aSelected)))
  148. }
  149. aSelected = new Array, blockTap = !1
  150. }
  151. function getYPosFromId(a) {
  152. return 62 * Math.floor(a / 6) + 110
  153. }
  154. function getNewDotType() {
  155. return 9 * Math.random() < 8 ? Math.floor(6 * Math.random()) : Math.floor(6 * Math.random() + 6)
  156. }
  157. function updateGameEvent() {
  158. if (!manualPause && !rotatePause && "game" == gameState) {
  159. var a = getDelta();
  160. background.render(ctx);
  161. for (var b = 0; b < aDots.length; b++)
  162. aDots[b].update(a), renderSprite(aDots[b]), aDots[b].removeMe && (aDots[b].removeMe = !1, ++removedDots == aSelected.length && replaceDots());
  163. if (gameTime -= a, 0 >= gameTime)
  164. return initGameOver(), void 0;
  165. hud.render(ctx, Math.round(gameTime)), renderMuteBut(), requestAnimFrame(updateGameEvent)
  166. }
  167. }
  168. function updateGameOver() {
  169. if (!rotatePause && "gameOver" == gameState) {
  170. var a = getDelta();
  171. background.updateScroll(a), background.render(ctx), panel.update(a), panel.render(ctx), renderMuteBut(), requestAnimFrame(updateGameOver)
  172. }
  173. }
  174. function updateSplashScreenEvent() {
  175. if (!rotatePause && "splash" == gameState) {
  176. var a = getDelta();
  177. if (splashTimer += a, splashTimer > 2.5)
  178. return allowSound && !muted && music.play(), initStartScreen(), void 0;
  179. splash.render(ctx, a), requestAnimFrame(updateSplashScreenEvent)
  180. }
  181. }
  182. function updateStartScreenEvent() {
  183. if (!rotatePause && "start" == gameState) {
  184. var a = getDelta();
  185. background.updateScroll(a), background.render(ctx);
  186. for (var b = 0; b < aDots.length; b++)
  187. aDots[b].y -= (30 + 2 * b) * a, aDots[b].x = aDots[b].x - 50 * Math.sin(aDots[b].y / 50) * a, aDots[b].y < -100 && (aDots[b].x = Math.random() * canvas.width, aDots[b].y = canvas.height + 200 * Math.random() + 100), aDots[b].update(a), renderSprite(aDots[b]);
  188. panel.update(a), panel.render(ctx), renderMuteBut(), requestAnimFrame(updateStartScreenEvent)
  189. }
  190. }
  191. function updateTutorialEvent() {
  192. if (!rotatePause && "tutorial" == gameState) {
  193. var a = getDelta();
  194. background.updateScroll(a), background.render(ctx), panel.update(a), panel.render(ctx), renderMuteBut(), requestAnimFrame(updateTutorialEvent)
  195. }
  196. }
  197. function getDelta() {
  198. var a = (new Date).getTime(), b = (a - previousTime) / 1e3;
  199. return previousTime = a, b > .5 && (b = 0), b
  200. }
  201. function renderSprite(a) {
  202. ctx.save(), ctx.translate(a.x, a.y), ctx.scale(a.scaleX, a.scaleY), ctx.rotate(a.rotation), a.render(ctx), ctx.restore()
  203. }
  204. function checkSpriteCollision(a, b, c) {
  205. var d = a.x, e = a.y, f = b.x, g = b.y, h = (d - f) * (d - f) + (e - g) * (e - g), i = (a.radius + c) * (a.radius + c);
  206. return i > h ? !0 : !1
  207. }
  208. function loadPreAssets() {
  209. aLangs.length > 1 ? (preAssetLib = new Utils.AssetLoader(curLang, [{id: "langSelect",file: "images/langSelect.jpg"}, {id: "preloadImage",file: "images/preloadImage.jpg"}], ctx, canvas.width, canvas.height, !1), preAssetLib.onReady(initLangSelect)) : (curLang = aLangs[0], preAssetLib = new Utils.AssetLoader(curLang, [{id: "preloadImage",file: "images/preloadImage.jpg"}], ctx, canvas.width, canvas.height, !1), preAssetLib.onReady(initLoadAssets))
  210. }
  211. function initLangSelect() {
  212. var a = preAssetLib.getData("langSelect");
  213. ctx.drawImage(a.img, 0, 0, a.img.width, a.img.height, canvas.width / 2 - .75 * (a.img.width / 2), canvas.height / 2 - .75 * (a.img.height / 2), .75 * a.img.width, .75 * a.img.height);
  214. for (var b = 105, c = 0; c < aLangs.length; c++) {
  215. var d = canvas.width / 2 - b * aLangs.length / 2 + c * b, e = canvas.height / 2 - b / 2;
  216. userInput.addHitArea("langSelect", butEventHandler, {lang: aLangs[c]}, {type: "rect",aRect: [d, e, d + b, e + 140]})
  217. }
  218. }
  219. function initLoadAssets() {
  220. var a = preAssetLib.getData("preloadImage");
  221. ctx.drawImage(a.img, 0, 0), loadAssets()
  222. }
  223. function loadAssets() {
  224. assetLib = new Utils.AssetLoader(curLang, [{id: "background",file: "images/background.jpg"}, {id: "rotateDeviceMessage",file: "images/rotateDeviceMessage.jpg"}, {id: "splash",file: "images/splashScreen.jpg"}, {id: "hud",file: "images/" + curLang + "/hud.png"}, {id: "playBut",file: "images/playBut.png"}, {id: "quitBut",file: "images/quitBut.png"}, {id: "moreGamesBut",file: "images/" + curLang + "/moreGamesBut.png"}, {id: "panels",file: "images/" + curLang + "/panels_383x550.png",oData: {columns: 2,spriteWidth: 383,spriteHeight: 550}}, {id: "dot",file: "images/dots_64x86.png",oData: {oAnims: {unSelected0: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],unSelected1: [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39],unSelected2: [40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59],unSelected3: [60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79],unSelected4: [80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99],unSelected5: [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119],unSelected6: [120],unSelected7: [121],unSelected8: [122],unSelected9: [123],unSelected10: [124],unSelected11: [125],selected0: [126, 127, 128, 129],selected1: [130, 131, 132, 133],selected2: [134, 135, 136, 137],selected3: [138, 139, 140, 141],selected4: [142, 143, 144, 145],selected5: [146, 147, 148, 149],selected6: [150, 151, 152, 153],selected7: [154, 155, 156, 157],selected8: [158, 159, 160, 161],selected9: [162, 163, 164, 165],selected10: [166, 167, 168, 169],selected11: [170, 171, 172, 173]},columns: 16,spriteWidth: 64,spriteHeight: 86}}, {id: "pop",file: "images/pop_156x141.png",oData: {oAnims: {pop: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]},columns: 6,spriteWidth: 156,spriteHeight: 141}}, {id: "fatNumbers",file: "images/fatNumbers_33x41.png",oData: {columns: 10,spriteWidth: 33,spriteHeight: 41}}, {id: "thinNumbers",file: "images/thinNumbers_25x32.png",oData: {columns: 10,spriteWidth: 25,spriteHeight: 32}}, {id: "muteBut",file: "images/mute_35x35.png",oData: {columns: 2,spriteWidth: 35,spriteHeight: 35}}], ctx, canvas.width, canvas.height, !1), assetLib.onReady(initSplash)
  225. }
  226. function resizeCanvas() {
  227. var a = window.innerWidth, b = window.innerHeight;
  228. a > 480 && (a -= 1, b -= 1), window.innerWidth > window.innerHeight && isMobile ? ("loading" != gameState && rotatePauseOn(), a / canvas.width < b / canvas.height ? (canvas.style.width = a + "px", canvas.style.height = a / canvas.width * canvas.height + "px", canvasX = 0, canvasY = (b - a / canvas.width * canvas.height) / 2, canvasScaleX = canvasScaleY = canvas.width / a, div.style.marginTop = canvasY + "px", div.style.marginLeft = canvasX + "px") : (canvas.style.width = b / canvas.height * canvas.width + "px", canvas.style.height = b + "px", canvasX = (a - b / canvas.height * canvas.width) / 2, canvasY = 0, canvasScaleX = canvasScaleY = canvas.height / b, div.style.marginTop = canvasY + "px", div.style.marginLeft = canvasX + "px")) : isMobile ? (rotatePause && rotatePauseOff(), canvasX = canvasY = 0, canvasScaleX = canvas.width / a, canvasScaleY = canvas.height / b, canvas.style.width = a + "px", canvas.style.height = b + "px", div.style.marginTop = "0px", div.style.marginLeft = "0px") : (rotatePause && rotatePauseOff(), a / canvas.width < b / canvas.height ? (canvas.style.width = a + "px", canvas.style.height = a / canvas.width * canvas.height + "px", canvasX = 0, canvasY = (b - a / canvas.width * canvas.height) / 2, canvasScaleX = canvasScaleY = canvas.width / a, div.style.marginTop = canvasY + "px", div.style.marginLeft = canvasX + "px") : (canvas.style.width = b / canvas.height * canvas.width + "px", canvas.style.height = b + "px", canvasX = (a - b / canvas.height * canvas.width) / 2, canvasY = 0, canvasScaleX = canvasScaleY = canvas.height / b, div.style.marginTop = canvasY + "px", div.style.marginLeft = canvasX + "px")), userInput.setCanvas(canvasX, canvasY, canvasScaleX, canvasScaleY)
  229. }
  230. function playSound(a) {
  231. allowSound && sound.play(a)
  232. }
  233. function toggleMute() {
  234. muted = !muted, allowSound && (muted ? Howler.mute() : Howler.unmute()), renderMuteBut()
  235. }
  236. function renderMuteBut() {
  237. if (allowSound) {
  238. var a = assetLib.getData("muteBut"), b = 0;
  239. muted && (b = 1);
  240. var c = b * a.oData.spriteWidth % a.img.width, d = Math.floor(b / (a.img.width / a.oData.spriteWidth)) * a.oData.spriteHeight;
  241. ctx.drawImage(a.img, c, d, a.oData.spriteWidth, a.oData.spriteHeight, 340, 10, a.oData.spriteWidth, a.oData.spriteHeight)
  242. }
  243. }
  244. function toggleManualPause() {
  245. if (manualPause)
  246. manualPause = !1, userInput.removeHitArea("quitFromPause"), userInput.removeHitArea("resumeFromPause"), pauseCoreOff();
  247. else {
  248. manualPause = !0, pauseCoreOn();
  249. var a = {oImgData: assetLib.getData("quitBut"),aPos: [120, 465]}, b = {oImgData: assetLib.getData("playBut"),aPos: [263, 465]}, c = new Array(a, b);
  250. userInput.addHitArea("quitFromPause", butEventHandler, null, {type: "image",oImageData: a.oImgData,aCentrePos: a.aPos}), userInput.addHitArea("resumeFromPause", butEventHandler, null, {type: "image",oImageData: b.oImgData,aCentrePos: b.aPos}), panel = new Elements.Panel(assetLib.getData("panels"), assetLib.getData("thinNumbers"), assetLib.getData("fatNumbers"), "pause", c, canvas.width, canvas.height), panel.render(ctx), userInput.addHitArea("pause", butEventHandler, null, {type: "rect",aRect: [294, 0, 336, 48]}, !0)
  251. }
  252. }
  253. function rotatePauseOn() {
  254. rotatePause = !0, ctx.drawImage(assetLib.getImg("rotateDeviceMessage"), 0, 0), userInput.pauseIsOn = !0, pauseCoreOn()
  255. }
  256. function rotatePauseOff() {
  257. rotatePause = !1, pauseCoreOff()
  258. }
  259. function pauseCoreOn() {
  260. switch (allowSound && Howler.mute(), gameState) {
  261. case "start":
  262. break;
  263. case "help":
  264. break;
  265. case "game":
  266. userInput.removeHitArea("dotHit"), userInput.removeHitArea("mouseUp");
  267. break;
  268. case "end":
  269. }
  270. }
  271. function pauseCoreOff() {
  272. switch (allowSound && (muted || Howler.unmute()), previousTime = (new Date).getTime(), userInput.pauseIsOn = !1, gameState) {
  273. case "splash":
  274. updateSplashScreenEvent();
  275. break;
  276. case "start":
  277. initStartScreen();
  278. break;
  279. case "tutorial":
  280. initPreGame();
  281. break;
  282. case "game":
  283. manualPause = !1;
  284. for (var a = 0; a < aDots.length; a++)
  285. userInput.addHitArea("dotHit", butEventHandler, {id: a,isDraggable: !0}, {type: "rect",aRect: [aDots[a].x - 22, aDots[a].targY - 22, aDots[a].x + 22, aDots[a].targY + 22]});
  286. userInput.addHitArea("mouseUp", butEventHandler, {multiTouch: !0}, {type: "rect",aRect: [0, 0, canvas.width, canvas.height]}), updateGameEvent();
  287. break;
  288. case "gameOver":
  289. initGameOver()
  290. }
  291. }
  292. var Utils;
  293. !function(a) {
  294. var b = function() {
  295. function a(a, b, c, d, e, f) {
  296. "undefined" == typeof f && (f = !0), this.oAssetData = {}, this.assetsLoaded = 0, this.totalAssets = b.length, this.ctx = c, this.canvasWidth = d, this.canvasHeight = e, this.showBar = f, this.topLeftX = this.canvasWidth / 2 - d / 4, this.topLeftY = this.canvasHeight / 2, this.showBar && (ctx.strokeStyle = "#aaaaaa", ctx.lineWidth = 2, ctx.fillStyle = "#ffffff", ctx.moveTo(this.topLeftX, this.topLeftY), ctx.lineTo(this.topLeftX + d / 2, this.topLeftY + 0), ctx.lineTo(this.topLeftX + d / 2, this.topLeftY + 20), ctx.lineTo(this.topLeftX + 0, this.topLeftY + 20), ctx.lineTo(this.topLeftX + 0, this.topLeftY + 0), ctx.stroke());
  297. for (var g = 0; g < b.length; g++)
  298. this.loadImage(b[g])
  299. }
  300. return a.prototype.loadImage = function(a) {
  301. var b = this, c = new Image;
  302. c.onload = function() {
  303. b.oAssetData[a.id] = {}, b.oAssetData[a.id].img = c, void 0 != a.oData && (b.oAssetData[a.id].oData = a.oData), ++b.assetsLoaded, b.showBar && ctx.fillRect(b.topLeftX + 2, b.topLeftY + 2, (b.canvasWidth / 2 - 4) / b.totalAssets * b.assetsLoaded, 16), b.checkLoadComplete()
  304. }, c.src = a.file
  305. }, a.prototype.checkLoadComplete = function() {
  306. this.assetsLoaded == this.totalAssets && this.loadedCallback()
  307. }, a.prototype.onReady = function(a) {
  308. this.loadedCallback = a
  309. }, a.prototype.getImg = function(a) {
  310. return this.oAssetData[a].img
  311. }, a.prototype.getData = function(a) {
  312. return this.oAssetData[a]
  313. }, a
  314. }();
  315. a.AssetLoader = b
  316. }(Utils || (Utils = {}));
  317. var Utils;
  318. !function(a) {
  319. var b = function() {
  320. function a(a, b, c, d) {
  321. this.x = 0, this.y = 0, this.rotation = 0, this.radius = 10, this.removeMe = !1, this.frameInc = 0, this.animType = "loop", this.offsetX = 0, this.offsetY = 0, this.scaleX = 1, this.scaleY = 1, this.oImgData = a, this.oAnims = this.oImgData.oData.oAnims, this.fps = b, this.radius = c, this.animId = d
  322. }
  323. return a.prototype.changeSpriteSheet = function(a) {
  324. this.oImgData = a, this.oAnims = this.oImgData.oData.oAnims, this.resetAnim()
  325. }, a.prototype.updateAnimation = function(a) {
  326. this.frameInc += this.fps * a
  327. }, a.prototype.resetAnim = function() {
  328. this.frameInc = 0
  329. }, a.prototype.setFrame = function(a) {
  330. this.fixedFrame = a
  331. }, a.prototype.setAnimType = function(a, b, c) {
  332. switch ("undefined" == typeof c && (c = !0), this.animId = b, this.animType = a, c && this.resetAnim(), a) {
  333. case "loop":
  334. break;
  335. case "once":
  336. this.maxIdx = this.oAnims[this.animId].length - 1
  337. }
  338. }, a.prototype.render = function(a) {
  339. if (null != this.animId) {
  340. var b = this.oAnims[this.animId].length, c = Math.floor(this.frameInc), d = this.oAnims[this.animId][c % b], e = d * this.oImgData.oData.spriteWidth % this.oImgData.img.width, f = Math.floor(d / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight;
  341. if ("once" == this.animType && c > this.maxIdx) {
  342. this.fixedFrame = this.oAnims[this.animId][b - 1], this.animId = null, this.animEndedFunc();
  343. var e = this.fixedFrame * this.oImgData.oData.spriteWidth % this.oImgData.img.width, f = Math.floor(this.fixedFrame / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight
  344. }
  345. } else
  346. var e = this.fixedFrame * this.oImgData.oData.spriteWidth % this.oImgData.img.width, f = Math.floor(this.fixedFrame / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight;
  347. a.drawImage(this.oImgData.img, e, f, this.oImgData.oData.spriteWidth, this.oImgData.oData.spriteHeight, -this.oImgData.oData.spriteWidth / 2 + this.offsetX, -this.oImgData.oData.spriteHeight / 2 + this.offsetY, this.oImgData.oData.spriteWidth, this.oImgData.oData.spriteHeight)
  348. }, a
  349. }();
  350. a.AnimSprite = b
  351. }(Utils || (Utils = {}));
  352. var Utils;
  353. !function(a) {
  354. var b = function() {
  355. function a(a, b) {
  356. this.x = 0, this.y = 0, this.rotation = 0, this.radius = 10, this.removeMe = !1, this.offsetX = 0, this.offsetY = 0, this.scaleX = 1, this.scaleY = 1, this.oImgData = a, this.radius = b
  357. }
  358. return a.prototype.setFrame = function(a) {
  359. this.frameNum = a
  360. }, a.prototype.render = function(a) {
  361. var b = this.frameNum * this.oImgData.oData.spriteWidth % this.oImgData.img.width, c = Math.floor(this.frameNum / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight;
  362. a.drawImage(this.oImgData.img, b, c, this.oImgData.oData.spriteWidth, this.oImgData.oData.spriteHeight, -this.oImgData.oData.spriteWidth / 2 + this.offsetX, -this.oImgData.oData.spriteHeight / 2 + this.offsetY, this.oImgData.oData.spriteWidth, this.oImgData.oData.spriteHeight)
  363. }, a
  364. }();
  365. a.BasicSprite = b
  366. }(Utils || (Utils = {}));
  367. var Utils;
  368. !function(a) {
  369. var b = function() {
  370. function a(a, b) {
  371. var c = this;
  372. this.canvasX = 0, this.canvasY = 0, this.canvasScaleX = 1, this.canvasScaleY = 1, this.prevHitTime = 0, this.pauseIsOn = !1, this.isDown = !1, this.isDetectingKeys = !1, this.isBugBrowser = b, a.addEventListener("touchstart", function(a) {
  373. for (var b = 0; b < a.changedTouches.length; b++)
  374. c.hitDown(a, a.changedTouches[b].pageX, a.changedTouches[b].pageY, a.changedTouches[b].identifier)
  375. }, !1), a.addEventListener("touchend", function(a) {
  376. for (var b = 0; b < a.changedTouches.length; b++)
  377. c.hitUp(a, a.changedTouches[b].pageX, a.changedTouches[b].pageY, a.changedTouches[b].identifier)
  378. }, !1), a.addEventListener("touchleave", function(a) {
  379. for (var b = 0; b < a.changedTouches.length; b++)
  380. c.leave(a, a.changedTouches[b].pageX, a.changedTouches[b].pageY, a.changedTouches[b].identifier)
  381. }, !1), a.addEventListener("touchmove", function(a) {
  382. for (var b = 0; b < c.aHitAreas.length; b++)
  383. void 0 != a.changedTouches[b] && c.move(a, a.changedTouches[b].pageX, a.changedTouches[b].pageY, a.changedTouches[b].identifier, !0)
  384. }, !1), a.addEventListener("mousedown", function(a) {
  385. c.isDown = !0, c.hitDown(a, a.pageX, a.pageY, 1)
  386. }, !1), a.addEventListener("mouseup", function(a) {
  387. c.isDown = !1, c.hitUp(a, a.pageX, a.pageY, 1)
  388. }, !1), a.addEventListener("mouseleave", function(a) {
  389. c.leave(a, a.pageX, a.pageY, 1)
  390. }, !1), a.addEventListener("mousemove", function(a) {
  391. c.move(a, a.pageX, a.pageY, 1, c.isDown)
  392. }, !1), this.aHitAreas = new Array, this.aKeys = new Array
  393. }
  394. return a.prototype.setCanvas = function(a, b, c, d) {
  395. this.canvasX = a, this.canvasY = b, this.canvasScaleX = c, this.canvasScaleY = d
  396. }, a.prototype.hitDown = function(a, b, c, d) {
  397. if (!this.pauseIsOn) {
  398. var e = (new Date).getTime();
  399. if (!(e - this.prevHitTime < 500 && isBugBrowser)) {
  400. this.prevHitTime = e, a.preventDefault(), a.stopPropagation(), b = (b - this.canvasX) * this.canvasScaleX, c = (c - this.canvasY) * this.canvasScaleY;
  401. for (var f = 0; f < this.aHitAreas.length; f++)
  402. if (this.aHitAreas[f].rect && b > this.aHitAreas[f].area[0] && c > this.aHitAreas[f].area[1] && b < this.aHitAreas[f].area[2] && c < this.aHitAreas[f].area[3]) {
  403. this.aHitAreas[f].aTouchIdentifiers.push(d), this.aHitAreas[f].oData.isDown || (this.aHitAreas[f].oData.isDown = !0, this.aHitAreas[f].callback(this.aHitAreas[f].id, this.aHitAreas[f].oData));
  404. break
  405. }
  406. }
  407. }
  408. }, a.prototype.hitUp = function(a, b, c, d) {
  409. if (!this.pauseIsOn) {
  410. a.preventDefault(), a.stopPropagation(), b = (b - this.canvasX) * this.canvasScaleX, c = (c - this.canvasY) * this.canvasScaleY;
  411. for (var e = 0; e < this.aHitAreas.length; e++)
  412. if (this.aHitAreas[e].rect && b > this.aHitAreas[e].area[0] && c > this.aHitAreas[e].area[1] && b < this.aHitAreas[e].area[2] && c < this.aHitAreas[e].area[3]) {
  413. for (var f = 0; f < this.aHitAreas[e].aTouchIdentifiers.length; f++)
  414. this.aHitAreas[e].aTouchIdentifiers[f] == d && (this.aHitAreas[e].aTouchIdentifiers.splice(f, 1), f -= 1);
  415. 0 == this.aHitAreas[e].aTouchIdentifiers.length && (this.aHitAreas[e].oData.isDown = !1, this.aHitAreas[e].oData.multiTouch && this.aHitAreas[e].callback(this.aHitAreas[e].id, this.aHitAreas[e].oData))
  416. }
  417. }
  418. }, a.prototype.move = function(a, b, c, d, e) {
  419. if (!this.pauseIsOn && e) {
  420. b = (b - this.canvasX) * this.canvasScaleX, c = (c - this.canvasY) * this.canvasScaleY;
  421. for (var f = 0; f < this.aHitAreas.length; f++)
  422. if (this.aHitAreas[f].rect)
  423. if (b > this.aHitAreas[f].area[0] && c > this.aHitAreas[f].area[1] && b < this.aHitAreas[f].area[2] && c < this.aHitAreas[f].area[3])
  424. this.aHitAreas[f].oData.isDown || (this.aHitAreas[f].oData.isDown = !0, this.aHitAreas[f].aTouchIdentifiers.push(d), this.aHitAreas[f].oData.multiTouch && this.aHitAreas[f].callback(this.aHitAreas[f].id, this.aHitAreas[f].oData)), this.aHitAreas[f].oData.isDraggable && (this.aHitAreas[f].oData.isBeingDragged = !0, this.aHitAreas[f].oData.posX = b, this.aHitAreas[f].oData.posY = c, this.aHitAreas[f].callback(this.aHitAreas[f].id, this.aHitAreas[f].oData), this.aHitAreas[f].oData.isBeingDragged = !1);
  425. else if (this.aHitAreas[f].oData.isDown) {
  426. for (var g = 0; g < this.aHitAreas[f].aTouchIdentifiers.length; g++)
  427. this.aHitAreas[f].aTouchIdentifiers[g] == d && (this.aHitAreas[f].aTouchIdentifiers.splice(g, 1), g -= 1);
  428. 0 == this.aHitAreas[f].aTouchIdentifiers.length && (this.aHitAreas[f].oData.isDown = !1, this.aHitAreas[f].oData.multiTouch && this.aHitAreas[f].callback(this.aHitAreas[f].id, this.aHitAreas[f].oData))
  429. }
  430. }
  431. }, a.prototype.leave = function(a, b, c, d) {
  432. if (!this.pauseIsOn) {
  433. a.preventDefault(), a.stopPropagation(), this.isDown = !1;
  434. for (var e = 0; e < this.aHitAreas.length; e++)
  435. if (this.aHitAreas[e].aTouchIdentifiers.length > 0) {
  436. for (var f = 0; f < this.aHitAreas[e].aTouchIdentifiers.length; f++)
  437. this.aHitAreas[e].aTouchIdentifiers[f] == d && (this.aHitAreas[e].aTouchIdentifiers.splice(f, 1), f -= 1);
  438. 0 == this.aHitAreas[e].aTouchIdentifiers.length && (this.aHitAreas[e].oData.isDown = !1, this.aHitAreas[e].callback(this.aHitAreas[e].id, this.aHitAreas[e].oData));
  439. break
  440. }
  441. }
  442. }, a.prototype.keyDown = function(a) {
  443. for (var b = 0; b < this.aKeys.length; b++)
  444. a.keyCode == this.aKeys[b].keyCode && (this.aKeys[b].oData.isDown = !0, this.aKeys[b].callback(this.aKeys[b].id, this.aKeys[b].oData))
  445. }, a.prototype.keyUp = function(a) {
  446. for (var b = 0; b < this.aKeys.length; b++)
  447. a.keyCode == this.aKeys[b].keyCode && (this.aKeys[b].oData.isDown = !1, this.aKeys[b].callback(this.aKeys[b].id, this.aKeys[b].oData))
  448. }, a.prototype.addKey = function(a, b, c, d) {
  449. var e = this;
  450. this.isDetectingKeys || (window.addEventListener("keydown", function(a) {
  451. e.keyDown(a)
  452. }, !1), window.addEventListener("keyup", function(a) {
  453. e.keyUp(a)
  454. }, !1), this.isDetectingKeys = !0), null == c && (c = new Object), this.aKeys.push({id: a,callback: b,oData: c,keyCode: d})
  455. }, a.prototype.removeKey = function(a) {
  456. for (var b = 0; b < this.aKeys.length; b++)
  457. this.aKeys[b].id == a && (this.aKeys.splice(b, 1), b -= 1)
  458. }, a.prototype.addHitArea = function(a, b, c, d, e) {
  459. "undefined" == typeof e && (e = !1), null == c && (c = new Object), e && this.removeHitArea(a);
  460. var f = new Array;
  461. switch (d.type) {
  462. case "image":
  463. d.oImageData.isSpriteSheet ? this.aHitAreas.push({id: a,aTouchIdentifiers: f,callback: b,oData: c,rect: !0,area: [d.aCentrePos[0] - d.oImageData.oData.spriteHeight / 2, d.aCentrePos[1] - d.oImageData.oData.spriteHeight / 2, d.aCentrePos[0] + d.oImageData.oData.spriteWidth / 2, d.aCentrePos[1] + d.oImageData.oData.spriteHeight / 2]}) : this.aHitAreas.push({id: a,aTouchIdentifiers: f,callback: b,oData: c,rect: !0,area: [d.aCentrePos[0] - d.oImageData.img.width / 2, d.aCentrePos[1] - d.oImageData.img.height / 2, d.aCentrePos[0] + d.oImageData.img.width / 2, d.aCentrePos[1] + d.oImageData.img.height / 2]});
  464. break;
  465. case "rect":
  466. this.aHitAreas.push({id: a,aTouchIdentifiers: f,callback: b,oData: c,rect: !0,area: d.aRect})
  467. }
  468. }, a.prototype.removeHitArea = function(a) {
  469. for (var b = 0; b < this.aHitAreas.length; b++)
  470. this.aHitAreas[b].id == a && (this.aHitAreas.splice(b, 1), b -= 1)
  471. }, a
  472. }();
  473. a.UserInput = b
  474. }(Utils || (Utils = {}));
  475. var Utils;
  476. !function(a) {
  477. var b = function() {
  478. function a(a) {
  479. this.updateFreq = 10, this.updateInc = 0, this.frameAverage = 0, this.display = 1, this.log = "", this.render = function(a) {
  480. this.frameAverage += this.delta / this.updateFreq, ++this.updateInc >= this.updateFreq && (this.updateInc = 0, this.display = this.frameAverage, this.frameAverage = 0), a.textAlign = "left", ctx.font = "10px Helvetica", a.fillStyle = "#333333", a.beginPath(), a.rect(0, this.canvasHeight - 15, 40, 15), a.closePath(), a.fill(), a.fillStyle = "#ffffff", a.fillText(Math.round(1e3 / (1e3 * this.display)) + " fps " + this.log, 5, this.canvasHeight - 5)
  481. }, this.canvasHeight = a
  482. }
  483. return a.prototype.update = function(a) {
  484. this.delta = a
  485. }, a
  486. }();
  487. a.FpsMeter = b
  488. }(Utils || (Utils = {}));
  489. var Elements;
  490. !function(a) {
  491. var b = function() {
  492. function a(a, b, c) {
  493. this.x = 0, this.y = 0, this.targY = 0, this.incY = 0, this.oImgData = a, this.canvasWidth = b, this.canvasHeight = c
  494. }
  495. return a.prototype.startScroll = function(a) {
  496. this.targY -= 5 * a, TweenLite.killTweensOf(this), TweenLite.to(this, 4, {y: this.targY,ease: "Quad.easeOut"})
  497. }, a.prototype.updateScroll = function(a) {
  498. this.incY += 5 * a, this.x = this.x - 50 * Math.sin(this.incY / 10) * a, this.y = this.y - 50 * a
  499. }, a.prototype.render = function(a) {
  500. this.x = this.x % this.canvasWidth, this.y = this.y % this.canvasHeight, this.x < 0 && (this.x += this.canvasWidth), this.y < 0 && (this.y += this.canvasHeight), a.drawImage(this.oImgData.img, this.x, this.y, this.canvasWidth, this.canvasHeight, 0, 0, this.canvasWidth, this.canvasHeight)
  501. }, a
  502. }();
  503. a.Background = b
  504. }(Elements || (Elements = {}));
  505. var Elements;
  506. !function(a) {
  507. var b = function() {
  508. function a(a, b, c, d, e) {
  509. this.incY = 0, this.score = 0, this.highestScore = 0, this.posY = 0, this.bgX = 0, this.bgY = 0, this.atmosX = 0, this.atmosY = 0, this.oButs = a, this.oBgImgData = b, this.oTitleImgData = c, this.canvasWidth = d, this.canvasHeight = e, this.posY = -this.canvasHeight
  510. }
  511. return a.prototype.setRenderFunc = function(a) {
  512. switch (this.posY = -this.canvasHeight, a) {
  513. case "start":
  514. this.renderFunc = this.renderStartScreen, TweenLite.to(this, .5, {posY: 0});
  515. break;
  516. case "help":
  517. break;
  518. case "end":
  519. }
  520. }, a.prototype.render = function(a, b) {
  521. this.renderFunc(a, b)
  522. }, a.prototype.renderStartScreen = function(a, b) {
  523. this.incY += 5 * b, this.bgY -= 50 * b, this.bgX -= 50 * Math.sin(this.incY / 10) * b;
  524. var c = this.bgX % this.canvasWidth, d = this.bgY % this.canvasHeight;
  525. 0 > c && (c += this.canvasWidth), 0 > d && (d += this.canvasHeight), a.drawImage(this.oBgImgData.img, c, d, this.canvasWidth, this.canvasHeight, 0, 0, this.canvasWidth, this.canvasHeight), a.drawImage(this.oTitleImgData.img, 15 + this.posY, 60), a.drawImage(this.oButs.play.imageData.img, this.oButs.play.pos[0] - this.oButs.play.imageData.img.width / 2, this.oButs.play.pos[1] - this.oButs.play.imageData.img.height / 2 - 5 * Math.sin(this.incY) - this.posY), a.drawImage(this.oButs.moreGames.imageData.img, this.oButs.moreGames.pos[0] - this.oButs.moreGames.imageData.img.width / 2, this.oButs.moreGames.pos[1] - this.oButs.moreGames.imageData.img.height / 2 - 5 * Math.sin(this.incY) - this.posY)
  526. }, a
  527. }();
  528. a.Screens = b
  529. }(Elements || (Elements = {}));
  530. var Elements;
  531. !function(a) {
  532. var b = function() {
  533. function a(a, b, c) {
  534. this.inc = 0, this.oSplashScreenImgData = a, this.canvasWidth = b, this.canvasHeight = c, this.posY = -this.canvasHeight, TweenLite.to(this, .5, {posY: 0})
  535. }
  536. return a.prototype.render = function(a, b) {
  537. this.inc += 5 * b, a.drawImage(this.oSplashScreenImgData.img, 0, 0 - this.posY)
  538. }, a
  539. }();
  540. a.Splash = b
  541. }(Elements || (Elements = {}));
  542. var Elements;
  543. !function(a) {
  544. var b = function() {
  545. function a(a, b, c, d, e, f, g) {
  546. this.timer = .3, this.endTime = 0, this.posY = 0, this.numberSpace = 17, this.incY = 0, this.oPanelsImgData = a, this.oThinNumbersImgData = b, this.oFatNumbersImgData = c, this.panelType = d, this.aButs = e, this.canvasWidth = f, this.canvasHeight = g
  547. }
  548. return a.prototype.update = function(a) {
  549. this.incY += 5 * a
  550. }, a.prototype.startTween = function() {
  551. this.posY = 550, TweenLite.to(this, .8, {posY: 0,ease: "Back.easeOut"})
  552. }, a.prototype.render = function(a) {
  553. switch (this.panelType) {
  554. case "start":
  555. var b = 6, c = b * this.oPanelsImgData.oData.spriteWidth % this.oPanelsImgData.img.width, d = Math.floor(b / (this.oPanelsImgData.img.width / this.oPanelsImgData.oData.spriteWidth)) * this.oPanelsImgData.oData.spriteHeight;
  556. a.drawImage(this.oPanelsImgData.img, c, d, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight, 0, 0 + this.posY - 20, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight);
  557. break;
  558. case "gameOver":
  559. var b = 5, c = b * this.oPanelsImgData.oData.spriteWidth % this.oPanelsImgData.img.width, d = Math.floor(b / (this.oPanelsImgData.img.width / this.oPanelsImgData.oData.spriteWidth)) * this.oPanelsImgData.oData.spriteHeight;
  560. a.drawImage(this.oPanelsImgData.img, c, d, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight, 0, 0 + this.posY, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight);
  561. for (var e = this.oScoreData.gameScore, f = 0; f < e.toString().length; f++) {
  562. b = parseFloat(e.toString().charAt(f));
  563. var c = b * this.oFatNumbersImgData.oData.spriteWidth % this.oFatNumbersImgData.img.width, d = Math.floor(b / (this.oFatNumbersImgData.img.width / this.oFatNumbersImgData.oData.spriteWidth)) * this.oFatNumbersImgData.oData.spriteHeight;
  564. a.drawImage(this.oFatNumbersImgData.img, c, d, this.oFatNumbersImgData.oData.spriteWidth, this.oFatNumbersImgData.oData.spriteHeight, this.canvasWidth / 2 + 25 * f - 25 * e.toString().length / 2, 193 + this.posY, this.oFatNumbersImgData.oData.spriteWidth, this.oFatNumbersImgData.oData.spriteHeight)
  565. }
  566. for (var e = this.oScoreData.longestChain, f = 0; f < e.toString().length; f++) {
  567. b = parseFloat(e.toString().charAt(f));
  568. var c = b * this.oThinNumbersImgData.oData.spriteWidth % this.oThinNumbersImgData.img.width, d = Math.floor(b / (this.oThinNumbersImgData.img.width / this.oThinNumbersImgData.oData.spriteWidth)) * this.oThinNumbersImgData.oData.spriteHeight;
  569. a.drawImage(this.oThinNumbersImgData.img, c, d, this.oThinNumbersImgData.oData.spriteWidth, this.oThinNumbersImgData.oData.spriteHeight, 224 + f * this.numberSpace, 253 + this.posY, this.oThinNumbersImgData.oData.spriteWidth, this.oThinNumbersImgData.oData.spriteHeight)
  570. }
  571. for (var e = this.oScoreData.balloonsPopped, f = 0; f < e.toString().length; f++) {
  572. b = parseFloat(e.toString().charAt(f));
  573. var c = b * this.oThinNumbersImgData.oData.spriteWidth % this.oThinNumbersImgData.img.width, d = Math.floor(b / (this.oThinNumbersImgData.img.width / this.oThinNumbersImgData.oData.spriteWidth)) * this.oThinNumbersImgData.oData.spriteHeight;
  574. a.drawImage(this.oThinNumbersImgData.img, c, d, this.oThinNumbersImgData.oData.spriteWidth, this.oThinNumbersImgData.oData.spriteHeight, 253 + f * this.numberSpace, 286 + this.posY, this.oThinNumbersImgData.oData.spriteWidth, this.oThinNumbersImgData.oData.spriteHeight)
  575. }
  576. for (var e = this.oScoreData.highScore, f = 0; f < e.toString().length; f++) {
  577. b = parseFloat(e.toString().charAt(f));
  578. var c = b * this.oThinNumbersImgData.oData.spriteWidth % this.oThinNumbersImgData.img.width, d = Math.floor(b / (this.oThinNumbersImgData.img.width / this.oThinNumbersImgData.oData.spriteWidth)) * this.oThinNumbersImgData.oData.spriteHeight;
  579. a.drawImage(this.oThinNumbersImgData.img, c, d, this.oThinNumbersImgData.oData.spriteWidth, this.oThinNumbersImgData.oData.spriteHeight, 186 + f * this.numberSpace, 342 + this.posY, this.oThinNumbersImgData.oData.spriteWidth, this.oThinNumbersImgData.oData.spriteHeight)
  580. }
  581. break;
  582. case "tutorial0":
  583. case "tutorial1":
  584. case "tutorial2":
  585. case "tutorial3":
  586. case "tutorial4":
  587. var b = parseFloat(this.panelType.charAt(this.panelType.length - 1)), c = b * this.oPanelsImgData.oData.spriteWidth % this.oPanelsImgData.img.width, d = Math.floor(b / (this.oPanelsImgData.img.width / this.oPanelsImgData.oData.spriteWidth)) * this.oPanelsImgData.oData.spriteHeight;
  588. a.drawImage(this.oPanelsImgData.img, c, d, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight, 0, 0 + this.posY, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight);
  589. break;
  590. case "pause":
  591. var b = 7, c = b * this.oPanelsImgData.oData.spriteWidth % this.oPanelsImgData.img.width, d = Math.floor(b / (this.oPanelsImgData.img.width / this.oPanelsImgData.oData.spriteWidth)) * this.oPanelsImgData.oData.spriteHeight;
  592. a.drawImage(this.oPanelsImgData.img, c, d, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight, 0, 0, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight)
  593. }
  594. for (var f = 0; f < this.aButs.length; f++)
  595. 0 == f % 2 ? a.drawImage(this.aButs[f].oImgData.img, this.aButs[f].aPos[0] - this.aButs[f].oImgData.img.width / 2 + this.posY, this.aButs[f].aPos[1] - this.aButs[f].oImgData.img.height / 2 - 5 * Math.sin(this.incY + 180)) : a.drawImage(this.aButs[f].oImgData.img, this.aButs[f].aPos[0] - this.aButs[f].oImgData.img.width / 2 - this.posY, this.aButs[f].aPos[1] - this.aButs[f].oImgData.img.height / 2 - 5 * Math.sin(this.incY))
  596. }, a
  597. }();
  598. a.Panel = b
  599. }(Elements || (Elements = {}));
  600. var Elements;
  601. !function(a) {
  602. var b = function() {
  603. function a(a, b, c, d, e) {
  604. this.score = 0, this.oHudImgData = a, this.oThinNumbersImgData = b, this.oFatNumbersImgData = c, this.canvasWidth = d, this.canvasHeight = e, this.score = 0
  605. }
  606. return a.prototype.render = function(a, b) {
  607. a.drawImage(this.oHudImgData.img, 0, 0);
  608. for (var c = 0; c < this.score.toString().length; c++) {
  609. var d = parseFloat(this.score.toString().charAt(c)), e = d * this.oFatNumbersImgData.oData.spriteWidth % this.oFatNumbersImgData.img.width, f = Math.floor(d / (this.oFatNumbersImgData.img.width / this.oFatNumbersImgData.oData.spriteWidth)) * this.oFatNumbersImgData.oData.spriteHeight;
  610. a.drawImage(this.oFatNumbersImgData.img, e, f, this.oFatNumbersImgData.oData.spriteWidth, this.oFatNumbersImgData.oData.spriteHeight, 175 + 25 * c - 25 * this.score.toString().length / 2, 18, this.oFatNumbersImgData.oData.spriteWidth, this.oFatNumbersImgData.oData.spriteHeight)
  611. }
  612. for (var c = 0; c < b.toString().length; c++) {
  613. var d = parseFloat(b.toString().charAt(c)), e = d * this.oThinNumbersImgData.oData.spriteWidth % this.oThinNumbersImgData.img.width, f = Math.floor(d / (this.oThinNumbersImgData.img.width / this.oThinNumbersImgData.oData.spriteWidth)) * this.oThinNumbersImgData.oData.spriteHeight;
  614. a.drawImage(this.oThinNumbersImgData.img, e, f, this.oThinNumbersImgData.oData.spriteWidth, this.oThinNumbersImgData.oData.spriteHeight, 31 + 17 * c - 17 * b.toString().length / 2, 22, this.oThinNumbersImgData.oData.spriteWidth, this.oThinNumbersImgData.oData.spriteHeight)
  615. }
  616. }, a.prototype.updateScore = function(a) {
  617. this.score = a
  618. }, a
  619. }();
  620. a.Hud = b
  621. }(Elements || (Elements = {}));
  622. var __extends = this.__extends || function(a, b) {
  623. function c() {
  624. this.constructor = a
  625. }
  626. c.prototype = b.prototype, a.prototype = new c
  627. }, Elements;
  628. !function(a) {
  629. var b = function(a) {
  630. function b(b, c, d, e, f, g) {
  631. a.call(this, b, 15, 15, "unSelected" + e), this.canHit = !0, this.selected = !1, this.popDelay = -1, this.oDotImgData = b, this.oPopImgData = c, this.id = d, this.type = this.colour = e, this.canvasWidth = f, this.canvasHeight = g, this.offsetY = 10, this.frameInc = Math.ceil(20 * Math.random()), this.animEndedFunc = this.burst
  632. }
  633. return __extends(b, a), b.prototype.fall = function() {
  634. this.y = this.targY + 550, this.x = this.targX, TweenLite.to(this, .5, {y: this.targY,delay: .02 * this.id,ease: "Quad.easeOut"})
  635. }, b.prototype.replaceWithExistingDot = function(a) {
  636. this.y = a.targY, this.type = a.type, this.removeMe = !1, this.canHit = !0, this.x = this.targX, this.changeSpriteSheet(this.oDotImgData), this.frameInc = a.frameInc, this.unSelect(), TweenLite.to(this, .5, {y: this.targY,ease: "Quad.easeInOut"})
  637. }, b.prototype.replaceWithNewDot = function(a) {
  638. this.y = this.targY + 550, this.type = a, this.removeMe = !1, this.canHit = !0, this.x = this.targX, this.changeSpriteSheet(this.oDotImgData), this.frameInc = Math.ceil(20 * Math.random()), this.unSelect(), TweenLite.to(this, .5, {y: this.targY,ease: "Quad.easeOut"})
  639. }, b.prototype.trySelect = function(a) {
  640. var b = a.x - this.x, c = a.targY - this.targY, d = b * b + c * c;
  641. return 8100 > d && (a.colour == this.colour || this.type >= 6 || 6 == a.type) ? (this.select(), this.type >= 7 && (this.colour = a.colour), this.prevDot = a, this) : a
  642. }, b.prototype.select = function() {
  643. this.selected || (this.setAnimType("loop", "selected" + this.type, !1), this.selected = !0)
  644. }, b.prototype.unSelect = function() {
  645. this.setAnimType("loop", "unSelected" + this.type, !1), this.selected = !1, this.colour = this.type
  646. }, b.prototype.update = function(b) {
  647. a.prototype.updateAnimation.call(this, b), this.popDelay >= 0 && (this.popDelay += b, this.popDelay > this.popDelayTarg && this.pop())
  648. }, b.prototype.hit = function(a) {
  649. this.popDelay = 0, this.popDelayTarg = .25 * a
  650. }, b.prototype.pop = function() {
  651. this.popDelay = -1, this.changeSpriteSheet(this.oPopImgData), this.canHit = !1, this.setAnimType("once", "pop")
  652. }, b.prototype.burst = function() {
  653. this.removeMe = !0
  654. }, b
  655. }(Utils.AnimSprite);
  656. a.Dot = b
  657. }(Elements || (Elements = {}));
  658. var requestAnimFrame = function() {
  659. return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(a) {
  660. window.setTimeout(a, 1e3 / 60, (new Date).getTime())
  661. }
  662. }(), previousTime, canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d");
  663. canvas.width = 383, canvas.height = 550;
  664. var canvasX, canvasY, canvasScaleX, canvasScaleY, div = document.getElementById("viewporter"), sound, music, allowSound = !1, muted = !1, splash, splashTimer = 0, screens, assetLib, preAssetLib, rotatePause = !1, manualPause = !1, isMobile = !1, gameState = "loading", aLangs = new Array("EN"), curLang = "", isBugBrowser = !1, deviceAgent = navigator.userAgent.toLowerCase();
  665. (deviceAgent.match(/(iphone|ipod|ipad)/) || deviceAgent.match(/(android)/) || deviceAgent.match(/(iemobile)/) || deviceAgent.match(/iphone/i) || deviceAgent.match(/ipad/i) || deviceAgent.match(/ipod/i) || deviceAgent.match(/blackberry/i) || deviceAgent.match(/bada/i)) && (isMobile = !0, deviceAgent.match(/(android)/) && !/Chrome/.test(navigator.userAgent) && (isBugBrowser = !0));
  666. var userInput = new Utils.UserInput(canvas, isBugBrowser);
  667. resizeCanvas(), window.onresize = function() {
  668. setTimeout(function() {
  669. resizeCanvas()
  670. }, 1)
  671. }, window.addEventListener("load", function() {
  672. setTimeout(function() {
  673. resizeCanvas()
  674. }, 0), window.addEventListener("orientationchange", function() {
  675. resizeCanvas()
  676. }, !1)
  677. }), ("undefined" != typeof window.AudioContext || "undefined" != typeof window.webkitAudioContext || -1 == navigator.userAgent.indexOf("Android")) && (allowSound = !0, sound = new Howl({urls: ["audio/sound.ogg", "audio/sound.m4a"],sprite: {pop1: [0, 400],pop2: [500, 400],pop3: [1e3, 750],click: [2e3, 300],timesUp: [2500, 2400],explode: [5e3, 1500],drag: [7e3, 400]}}), music = new Howl({urls: ["audio/music.ogg", "audio/music.m4a"],volume: .25,loop: !0}));
  678. var panel, hud, background, gameScore, gameNum = 0, aLevelUps, aTutorials = new Array({gameNum: 0,shown: !1,panelType: "tutorial0"}, {gameNum: 1,shown: !1,panelType: "tutorial1"}, {gameNum: 2,shown: !1,panelType: "tutorial2"}, {gameNum: 3,shown: !1,panelType: "tutorial3"}, {gameNum: 4,shown: !1,panelType: "tutorial4"}), panelFrame, aDots, lastSelectedDot, aSelected, blockTap = !1, removedDots, gameTime, longestChain, balloonsPopped, highScore = 0;
  679. loadPreAssets();