app.js 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428
  1. function initStartScreen() {
  2. /*(updateShare(0),*/ gameState = "start", userInput.removeHitArea("moreGames"), 1 == audioType && music.volume(.25), levelScore = 0, levelNum = 0, background = new Elements.Background(assetLib.getData("background"), canvas.width, canvas.height), userInput.addHitArea("mute", butEventHandler, null, "rect", {
  3. aRect: [392, 0, canvas.width, 53]
  4. }, !0);
  5. var e = {
  6. oImgData: assetLib.getData("uiButs"),
  7. aPos: [canvas.width / 2, 415],
  8. type: 1,
  9. frame: 0
  10. },
  11. t = {
  12. oImgData: assetLib.getData("uiButs"),
  13. aPos: [canvas.width / 2, 530],
  14. type: 1,
  15. frame: 2
  16. };
  17. userInput.addHitArea("startGame", butEventHandler, null, "image", e), userInput.addHitArea("moreGames", butEventHandler, null, "image", t);
  18. var n = getScaleImageToMax("", [184, 58]);
  19. oSpilLogoBut = {
  20. oImgData: assetLib.getData("logo"),
  21. aPos: getCentreFromTopLeft([13, 13], assetLib.getData("logo"), n),
  22. scale: n,
  23. type: 0
  24. }, userInput.addHitArea("logo", butEventHandler, null, "image", oSpilLogoBut);
  25. var r = new Array(e, t, oSpilLogoBut);
  26. panel = new Elements.Panel(assetLib.getData("panels"), assetLib.getData("bigNumbers"), assetLib.getData("smallNumbers"), gameState, r, canvas.width, canvas.height), panel.startTween(), aBubbles = new Array;
  27. for (var i = 0; 20 > i; i++) {
  28. var s = new Elements.Bubble(assetLib.getData("bubbles"), Math.floor(4 * Math.random()), [450 * Math.round(1 * Math.random()), 600 * Math.random()], canvas.width, canvas.height);
  29. aBubbles.push(s)
  30. }
  31. previousTime = (new Date).getTime(), updateStartScreenEvent()
  32. }
  33. function initPreGame() {
  34. gameState = "tutorial", background = new Elements.Background(assetLib.getData("background"), canvas.width, canvas.height);
  35. for (var e = 0; e < aTutorials.length; e++)
  36. if (aTutorials[e].levelNum == levelNum && !aTutorials[e].shown) {
  37. var t = {
  38. oImgData: assetLib.getData("uiButs"),
  39. aPos: [canvas.width / 2, 500],
  40. type: 1,
  41. frame: 0
  42. };
  43. userInput.addHitArea("continue", butEventHandler, null, "rect", {
  44. aRect: [0, 60, canvas.width, canvas.height]
  45. }, !0);
  46. var n = getScaleImageToMax(assetLib.getData("logo"), [184, 58]);
  47. oSpilLogoBut = {
  48. oImgData: assetLib.getData("logo"),
  49. aPos: getCentreFromTopLeft([13, 13], assetLib.getData("logo"), n),
  50. scale: n,
  51. type: 0
  52. }, userInput.addHitArea("logo", butEventHandler, null, "image", oSpilLogoBut);
  53. var r = new Array(t, oSpilLogoBut);
  54. return background.render(ctx), panel = new Elements.Panel(assetLib.getData("panels"), assetLib.getData("bigNumbers"), assetLib.getData("smallNumbers"), aTutorials[e].panelType, r, canvas.width, canvas.height), panelFrame = aTutorials[e].panelFrame, panel.startTween(), previousTime = (new Date).getTime(), updateTutorialEvent(), void 0
  55. }
  56. initGame()
  57. }
  58. function initGame() {
  59. gameState = "game", 1 == audioType && music.volume(.5), background = new Elements.Background(assetLib.getData("background"), canvas.width, canvas.height), userInput.addHitArea("pause", butEventHandler, null, "rect", {
  60. aRect: [0, 0, 53, 53]
  61. }, !0), userInput.addHitArea("wash", butEventHandler, {
  62. isDraggable: !0,
  63. multiTouch: !0
  64. }, "rect", {
  65. aRect: [0, 60, canvas.width, 540]
  66. }, !0);
  67. var e = getScaleImageToMax(assetLib.getData("logo"), [0, 0]);
  68. oSpilLogoBut = {
  69. oImgData: assetLib.getData("logo"),
  70. aPos: getCentreFromBottomRight([440, 590], assetLib.getData("logo"), e),
  71. scale: e,
  72. type: 0
  73. }, userInput.addHitArea("logo", butEventHandler, null, "image", oSpilLogoBut), water = new Elements.Water(assetLib.getData("water"), canvas.width, canvas.height), hud = new Elements.Hud(assetLib.getData("hud"), assetLib.getData("bigNumbers"), assetLib.getData("smallNumbers"), canvas.width, canvas.height), gameTimer = 0, allowWashing = !0, addCrockery(), aBubbles = new Array, bubbleLimiter = 0, previousTime = (new Date).getTime(), updateGameEvent()
  74. }
  75. function dsdsff() {
  76. var e = spilAPI.Branding.getSplashScreen();
  77. if (e.show && e.action) {
  78. var t = document.getElementById("spilgames-splash-screen");
  79. t.addEventListener("click", e.action), t.classList.remove("spilgames-splash-screen-gone"), window.setTimeout(function() {
  80. t.classList.add("spilgames-splash-screen-gone"), 1 != audioType || muted || music.play(), initStartScreen(), resizeCanvas()
  81. }, 2e3)
  82. } else 1 != audioType || muted || music.play(), initStartScreen(), resizeCanvas()
  83. }
  84. function butEventHandler(e, t) {
  85. switch (e) {
  86. case "langSelect":
  87. console.log(t.lang), curLang = t.lang, ctx.clearRect(0, 0, canvas.width, canvas.height), userInput.removeHitArea("langSelect"), initLoadAssets();
  88. break;
  89. case "startGame":
  90. playSound("click"), userInput.removeHitArea("startGame"), userInput.removeHitArea("moreGames"), userInput.removeHitArea("logo"), initPreGame();
  91. break;
  92. case "logo":
  93. playSound("click"), oSpilLogoData.action();
  94. break;
  95. case "moreGames":
  96. // playSound("click"), Play68.goHome();
  97. break;
  98. case "continue":
  99. playSound("click"), userInput.removeHitArea("continue"), userInput.removeHitArea("logo"), initGame();
  100. break;
  101. case "wash":
  102. allowWashing && (t.isBeingDragged ? (aPrevWashPos = aCurWashPos.slice(0), aCurWashPos = [t.x, t.y], isWashing = !0, crockery.eyesOpen = !1) : t.isDown ? (aPrevWashPos = [t.x, t.y], aCurWashPos = [t.x, t.y], crockery.eyesOpen = !1) : crockery.eyesOpen = !0);
  103. break;
  104. case "replay":
  105. playSound("click"), userInput.removeHitArea("moreGames"), userInput.removeHitArea("logo"), userInput.removeHitArea("replay"), userInput.removeHitArea("exitFromEnd"), levelScore = 0, initGame(), spilAPI.GameBreak.request(adPauseOn, adPauseOff), console.log("show ad");
  106. break;
  107. case "exitFromEnd":
  108. playSound("click"), userInput.removeHitArea("moreGames"), userInput.removeHitArea("logo"), userInput.removeHitArea("replay"), userInput.removeHitArea("exitFromEnd"), levelScore = 0, initStartScreen();
  109. break;
  110. case "mute":
  111. playSound("click"), toggleMute();
  112. break;
  113. case "pause":
  114. case "resumeFromPause":
  115. playSound("click"), toggleManualPause();
  116. break;
  117. case "quitFromPause":
  118. playSound("click"), toggleManualPause(), userInput.removeHitArea("pause"), userInput.removeHitArea("wash"), userInput.removeHitArea("quitFromPause"), userInput.removeHitArea("resumeFromPause"), userInput.removeHitArea("moreGames"), levelScore = 0, initStartScreen()
  119. }
  120. }
  121. function initGameOver() {
  122. gameState = "gameOver", 1 == audioType && music.volume(.25), playSound("gameEnd"), userInput.removeHitArea("pause"), userInput.removeHitArea("wash"), userInput.removeHitArea("logo");
  123. var e = {
  124. oImgData: assetLib.getData("uiButs"),
  125. aPos: [120, 530],
  126. type: 1,
  127. frame: 2
  128. },
  129. t = {
  130. oImgData: assetLib.getData("uiButs"),
  131. aPos: [330, 530],
  132. type: 1,
  133. frame: 0
  134. },
  135. n = {
  136. oImgData: assetLib.getData("uiButs"),
  137. aPos: [120, 70],
  138. type: 1,
  139. frame: 1
  140. };
  141. userInput.addHitArea("moreGames", butEventHandler, null, "image", e), userInput.addHitArea("replay", butEventHandler, null, "image", t), userInput.addHitArea("exitFromEnd", butEventHandler, null, "image", n);
  142. var r = getScaleImageToMax(assetLib.getData("logo"), [160, 63]);
  143. oSpilLogoBut = {
  144. oImgData: assetLib.getData("logo"),
  145. aPos: getCentreFromTopLeft([230, 50], assetLib.getData("logo"), r),
  146. scale: r,
  147. type: 0
  148. }, userInput.addHitArea("logo", butEventHandler, null, "image", oSpilLogoBut);
  149. var i = new Array(e, t, n, oSpilLogoBut);
  150. panel = new Elements.Panel(assetLib.getData("panels"), assetLib.getData("bigNumbers"), assetLib.getData("smallNumbers"), gameState, i, canvas.width, canvas.height), panel.startTween(), aBubbles = new Array;
  151. for (var s = 0; 20 > s; s++) {
  152. var o = new Elements.Bubble(assetLib.getData("bubbles"), Math.floor(4 * Math.random()), [450 * Math.round(1 * Math.random()), 600 * Math.random()], canvas.width, canvas.height);
  153. aBubbles.push(o)
  154. }
  155. levelScore += 100 * hud.washedNum, myPlayGameScore = levelScore;
  156. levelScore > highScore && (highScore = levelScore), panel.oScoreData = {
  157. levelScore: levelScore,
  158. highScore: highScore
  159. }, previousTime = (new Date).getTime(), updateGameOver();
  160. // updateShare(myPlayGameScore);
  161. // Play68.setRankingScoreDesc(myPlayGameScore)
  162. }
  163. function addCrockery() {
  164. playSound("startSplash"), crockery = new Elements.Crockery(assetLib.getData("crockery"), assetLib.getData("expressions"), assetLib.getData("dirt"), crockeryCallback, crockeryId, canvas.width, canvas.height), crockery.startTween(), crockeryId = (crockeryId + 1) % 5
  165. }
  166. function addBubble(e) {
  167. var t;
  168. flipFlop ? (playSound("wash" + Math.floor(4 * Math.random())), flipFlop = !1) : flipFlop = !0, t = new Elements.Bubble(assetLib.getData("bubbles"), Math.floor(4 * Math.random()), aCurWashPos, canvas.width, canvas.height);
  169. var n = aPrevWashPos[0] - aCurWashPos[0],
  170. r = aPrevWashPos[1] - aCurWashPos[1],
  171. i = (n * n + r * r) / e / 2e3;
  172. aBubbles.push(t), crockery.wash(Math.min(i, .5), aCurWashPos)
  173. }
  174. function addSparkle() {
  175. var e;
  176. e = new Elements.Bubble(assetLib.getData("bubbles"), 4, [400 * Math.random() + 25, 300 * Math.random() + 150], canvas.width, canvas.height), aBubbles.push(e)
  177. }
  178. function crockeryCallback(e) {
  179. switch (e) {
  180. case "dirtClean":
  181. levelScore += 10;
  182. break;
  183. case "allClean":
  184. playSound("dishClean"), allowWashing = !1, isWashing = !1, hud.washedNum++, aBubbles = new Array;
  185. for (var t = 0; 10 > t; t++) addSparkle();
  186. break;
  187. case "removed":
  188. addCrockery(), allowWashing = !0, isWashing = !0
  189. }
  190. }
  191. function updateGameEvent() {
  192. if (!manualPause && !rotatePause && "game" == gameState) {
  193. var e = getDelta();
  194. if (gameTimer += e, gameTimer >= 1 && (gameTimer = 0, --hud.time <= 0)) return initGameOver(), void 0;
  195. background.render(ctx), water.update(e), water.render(ctx), crockery.render(ctx), bubbleLimiter += e, isWashing && bubbleLimiter > .15 && aBubbles.length < 20 && (addBubble(e), isWashing = !1, bubbleLimiter = 0);
  196. for (var t = 0; t < aBubbles.length; t++) aBubbles[t].update(e), renderSprite(aBubbles[t]), aBubbles[t].removeMe && (aBubbles.splice(t, 1), t -= 1);
  197. hud.render(ctx), renderMuteBut(), renderLogoBut(), requestAnimFrame(updateGameEvent)
  198. }
  199. }
  200. function updateGameOver() {
  201. if (!rotatePause && "gameOver" == gameState) {
  202. var e = getDelta();
  203. background.render(ctx), panel.update(e), panel.render(ctx);
  204. for (var t = 0; t < aBubbles.length; t++) aBubbles[t].update(e), renderSprite(aBubbles[t]), aBubbles[t].removeMe && (aBubbles[t].x = 450 * Math.round(1 * Math.random()), aBubbles[t].y = 600 * Math.random(), aBubbles[t].vy = 0, aBubbles[t].startTween(), aBubbles[t].removeMe = !1);
  205. renderMuteBut(), requestAnimFrame(updateGameOver)
  206. }
  207. }
  208. function updateSplashScreenEvent() {
  209. if (!rotatePause && "splash" == gameState) {
  210. var e = getDelta();
  211. if (splashTimer += e, splashTimer > 2.5) return 1 != audioType || muted || music.play(), initStartScreen(), void 0;
  212. splash.render(ctx, e), requestAnimFrame(updateSplashScreenEvent)
  213. }
  214. }
  215. function updateStartScreenEvent() {
  216. if (!rotatePause && "start" == gameState) {
  217. var e = getDelta();
  218. background.render(ctx), panel.update(e), panel.render(ctx);
  219. for (var t = 0; t < aBubbles.length; t++) aBubbles[t].update(e), renderSprite(aBubbles[t]), aBubbles[t].removeMe && (aBubbles[t].x = 450 * Math.round(1 * Math.random()), aBubbles[t].y = 600 * Math.random(), aBubbles[t].vy = 0, aBubbles[t].startTween(), aBubbles[t].removeMe = !1);
  220. renderMuteBut(), requestAnimFrame(updateStartScreenEvent)
  221. }
  222. }
  223. function updateTutorialEvent() {
  224. if (!rotatePause && "tutorial" == gameState) {
  225. var e = getDelta();
  226. background.render(ctx), panel.update(e), panel.render(ctx);
  227. for (var t = 0; t < aBubbles.length; t++) aBubbles[t].update(e), renderSprite(aBubbles[t]), aBubbles[t].removeMe && (aBubbles[t].x = 450 * Math.round(1 * Math.random()), aBubbles[t].y = 600 * Math.random(), aBubbles[t].vy = 0, aBubbles[t].startTween(), aBubbles[t].removeMe = !1);
  228. renderMuteBut(), requestAnimFrame(updateTutorialEvent)
  229. }
  230. }
  231. function getDelta() {
  232. var e = (new Date).getTime(),
  233. t = (e - previousTime) / 1e3;
  234. return previousTime = e, t > .5 && (t = 0), t
  235. }
  236. function renderSprite(e) {
  237. ctx.save(), ctx.translate(e.x, e.y), ctx.scale(e.scaleX, e.scaleY), ctx.rotate(e.rotation), e.render(ctx), ctx.restore()
  238. }
  239. function checkSpriteCollision(e, t) {
  240. var n = e.x,
  241. r = e.y,
  242. i = t.x,
  243. s = t.y,
  244. o = (n - i) * (n - i) + (r - s) * (r - s),
  245. u = e.radius * t.radius;
  246. return u > o ? !0 : !1
  247. }
  248. function getScaleImageToMax(e, t) {
  249. var n
  250. }
  251. function getCentreFromTopLeft(e, t, n) {
  252. var r = new Array;
  253. return r.push(e[0] + t.oData.spriteWidth / 2 * n), r.push(e[1] + t.oData.spriteHeight / 2 * n), r
  254. }
  255. function getCentreFromBottomRight(e, t, n) {
  256. var r = new Array;
  257. return r.push(e[0] - t.oData.spriteWidth / 2 * n), r.push(e[1] - t.oData.spriteHeight / 2 * n), r
  258. }
  259. function loadPreAssets() {
  260. aLangs.length > 1 ? (preAssetLib = new Utils.AssetLoader(curLang, [{
  261. id: "langSelect",
  262. file: "images/langSelect.jpg"
  263. }, {
  264. id: "preloadImage",
  265. file: "images/preloadImage.jpg"
  266. }], ctx, canvas.width, canvas.height, !1), preAssetLib.onReady(initLangSelect)) : (curLang = aLangs[0], preAssetLib = new Utils.AssetLoader(curLang, [{
  267. id: "preloadImage",
  268. file: "images/preloadImage.jpg"
  269. }], ctx, canvas.width, canvas.height, !1), preAssetLib.onReady(initLoadAssets))
  270. }
  271. function initLangSelect() {
  272. var e = preAssetLib.getData("langSelect");
  273. ctx.drawImage(e.img, canvas.width / 2 - e.img.width / 2, canvas.height / 2 - e.img.height / 2);
  274. for (var t = 140, n = 0; n < aLangs.length; n++) {
  275. var r = canvas.width / 2 - t * aLangs.length / 2 + n * t,
  276. i = canvas.height / 2 - t / 2;
  277. userInput.addHitArea("langSelect", butEventHandler, {
  278. lang: aLangs[n]
  279. }, "rect", {
  280. aRect: [r, i, r + t, i + 140]
  281. })
  282. }
  283. }
  284. function initLoadAssets() {
  285. var e = preAssetLib.getData("preloadImage");
  286. ctx.drawImage(e.img, 0, 0), loadAssets()
  287. }
  288. function loadAssets() {
  289. assetLib = new Utils.AssetLoader(curLang, [{
  290. id: "background",
  291. file: "images/background.jpg"
  292. }, {
  293. id: "rotateDeviceMessage",
  294. file: "images/rotateDeviceMessage.jpg"
  295. }, {
  296. id: "splash",
  297. file: "images/splashScreen.jpg"
  298. }, {
  299. id: "hud",
  300. file: "images/hud.png"
  301. }, {
  302. id: "water",
  303. file: "images/water.png"
  304. }, {
  305. id: "uiButs",
  306. file: "images/uiButs_201x109.png",
  307. oData: {
  308. columns: 2,
  309. spriteWidth: 201,
  310. spriteHeight: 109
  311. }
  312. }, {
  313. id: "panels",
  314. file: "images/" + curLang + "/panels_450x600.png",
  315. oData: {
  316. columns: 2,
  317. spriteWidth: 450,
  318. spriteHeight: 600
  319. }
  320. }, {
  321. id: "crockery",
  322. file: "images/crockery_364x331.png",
  323. oData: {
  324. columns: 2,
  325. spriteWidth: 364,
  326. spriteHeight: 331
  327. }
  328. }, {
  329. id: "expressions",
  330. file: "images/expressions_271x108.png",
  331. oData: {
  332. columns: 3,
  333. spriteWidth: 271,
  334. spriteHeight: 108
  335. }
  336. }, {
  337. id: "bubbles",
  338. file: "images/bubbles_84x88.png",
  339. oData: {
  340. columns: 4,
  341. spriteWidth: 84,
  342. spriteHeight: 88
  343. }
  344. }, {
  345. id: "dirt",
  346. file: "images/dirt_71x72.png",
  347. oData: {
  348. columns: 14,
  349. spriteWidth: 71,
  350. spriteHeight: 72
  351. }
  352. }, {
  353. id: "bigNumbers",
  354. file: "images/bigNumbers_50x64.png",
  355. oData: {
  356. columns: 10,
  357. spriteWidth: 50,
  358. spriteHeight: 64
  359. }
  360. }, {
  361. id: "smallNumbers",
  362. file: "images/smallNumbers_22x30.png",
  363. oData: {
  364. columns: 10,
  365. spriteWidth: 22,
  366. spriteHeight: 30
  367. }
  368. }, {
  369. id: "muteBut",
  370. file: "images/mute_53x53.png",
  371. oData: {
  372. columns: 2,
  373. spriteWidth: 53,
  374. spriteHeight: 53
  375. }
  376. }, {
  377. id: "logo",
  378. file: oSpilLogoData.image
  379. }], ctx, canvas.width, canvas.height);
  380. assetLib.onReady(dsdsff);
  381. }
  382. function resizeCanvas() {
  383. var e = window.innerWidth,
  384. t = window.innerHeight;
  385. e > 480 && (e -= 1, t -= 1), window.innerWidth > window.innerHeight && isMobile ? ("loading" != gameState && rotatePauseOn(), e / canvas.width < t / canvas.height ? (canvas.style.width = e + "px", canvas.style.height = e / canvas.width * canvas.height + "px", canvasX = 0, canvasY = (t - e / canvas.width * canvas.height) / 2, canvasScaleX = canvasScaleY = canvas.width / e, div.style.marginTop = canvasY + "px", div.style.marginLeft = canvasX + "px") : (canvas.style.width = t / canvas.height * canvas.width + "px", canvas.style.height = t + "px", canvasX = (e - t / canvas.height * canvas.width) / 2, canvasY = 0, canvasScaleX = canvasScaleY = canvas.height / t, div.style.marginTop = canvasY + "px", div.style.marginLeft = canvasX + "px")) : isMobile ? (rotatePause && rotatePauseOff(), canvasX = canvasY = 0, canvasScaleX = canvas.width / e, canvasScaleY = canvas.height / t, canvas.style.width = e + "px", canvas.style.height = t + "px", div.style.marginTop = "0px", div.style.marginLeft = "0px") : (rotatePause && rotatePauseOff(), e / canvas.width < t / canvas.height ? (canvas.style.width = e + "px", canvas.style.height = e / canvas.width * canvas.height + "px", canvasX = 0, canvasY = (t - e / canvas.width * canvas.height) / 2, canvasScaleX = canvasScaleY = canvas.width / e, div.style.marginTop = canvasY + "px", div.style.marginLeft = canvasX + "px") : (canvas.style.width = t / canvas.height * canvas.width + "px", canvas.style.height = t + "px", canvasX = (e - t / canvas.height * canvas.width) / 2, canvasY = 0, canvasScaleX = canvasScaleY = canvas.height / t, div.style.marginTop = canvasY + "px", div.style.marginLeft = canvasX + "px")), userInput.setCanvas(canvasX, canvasY, canvasScaleX, canvasScaleY)
  386. }
  387. function playSound(e) {
  388. 1 == audioType && sound.play(e)
  389. }
  390. function toggleMute() {
  391. muted = !muted, 1 == audioType ? muted ? Howler.mute() : Howler.unmute() : 2 == audioType && (muted ? music.pause() : music.play()), renderMuteBut()
  392. }
  393. function renderLogoBut() {
  394. ctx.drawImage(oSpilLogoBut.oImgData.img, 0, 0, oSpilLogoBut.oImgData.img.width, oSpilLogoBut.oImgData.img.height, oSpilLogoBut.aPos[0] - oSpilLogoBut.oImgData.img.width / 2 * oSpilLogoBut.scale, oSpilLogoBut.aPos[1] - oSpilLogoBut.oImgData.img.height / 2 * oSpilLogoBut.scale, oSpilLogoBut.oImgData.img.width * oSpilLogoBut.scale, oSpilLogoBut.oImgData.img.height * oSpilLogoBut.scale)
  395. }
  396. function renderMuteBut() {
  397. if (0 != audioType) {
  398. var e = assetLib.getData("muteBut"),
  399. t = 0;
  400. muted && (t = 1);
  401. var n = t * e.oData.spriteWidth % e.img.width,
  402. r = Math.floor(t / (e.img.width / e.oData.spriteWidth)) * e.oData.spriteHeight;
  403. ctx.drawImage(e.img, n, r, e.oData.spriteWidth, e.oData.spriteHeight, 388, 7, e.oData.spriteWidth, e.oData.spriteHeight)
  404. }
  405. }
  406. function adPauseOn() {
  407. toggleManualPause()
  408. }
  409. function adPauseOff() {
  410. manualPause && toggleManualPause()
  411. }
  412. function toggleManualPause() {
  413. if (manualPause) manualPause = !1, userInput.removeHitArea("quitFromPause"), userInput.removeHitArea("resumeFromPause"), userInput.removeHitArea("moreGames"), pauseCoreOff();
  414. else {
  415. manualPause = !0, pauseCoreOn();
  416. var e = {
  417. oImgData: assetLib.getData("uiButs"),
  418. aPos: [120, 400],
  419. type: 1,
  420. frame: 1
  421. },
  422. t = {
  423. oImgData: assetLib.getData("uiButs"),
  424. aPos: [330, 400],
  425. type: 1,
  426. frame: 0
  427. },
  428. n = {
  429. oImgData: assetLib.getData("uiButs"),
  430. aPos: [120, 520],
  431. type: 1,
  432. frame: 2
  433. },
  434. r = new Array(e, t, n);
  435. userInput.addHitArea("quitFromPause", butEventHandler, null, "image", e), userInput.addHitArea("resumeFromPause", butEventHandler, null, "image", t), userInput.addHitArea("moreGames", butEventHandler, null, "image", n), panel = new Elements.Panel(assetLib.getData("panels"), assetLib.getData("bigNumbers"), assetLib.getData("smallNumbers"), "pause", r, canvas.width, canvas.height), panel.render(ctx), renderLogoBut(), userInput.addHitArea("pause", butEventHandler, null, "rect", {
  436. aRect: [0, 0, 53, 53]
  437. }, !0)
  438. }
  439. }
  440. function rotatePauseOn() {
  441. rotatePause = !0, ctx.drawImage(assetLib.getImg("rotateDeviceMessage"), 0, 0), userInput.pauseIsOn = !0, pauseCoreOn()
  442. }
  443. function rotatePauseOff() {
  444. rotatePause = !1, userInput.removeHitArea("quitFromPause"), userInput.removeHitArea("resumeFromPause"), userInput.removeHitArea("moreGames"), pauseCoreOff()
  445. }
  446. function pauseCoreOn() {
  447. switch (1 == audioType ? Howler.mute() : 2 == audioType && music.pause(), gameState) {
  448. case "game":
  449. userInput.removeHitArea("wash")
  450. }
  451. }
  452. function pauseCoreOff() {
  453. switch (1 == audioType ? muted || Howler.unmute() : 2 == audioType && (muted || music.play()), previousTime = (new Date).getTime(), userInput.pauseIsOn = !1, gameState) {
  454. case "splash":
  455. updateSplashScreenEvent();
  456. break;
  457. case "start":
  458. initStartScreen();
  459. break;
  460. case "tutorial":
  461. initPreGame();
  462. break;
  463. case "game":
  464. manualPause = !1, userInput.addHitArea("wash", butEventHandler, {
  465. isDraggable: !0,
  466. multiTouch: !0
  467. }, "rect", {
  468. aRect: [0, 60, canvas.width, canvas.height]
  469. }, !0), updateGameEvent();
  470. break;
  471. case "gameOver":
  472. initGameOver()
  473. }
  474. }
  475. var myPlayGameScore = "";
  476. var Utils;
  477. ! function(e) {
  478. var t = function() {
  479. function e(e, t, n, r, i, s) {
  480. "undefined" == typeof s && (s = !0), this.oAssetData = {}, this.assetsLoaded = 0, this.totalAssets = t.length, this.ctx = n, this.canvasWidth = r, this.canvasHeight = i, this.showBar = s, this.topLeftX = this.canvasWidth / 2 - r / 4, this.topLeftY = 370, this.showBar && (ctx.strokeStyle = "#ffffff", ctx.lineWidth = 2, ctx.fillStyle = "#D27B5A", ctx.moveTo(this.topLeftX, this.topLeftY), ctx.lineTo(this.topLeftX + r / 2, this.topLeftY + 0), ctx.lineTo(this.topLeftX + r / 2, this.topLeftY + 20), ctx.lineTo(this.topLeftX + 0, this.topLeftY + 20), ctx.lineTo(this.topLeftX + 0, this.topLeftY + 0), ctx.stroke());
  481. for (var o = 0; o < t.length; o++) this.loadImage(t[o])
  482. }
  483. return e.prototype.loadImage = function(e) {
  484. var t = this,
  485. n = new Image;
  486. n.onload = function() {
  487. t.oAssetData[e.id] = {}, t.oAssetData[e.id].img = n, void 0 != e.oData ? (t.oAssetData[e.id].oData = e.oData, t.oAssetData[e.id].isSpriteSheet = !0) : (t.oAssetData[e.id].isSpriteSheet = !1, t.oAssetData[e.id].oData = {}, t.oAssetData[e.id].oData.spriteWidth = t.oAssetData[e.id].img.width, t.oAssetData[e.id].oData.spriteHeight = t.oAssetData[e.id].img.height), ++t.assetsLoaded, t.showBar && ctx.fillRect(t.topLeftX + 2, t.topLeftY + 2, (t.canvasWidth / 2 - 4) / t.totalAssets * t.assetsLoaded, 16), t.checkLoadComplete()
  488. }, n.src = e.file
  489. }, e.prototype.checkLoadComplete = function() {
  490. this.assetsLoaded == this.totalAssets && this.loadedCallback()
  491. }, e.prototype.onReady = function(e) {
  492. this.loadedCallback = e
  493. }, e.prototype.getImg = function(e) {
  494. return this.oAssetData[e].img
  495. }, e.prototype.getData = function(e) {
  496. return this.oAssetData[e]
  497. }, e
  498. }();
  499. e.AssetLoader = t
  500. }(Utils || (Utils = {}));
  501. var Utils;
  502. ! function(e) {
  503. var t = function() {
  504. function e(e, t, n, r) {
  505. 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 = e, this.oAnims = this.oImgData.oData.oAnims, this.fps = t, this.radius = n, this.animId = r
  506. }
  507. return e.prototype.updateAnimation = function(e) {
  508. this.frameInc += this.fps * e
  509. }, e.prototype.resetAnim = function() {
  510. this.frameInc = 0
  511. }, e.prototype.setFrame = function(e) {
  512. this.fixedFrame = e
  513. }, e.prototype.setAnimType = function(e, t, n) {
  514. switch ("undefined" == typeof n && (n = !0), this.animId = t, this.animType = e, n && this.resetAnim(), e) {
  515. case "loop":
  516. break;
  517. case "once":
  518. this.maxIdx = this.oAnims[this.animId].length - 1
  519. }
  520. }, e.prototype.render = function(e) {
  521. if (null != this.animId) {
  522. var t = this.oAnims[this.animId].length,
  523. n = Math.floor(this.frameInc),
  524. r = this.oAnims[this.animId][n % t],
  525. i = r * this.oImgData.oData.spriteWidth % this.oImgData.img.width,
  526. s = Math.floor(r / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight;
  527. if ("once" == this.animType && n > this.maxIdx) {
  528. this.fixedFrame = this.oAnims[this.animId][t - 1], this.animId = null, this.animEndedFunc();
  529. var i = this.fixedFrame * this.oImgData.oData.spriteWidth % this.oImgData.img.width,
  530. s = Math.floor(this.fixedFrame / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight
  531. }
  532. } else var i = this.fixedFrame * this.oImgData.oData.spriteWidth % this.oImgData.img.width,
  533. s = Math.floor(this.fixedFrame / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight;
  534. e.drawImage(this.oImgData.img, i, s, 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)
  535. }, e
  536. }();
  537. e.AnimSprite = t
  538. }(Utils || (Utils = {}));
  539. var Utils;
  540. ! function(e) {
  541. var t = function() {
  542. function e(e, t, n) {
  543. "undefined" == typeof n && (n = 0), 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 = e, this.radius = t, this.setFrame(n)
  544. }
  545. return e.prototype.setFrame = function(e) {
  546. this.frameNum = e
  547. }, e.prototype.render = function(e) {
  548. var t = this.frameNum * this.oImgData.oData.spriteWidth % this.oImgData.img.width,
  549. n = Math.floor(this.frameNum / (this.oImgData.img.width / this.oImgData.oData.spriteWidth)) * this.oImgData.oData.spriteHeight;
  550. e.drawImage(this.oImgData.img, t, n, 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)
  551. }, e
  552. }();
  553. e.BasicSprite = t
  554. }(Utils || (Utils = {}));
  555. var Utils;
  556. ! function(e) {
  557. var t = function() {
  558. function e(e, t) {
  559. var n = this;
  560. 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 = t, e.addEventListener("touchstart", function(e) {
  561. for (var t = 0; t < e.changedTouches.length; t++) n.hitDown(e, e.changedTouches[t].pageX, e.changedTouches[t].pageY, e.changedTouches[t].identifier)
  562. }, !1), e.addEventListener("touchend", function(e) {
  563. for (var t = 0; t < e.changedTouches.length; t++) n.hitUp(e, e.changedTouches[t].pageX, e.changedTouches[t].pageY, e.changedTouches[t].identifier)
  564. }, !1), e.addEventListener("touchmove", function(e) {
  565. for (var t = 0; t < n.aHitAreas.length; t++) n.move(e, e.changedTouches[t].pageX, e.changedTouches[t].pageY, e.changedTouches[t].identifier, !0)
  566. }, !1), e.addEventListener("mousedown", function(e) {
  567. n.isDown = !0, n.hitDown(e, e.pageX, e.pageY, 1)
  568. }, !1), e.addEventListener("mouseup", function(e) {
  569. n.isDown = !1, n.hitUp(e, e.pageX, e.pageY, 1)
  570. }, !1), e.addEventListener("mousemove", function(e) {
  571. n.move(e, e.pageX, e.pageY, 1, n.isDown)
  572. }, !1), this.aHitAreas = new Array, this.aKeys = new Array
  573. }
  574. return e.prototype.setCanvas = function(e, t, n, r) {
  575. this.canvasX = e, this.canvasY = t, this.canvasScaleX = n, this.canvasScaleY = r
  576. }, e.prototype.hitDown = function(e, t, n, r) {
  577. if (!this.pauseIsOn) {
  578. var i = (new Date).getTime();
  579. if (!(i - this.prevHitTime < 500 && isBugBrowser)) {
  580. this.prevHitTime = i, e.preventDefault(), e.stopPropagation(), t = (t - this.canvasX) * this.canvasScaleX, n = (n - this.canvasY) * this.canvasScaleY;
  581. for (var s = 0; s < this.aHitAreas.length; s++)
  582. if (this.aHitAreas[s].rect && t > this.aHitAreas[s].area[0] && n > this.aHitAreas[s].area[1] && t < this.aHitAreas[s].area[2] && n < this.aHitAreas[s].area[3]) {
  583. this.aHitAreas[s].aTouchIdentifiers.push(r), this.aHitAreas[s].oData.isDown || (this.aHitAreas[s].oData.isDown = !0, this.aHitAreas[s].oData.x = t, this.aHitAreas[s].oData.y = n, this.aHitAreas[s].callback(this.aHitAreas[s].id, this.aHitAreas[s].oData));
  584. break
  585. }
  586. }
  587. }
  588. }, e.prototype.hitUp = function(e, t, n, r) {
  589. if (!this.pauseIsOn) {
  590. e.preventDefault(), e.stopPropagation(), t = (t - this.canvasX) * this.canvasScaleX, n = (n - this.canvasY) * this.canvasScaleY;
  591. for (var i = 0; i < this.aHitAreas.length; i++)
  592. if (this.aHitAreas[i].rect && t > this.aHitAreas[i].area[0] && n > this.aHitAreas[i].area[1] && t < this.aHitAreas[i].area[2] && n < this.aHitAreas[i].area[3]) {
  593. for (var s = 0; s < this.aHitAreas[i].aTouchIdentifiers.length; s++) this.aHitAreas[i].aTouchIdentifiers[s] == r && (this.aHitAreas[i].aTouchIdentifiers.splice(s, 1), s -= 1);
  594. 0 == this.aHitAreas[i].aTouchIdentifiers.length && (this.aHitAreas[i].oData.isDown = !1, this.aHitAreas[i].oData.multiTouch && this.aHitAreas[i].callback(this.aHitAreas[i].id, this.aHitAreas[i].oData));
  595. break
  596. }
  597. }
  598. }, e.prototype.move = function(e, t, n, r, i) {
  599. if (!this.pauseIsOn && i) {
  600. t = (t - this.canvasX) * this.canvasScaleX, n = (n - this.canvasY) * this.canvasScaleY;
  601. for (var s = 0; s < this.aHitAreas.length; s++)
  602. if (this.aHitAreas[s].rect)
  603. if (t > this.aHitAreas[s].area[0] && n > this.aHitAreas[s].area[1] && t < this.aHitAreas[s].area[2] && n < this.aHitAreas[s].area[3]) this.aHitAreas[s].oData.isDown || (this.aHitAreas[s].oData.isDown = !0, this.aHitAreas[s].oData.x = t, this.aHitAreas[s].oData.y = n, this.aHitAreas[s].aTouchIdentifiers.push(r), this.aHitAreas[s].oData.multiTouch && this.aHitAreas[s].callback(this.aHitAreas[s].id, this.aHitAreas[s].oData)), this.aHitAreas[s].oData.isDraggable && (this.aHitAreas[s].oData.isBeingDragged = !0, this.aHitAreas[s].oData.x = t, this.aHitAreas[s].oData.y = n, this.aHitAreas[s].callback(this.aHitAreas[s].id, this.aHitAreas[s].oData), this.aHitAreas[s].oData.isBeingDragged = !1);
  604. else if (this.aHitAreas[s].oData.isDown) {
  605. for (var o = 0; o < this.aHitAreas[s].aTouchIdentifiers.length; o++) this.aHitAreas[s].aTouchIdentifiers[o] == r && (this.aHitAreas[s].aTouchIdentifiers.splice(o, 1), o -= 1);
  606. 0 == this.aHitAreas[s].aTouchIdentifiers.length && (this.aHitAreas[s].oData.isDown = !1, this.aHitAreas[s].oData.multiTouch && this.aHitAreas[s].callback(this.aHitAreas[s].id, this.aHitAreas[s].oData))
  607. }
  608. }
  609. }, e.prototype.keyDown = function(e) {
  610. for (var t = 0; t < this.aKeys.length; t++) e.keyCode == this.aKeys[t].keyCode && (this.aKeys[t].oData.isDown = !0, this.aKeys[t].callback(this.aKeys[t].id, this.aKeys[t].oData))
  611. }, e.prototype.keyUp = function(e) {
  612. for (var t = 0; t < this.aKeys.length; t++) e.keyCode == this.aKeys[t].keyCode && (this.aKeys[t].oData.isDown = !1, this.aKeys[t].callback(this.aKeys[t].id, this.aKeys[t].oData))
  613. }, e.prototype.addKey = function(e, t, n, r) {
  614. var i = this;
  615. this.isDetectingKeys || (window.addEventListener("keydown", function(e) {
  616. i.keyDown(e)
  617. }, !1), window.addEventListener("keyup", function(e) {
  618. i.keyUp(e)
  619. }, !1), this.isDetectingKeys = !0), null == n && (n = new Object), this.aKeys.push({
  620. id: e,
  621. callback: t,
  622. oData: n,
  623. keyCode: r
  624. })
  625. }, e.prototype.removeKey = function(e) {
  626. for (var t = 0; t < this.aKeys.length; t++) this.aKeys[t].id == e && (this.aKeys.splice(t, 1), t -= 1)
  627. }, e.prototype.addHitArea = function(e, t, n, r, i, s) {
  628. "undefined" == typeof s && (s = !1), null == n && (n = new Object), s && this.removeHitArea(e);
  629. var o = new Array;
  630. switch (r) {
  631. case "image":
  632. void 0 == i.scale && (i.scale = 1);
  633. var u;
  634. i.oImgData.isSpriteSheet ? (u = new Array(i.aPos[0] - i.oImgData.oData.spriteWidth / 2 * i.scale, i.aPos[1] - i.oImgData.oData.spriteHeight / 2 * i.scale, i.aPos[0] + i.oImgData.oData.spriteWidth / 2 * i.scale, i.aPos[1] + i.oImgData.oData.spriteHeight / 2 * i.scale), this.aHitAreas.push({
  635. id: e,
  636. aTouchIdentifiers: o,
  637. callback: t,
  638. oData: n,
  639. rect: !0,
  640. area: u
  641. })) : (u = new Array(i.aPos[0] - i.oImgData.img.width / 2 * i.scale, i.aPos[1] - i.oImgData.img.height / 2 * i.scale, i.aPos[0] + i.oImgData.img.width / 2 * i.scale, i.aPos[1] + i.oImgData.img.height / 2 * i.scale), this.aHitAreas.push({
  642. id: e,
  643. aTouchIdentifiers: o,
  644. callback: t,
  645. oData: n,
  646. rect: !0,
  647. area: u
  648. }));
  649. break;
  650. case "rect":
  651. this.aHitAreas.push({
  652. id: e,
  653. aTouchIdentifiers: o,
  654. callback: t,
  655. oData: n,
  656. rect: !0,
  657. area: i.aRect
  658. })
  659. }
  660. }, e.prototype.removeHitArea = function(e) {
  661. for (var t = 0; t < this.aHitAreas.length; t++) this.aHitAreas[t].id == e && (this.aHitAreas.splice(t, 1), t -= 1)
  662. }, e
  663. }();
  664. e.UserInput = t
  665. }(Utils || (Utils = {}));
  666. var Utils;
  667. ! function(e) {
  668. var t = function() {
  669. function e(e) {
  670. this.updateFreq = 10, this.updateInc = 0, this.frameAverage = 0, this.display = 1, this.log = "", this.render = function(e) {
  671. this.frameAverage += this.delta / this.updateFreq, ++this.updateInc >= this.updateFreq && (this.updateInc = 0, this.display = this.frameAverage, this.frameAverage = 0), e.textAlign = "left", ctx.font = "10px Helvetica", e.fillStyle = "#333333", e.beginPath(), e.rect(0, this.canvasHeight - 15, 40, 15), e.closePath(), e.fill(), e.fillStyle = "#ffffff", e.fillText(Math.round(1e3 / (1e3 * this.display)) + " fps " + this.log, 5, this.canvasHeight - 5)
  672. }, this.canvasHeight = e
  673. }
  674. return e.prototype.update = function(e) {
  675. this.delta = e
  676. }, e
  677. }();
  678. e.FpsMeter = t
  679. }(Utils || (Utils = {}));
  680. var Elements;
  681. ! function(e) {
  682. var t = function() {
  683. function e(e, t, n) {
  684. this.x = 0, this.y = 0, this.targY = 0, this.incY = 0, this.oImgData = e, this.canvasWidth = t, this.canvasHeight = n
  685. }
  686. return e.prototype.updateScroll = function(e) {
  687. this.incY += 5 * e, this.x = this.x - 50 * Math.sin(this.incY / 10) * e, this.y = this.y - 50 * e
  688. }, e.prototype.renderScroll = function(e) {
  689. 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), e.drawImage(this.oImgData.img, this.x, this.y, this.canvasWidth, this.canvasHeight, 0, 0, this.canvasWidth, this.canvasHeight)
  690. }, e.prototype.render = function(e) {
  691. e.drawImage(this.oImgData.img, 0, 0)
  692. }, e
  693. }();
  694. e.Background = t
  695. }(Elements || (Elements = {}));
  696. var Elements;
  697. ! function(e) {
  698. var t = function() {
  699. function e(e, t, n) {
  700. this.inc = 0, this.oSplashScreenImgData = e, this.canvasWidth = t, this.canvasHeight = n, this.posY = -this.canvasHeight, TweenLite.to(this, .5, {
  701. posY: 0
  702. })
  703. }
  704. return e.prototype.render = function(e, t) {
  705. this.inc += 5 * t, e.drawImage(this.oSplashScreenImgData.img, 0, 0 - this.posY)
  706. }, e
  707. }();
  708. e.Splash = t
  709. }(Elements || (Elements = {}));
  710. var Elements;
  711. ! function(e) {
  712. var t = function() {
  713. function e(e, t, n, r, i, s, o) {
  714. this.timer = .3, this.endTime = 0, this.posY = 0, this.bigCharSpace = 42, this.smallCharSpace = 20, this.incY = 0, this.oPanelsImgData = e, this.oBigNumbersImgData = t, this.oSmallNumbersImgData = n, this.panelType = r, this.aButs = i, this.canvasWidth = s, this.canvasHeight = o
  715. }
  716. return e.prototype.update = function(e) {
  717. this.incY += 5 * e
  718. }, e.prototype.startTween = function() {
  719. this.posY = 550, TweenLite.to(this, .8, {
  720. posY: 0,
  721. ease: "Back.easeOut"
  722. })
  723. }, e.prototype.render = function(e) {
  724. switch (this.panelType) {
  725. case "start":
  726. var t = 0,
  727. n = t * this.oPanelsImgData.oData.spriteWidth % this.oPanelsImgData.img.width,
  728. r = Math.floor(t / (this.oPanelsImgData.img.width / this.oPanelsImgData.oData.spriteWidth)) * this.oPanelsImgData.oData.spriteHeight;
  729. e.drawImage(this.oPanelsImgData.img, n, r, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight, 0, 0 + this.posY, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight);
  730. break;
  731. case "gameOver":
  732. var t = 2,
  733. n = t * this.oPanelsImgData.oData.spriteWidth % this.oPanelsImgData.img.width,
  734. r = Math.floor(t / (this.oPanelsImgData.img.width / this.oPanelsImgData.oData.spriteWidth)) * this.oPanelsImgData.oData.spriteHeight;
  735. e.drawImage(this.oPanelsImgData.img, n, r, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight, 0, 0 + this.posY, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight);
  736. for (var i = this.oScoreData.levelScore, s = 0; s < i.toString().length; s++) {
  737. t = parseFloat(i.toString().charAt(s));
  738. var n = t * this.oBigNumbersImgData.oData.spriteWidth % this.oBigNumbersImgData.img.width,
  739. r = Math.floor(t / (this.oBigNumbersImgData.img.width / this.oBigNumbersImgData.oData.spriteWidth)) * this.oBigNumbersImgData.oData.spriteHeight;
  740. e.drawImage(this.oBigNumbersImgData.img, n, r, this.oBigNumbersImgData.oData.spriteWidth, this.oBigNumbersImgData.oData.spriteHeight, this.canvasWidth / 2 + s * this.bigCharSpace - this.bigCharSpace * i.toString().length / 2, 300 + this.posY, this.oBigNumbersImgData.oData.spriteWidth, this.oBigNumbersImgData.oData.spriteHeight)
  741. }
  742. for (var i = this.oScoreData.highScore, s = 0; s < i.toString().length; s++) {
  743. t = parseFloat(i.toString().charAt(s));
  744. var n = t * this.oSmallNumbersImgData.oData.spriteWidth % this.oSmallNumbersImgData.img.width,
  745. r = Math.floor(t / (this.oSmallNumbersImgData.img.width / this.oSmallNumbersImgData.oData.spriteWidth)) * this.oSmallNumbersImgData.oData.spriteHeight;
  746. e.drawImage(this.oSmallNumbersImgData.img, n, r, this.oSmallNumbersImgData.oData.spriteWidth, this.oSmallNumbersImgData.oData.spriteHeight, 248 + s * this.smallCharSpace, 415 + this.posY, this.oSmallNumbersImgData.oData.spriteWidth, this.oSmallNumbersImgData.oData.spriteHeight)
  747. }
  748. break;
  749. case "tutorial0":
  750. var t = parseFloat(this.panelType.charAt(this.panelType.length - 1)) + 3,
  751. n = t * this.oPanelsImgData.oData.spriteWidth % this.oPanelsImgData.img.width,
  752. r = Math.floor(t / (this.oPanelsImgData.img.width / this.oPanelsImgData.oData.spriteWidth)) * this.oPanelsImgData.oData.spriteHeight;
  753. e.drawImage(this.oPanelsImgData.img, n, r, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight, 0, 0 + this.posY, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight);
  754. break;
  755. case "pause":
  756. var t = 1,
  757. n = t * this.oPanelsImgData.oData.spriteWidth % this.oPanelsImgData.img.width,
  758. r = Math.floor(t / (this.oPanelsImgData.img.width / this.oPanelsImgData.oData.spriteWidth)) * this.oPanelsImgData.oData.spriteHeight;
  759. e.drawImage(this.oPanelsImgData.img, n, r, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight, 0, 0, this.oPanelsImgData.oData.spriteWidth, this.oPanelsImgData.oData.spriteHeight)
  760. }
  761. for (var s = 0; s < this.aButs.length; s++) {
  762. var o = this.posY,
  763. u = 0;
  764. if (0 != this.incY && (u = 3 * Math.sin(this.incY + 45 * s)), 0 == s % 2 && (o = -this.posY), 0 == this.aButs[s].type) e.drawImage(this.aButs[s].oImgData.img, this.aButs[s].aPos[0] - this.aButs[s].oImgData.img.width / 2 + o, this.aButs[s].aPos[1] - this.aButs[s].oImgData.img.height / 2 - u);
  765. else {
  766. var t = this.aButs[s].frame,
  767. n = t * this.aButs[s].oImgData.oData.spriteWidth % this.aButs[s].oImgData.img.width,
  768. r = Math.floor(t / (this.aButs[s].oImgData.img.width / this.aButs[s].oImgData.oData.spriteWidth)) * this.aButs[s].oImgData.oData.spriteHeight;
  769. e.drawImage(this.aButs[s].oImgData.img, n, r, this.aButs[s].oImgData.oData.spriteWidth, this.aButs[s].oImgData.oData.spriteHeight, this.aButs[s].aPos[0] - this.aButs[s].oImgData.oData.spriteWidth / 2 + o, this.aButs[s].aPos[1] - this.aButs[s].oImgData.oData.spriteHeight / 2 - u, this.aButs[s].oImgData.oData.spriteWidth, this.aButs[s].oImgData.oData.spriteHeight)
  770. }
  771. }
  772. }, e
  773. }();
  774. e.Panel = t
  775. }(Elements || (Elements = {}));
  776. var Elements;
  777. ! function(e) {
  778. var t = function() {
  779. function e(e, t, n, r, i) {
  780. this.time = 0, this.washedNum = 0, this.bigCharSpace = 42, this.smallCharSpace = 20, this.oHudImgData = e, this.oBigNumbersImgData = t, this.oSmallNumbersImgData = n, this.canvasWidth = r, this.canvasHeight = i, this.time = 60
  781. }
  782. return e.prototype.render = function(e) {
  783. e.drawImage(this.oHudImgData.img, 0, 0);
  784. for (var t = 0; t < this.time.toString().length; t++) {
  785. var n = parseFloat(this.time.toString().charAt(t)),
  786. r = n * this.oBigNumbersImgData.oData.spriteWidth % this.oBigNumbersImgData.img.width,
  787. i = Math.floor(n / (this.oBigNumbersImgData.img.width / this.oBigNumbersImgData.oData.spriteWidth)) * this.oBigNumbersImgData.oData.spriteHeight;
  788. e.drawImage(this.oBigNumbersImgData.img, r, i, this.oBigNumbersImgData.oData.spriteWidth, this.oBigNumbersImgData.oData.spriteHeight, this.canvasWidth / 2 + t * this.bigCharSpace - this.bigCharSpace * this.time.toString().length / 2, 26, this.oBigNumbersImgData.oData.spriteWidth, this.oBigNumbersImgData.oData.spriteHeight)
  789. }
  790. for (var t = 0; t < this.washedNum.toString().length; t++) {
  791. var n = parseFloat(this.washedNum.toString().charAt(t)),
  792. r = n * this.oSmallNumbersImgData.oData.spriteWidth % this.oSmallNumbersImgData.img.width,
  793. i = Math.floor(n / (this.oSmallNumbersImgData.img.width / this.oSmallNumbersImgData.oData.spriteWidth)) * this.oSmallNumbersImgData.oData.spriteHeight;
  794. e.drawImage(this.oSmallNumbersImgData.img, r, i, this.oSmallNumbersImgData.oData.spriteWidth, this.oSmallNumbersImgData.oData.spriteHeight, 48 + t * this.smallCharSpace - this.smallCharSpace * this.washedNum.toString().length / 2, 539, this.oSmallNumbersImgData.oData.spriteWidth, this.oSmallNumbersImgData.oData.spriteHeight)
  795. }
  796. }, e
  797. }();
  798. e.Hud = t
  799. }(Elements || (Elements = {}));
  800. var Elements;
  801. ! function(e) {
  802. var t = function() {
  803. function e(e, t, n) {
  804. this.incX = 0, this.aSegs = new Array(0, 52, 87, 122, 157, 192), this.oImgData = e, this.canvasWidth = t, this.canvasHeight = n
  805. }
  806. return e.prototype.update = function(e) {
  807. this.incX += 4 * e
  808. }, e.prototype.render = function(e) {
  809. for (var t = 0; t < this.aSegs.length - 1; t++) e.drawImage(this.oImgData.img, 0, this.aSegs[t], this.oImgData.img.width, this.aSegs[t + 1] - this.aSegs[t], 15 * Math.sin(this.incX + 2 * t) - 75, this.aSegs[t] + 408, this.oImgData.img.width, this.aSegs[t + 1] - this.aSegs[t])
  810. }, e
  811. }();
  812. e.Water = t
  813. }(Elements || (Elements = {}));
  814. var Elements;
  815. ! function(e) {
  816. var t = function() {
  817. function e(e, t, n, r, i, s, o) {
  818. this.aDirtPos = new Array, this.dirtNum = Math.round(5 * Math.random()) + 10, this.eyesOpen = !0, this.aDirtData = new Array([
  819. [-125, -60],
  820. [-125, -40],
  821. [-125, -20],
  822. [-125, 0],
  823. [-125, 20],
  824. [-125, 40],
  825. [-125, 60],
  826. [-105, -80],
  827. [-105, -60],
  828. [-105, -40],
  829. [-105, -20],
  830. [-105, 0],
  831. [-105, 20],
  832. [-105, 40],
  833. [-105, 60],
  834. [-105, 80],
  835. [-85, -100],
  836. [-85, -80],
  837. [-85, -60],
  838. [-85, -40],
  839. [-85, -20],
  840. [-85, 0],
  841. [-85, 20],
  842. [-85, 40],
  843. [-85, 60],
  844. [-85, 80],
  845. [-85, 100],
  846. [-65, -120],
  847. [-65, -100],
  848. [-65, -80],
  849. [-65, -60],
  850. [-65, -40],
  851. [-65, -20],
  852. [-65, 0],
  853. [-65, 20],
  854. [-65, 40],
  855. [-65, 60],
  856. [-65, 80],
  857. [-65, 100],
  858. [-65, 120],
  859. [-45, -120],
  860. [-45, -100],
  861. [-45, -80],
  862. [-45, -60],
  863. [-45, -40],
  864. [-45, -20],
  865. [-45, 0],
  866. [-45, 20],
  867. [-45, 40],
  868. [-45, 60],
  869. [-45, 80],
  870. [-45, 100],
  871. [-45, 120],
  872. [-25, -120],
  873. [-25, -100],
  874. [-25, -80],
  875. [-25, -60],
  876. [-25, -40],
  877. [-25, -20],
  878. [-25, 0],
  879. [-25, 20],
  880. [-25, 40],
  881. [-25, 60],
  882. [-25, 80],
  883. [-25, 100],
  884. [-25, 120],
  885. [-5, -140],
  886. [-5, -120],
  887. [-5, -100],
  888. [-5, -80],
  889. [-5, -60],
  890. [-5, -40],
  891. [-5, -20],
  892. [-5, 0],
  893. [-5, 20],
  894. [-5, 40],
  895. [-5, 60],
  896. [-5, 80],
  897. [-5, 100],
  898. [-5, 120],
  899. [-5, 140],
  900. [15, -140],
  901. [15, -120],
  902. [15, -100],
  903. [15, -80],
  904. [15, -60],
  905. [15, -40],
  906. [15, -20],
  907. [15, 0],
  908. [15, 20],
  909. [15, 40],
  910. [15, 60],
  911. [15, 80],
  912. [15, 100],
  913. [15, 120],
  914. [15, 140],
  915. [35, -120],
  916. [35, -100],
  917. [35, -80],
  918. [35, -60],
  919. [35, -40],
  920. [35, -20],
  921. [35, 0],
  922. [35, 20],
  923. [35, 40],
  924. [35, 60],
  925. [35, 80],
  926. [35, 100],
  927. [35, 120],
  928. [55, -120],
  929. [55, -100],
  930. [55, -80],
  931. [55, -60],
  932. [55, -40],
  933. [55, -20],
  934. [55, 0],
  935. [55, 20],
  936. [55, 40],
  937. [55, 60],
  938. [55, 80],
  939. [55, 100],
  940. [55, 120],
  941. [75, -120],
  942. [75, -100],
  943. [75, -80],
  944. [75, -60],
  945. [75, -40],
  946. [75, -20],
  947. [75, 0],
  948. [75, 20],
  949. [75, 40],
  950. [75, 60],
  951. [75, 80],
  952. [75, 100],
  953. [95, -100],
  954. [95, -80],
  955. [95, -60],
  956. [95, -40],
  957. [95, -20],
  958. [95, 0],
  959. [95, 20],
  960. [95, 40],
  961. [95, 60],
  962. [95, 80],
  963. [95, 100],
  964. [115, -80],
  965. [115, -60],
  966. [115, -40],
  967. [115, -20],
  968. [115, 0],
  969. [115, 20],
  970. [115, 40],
  971. [115, 60],
  972. [115, 80],
  973. [135, -40],
  974. [135, -20],
  975. [135, 0],
  976. [135, 20],
  977. [135, 40]
  978. ], [
  979. [-65, -80],
  980. [-65, -60],
  981. [-65, -40],
  982. [-65, -20],
  983. [-45, -80],
  984. [-45, -60],
  985. [-45, -40],
  986. [-45, -20],
  987. [-45, 0],
  988. [-45, 20],
  989. [-45, 100],
  990. [-25, -80],
  991. [-25, -60],
  992. [-25, -40],
  993. [-25, -20],
  994. [-25, 0],
  995. [-25, 20],
  996. [-25, 40],
  997. [-25, 60],
  998. [-25, 80],
  999. [-25, 100],
  1000. [-5, -80],
  1001. [-5, -60],
  1002. [-5, -40],
  1003. [-5, -20],
  1004. [-5, 0],
  1005. [-5, 20],
  1006. [-5, 40],
  1007. [-5, 60],
  1008. [-5, 80],
  1009. [-5, 100],
  1010. [15, -80],
  1011. [15, -60],
  1012. [15, -40],
  1013. [15, -20],
  1014. [15, 0],
  1015. [15, 20],
  1016. [15, 40],
  1017. [15, 60],
  1018. [15, 80],
  1019. [15, 100],
  1020. [35, -80],
  1021. [35, -60],
  1022. [35, -40],
  1023. [35, -20],
  1024. [35, 0],
  1025. [35, 20],
  1026. [35, 40],
  1027. [35, 100],
  1028. [55, -80],
  1029. [55, -60],
  1030. [55, -40],
  1031. [55, -20],
  1032. [55, 0],
  1033. [55, 20],
  1034. [55, 100],
  1035. [75, -80],
  1036. [75, -60]
  1037. ], [
  1038. [-125, -60],
  1039. [-125, -40],
  1040. [-105, -60],
  1041. [-105, -40],
  1042. [-105, -20],
  1043. [-105, 0],
  1044. [-105, 20],
  1045. [-85, -60],
  1046. [-85, -40],
  1047. [-85, -20],
  1048. [-85, 0],
  1049. [-85, 20],
  1050. [-85, 40],
  1051. [-65, -60],
  1052. [-65, -40],
  1053. [-65, -20],
  1054. [-65, 0],
  1055. [-65, 20],
  1056. [-65, 40],
  1057. [-65, 60],
  1058. [-65, 80],
  1059. [-45, -60],
  1060. [-45, -40],
  1061. [-45, -20],
  1062. [-45, 0],
  1063. [-45, 20],
  1064. [-45, 40],
  1065. [-45, 60],
  1066. [-45, 80],
  1067. [-25, -60],
  1068. [-25, -40],
  1069. [-25, -20],
  1070. [-25, 0],
  1071. [-25, 20],
  1072. [-25, 40],
  1073. [-25, 60],
  1074. [-25, 80],
  1075. [-5, -60],
  1076. [-5, -40],
  1077. [-5, -20],
  1078. [-5, 0],
  1079. [-5, 20],
  1080. [-5, 40],
  1081. [-5, 60],
  1082. [-5, 80],
  1083. [15, -60],
  1084. [15, -40],
  1085. [15, -20],
  1086. [15, 0],
  1087. [15, 20],
  1088. [15, 40],
  1089. [15, 60],
  1090. [35, -60],
  1091. [35, -40],
  1092. [35, -20],
  1093. [35, 0],
  1094. [35, 20],
  1095. [35, 40],
  1096. [55, -60],
  1097. [55, -40],
  1098. [55, -20],
  1099. [55, 0],
  1100. [75, -60]
  1101. ], [
  1102. [-125, -20],
  1103. [-125, 0],
  1104. [-105, -20],
  1105. [-105, 0],
  1106. [-85, -20],
  1107. [-85, 0],
  1108. [-85, 20],
  1109. [-65, -20],
  1110. [-65, 0],
  1111. [-65, 20],
  1112. [-45, -20],
  1113. [-45, 0],
  1114. [-45, 20],
  1115. [-45, 40],
  1116. [-25, -20],
  1117. [-25, 0],
  1118. [-25, 20],
  1119. [-25, 40],
  1120. [-5, -20],
  1121. [-5, 0],
  1122. [-5, 20],
  1123. [-5, 40],
  1124. [15, -20],
  1125. [15, 0],
  1126. [15, 20],
  1127. [15, 40],
  1128. [35, -20],
  1129. [35, 0],
  1130. [35, 20],
  1131. [35, 40],
  1132. [55, -20],
  1133. [55, 0],
  1134. [55, 20],
  1135. [55, 40],
  1136. [75, -20],
  1137. [75, 0],
  1138. [75, 20],
  1139. [95, -20],
  1140. [95, 0],
  1141. [115, -20],
  1142. [115, 0],
  1143. [135, -20]
  1144. ], [
  1145. [-105, -100],
  1146. [-105, 20],
  1147. [-105, 40],
  1148. [-105, 60],
  1149. [-105, 80],
  1150. [-105, 100],
  1151. [-85, -100],
  1152. [-85, -80],
  1153. [-85, -60],
  1154. [-85, -40],
  1155. [-85, -20],
  1156. [-85, 0],
  1157. [-85, 20],
  1158. [-85, 40],
  1159. [-85, 60],
  1160. [-85, 80],
  1161. [-85, 100],
  1162. [-85, 120],
  1163. [-65, -100],
  1164. [-65, -80],
  1165. [-65, -60],
  1166. [-65, -40],
  1167. [-65, -20],
  1168. [-65, 0],
  1169. [-65, 20],
  1170. [-65, 40],
  1171. [-65, 60],
  1172. [-65, 80],
  1173. [-65, 100],
  1174. [-65, 120],
  1175. [-45, -100],
  1176. [-45, -80],
  1177. [-45, -60],
  1178. [-45, -40],
  1179. [-45, -20],
  1180. [-45, 0],
  1181. [-45, 20],
  1182. [-45, 40],
  1183. [-45, 60],
  1184. [-45, 80],
  1185. [-45, 100],
  1186. [-45, 120],
  1187. [-25, -100],
  1188. [-25, -80],
  1189. [-25, -60],
  1190. [-25, -40],
  1191. [-25, -20],
  1192. [-25, 0],
  1193. [-25, 20],
  1194. [-25, 40],
  1195. [-25, 60],
  1196. [-25, 80],
  1197. [-25, 100],
  1198. [-25, 120],
  1199. [-5, -100],
  1200. [-5, -80],
  1201. [-5, -60],
  1202. [-5, -40],
  1203. [-5, -20],
  1204. [-5, 0],
  1205. [-5, 20],
  1206. [-5, 40],
  1207. [-5, 60],
  1208. [-5, 80],
  1209. [-5, 100],
  1210. [-5, 120],
  1211. [15, -100],
  1212. [15, -80],
  1213. [15, -60],
  1214. [15, -40],
  1215. [15, -20],
  1216. [15, 0],
  1217. [15, 20],
  1218. [15, 40],
  1219. [15, 60],
  1220. [15, 80],
  1221. [15, 100],
  1222. [15, 120],
  1223. [35, -40],
  1224. [35, -20],
  1225. [35, 0],
  1226. [35, 20],
  1227. [35, 40],
  1228. [35, 60],
  1229. [35, 80],
  1230. [35, 100]
  1231. ]), this.oCrockeryImgData = e, this.oExpressionsImgData = t, this.oDirtImgData = n, this.crockeryId = i, this.crockeryCallback = r, this.canvasWidth = s, this.canvasHeight = o, this.x = this.canvasWidth / 2, this.y = 325;
  1232. for (var u = 0; u < this.dirtNum; u++) {
  1233. var a = Math.floor(Math.random() * (this.aDirtData[this.crockeryId].length - 1));
  1234. this.aDirtPos.push(this.aDirtData[this.crockeryId][a]), this.aDirtData[this.crockeryId].splice(a, 1), this.aDirtPos[this.aDirtPos.length - 1].push((90 * Math.random() - 45) * (Math.PI / 180)), this.aDirtPos[this.aDirtPos.length - 1].push(Math.floor(1 * Math.random()))
  1235. }
  1236. this.renderFunc = this.renderDirty
  1237. }
  1238. return e.prototype.startTween = function() {
  1239. this.posY = 600, TweenLite.to(this, .8, {
  1240. posY: 0,
  1241. ease: "Back.easeOut"
  1242. })
  1243. }, e.prototype.removed = function(e) {
  1244. e.crockeryCallback("removed")
  1245. }, e.prototype.wash = function(e, t) {
  1246. for (var n = 0, r = 0; r < this.aDirtPos.length; r++) {
  1247. var i = t[0] - this.aDirtPos[r][0] - this.x,
  1248. s = t[1] - this.aDirtPos[r][1] - this.y,
  1249. o = i * i + s * s;
  1250. 5e3 > o && 10 != this.aDirtPos[r][3] && (this.aDirtPos[r][3] += e, this.aDirtPos[r][3] >= 4 && (this.aDirtPos[r][3] = 10, this.crockeryCallback("dirtClean"))), 10 == this.aDirtPos[r][3] && n++
  1251. }
  1252. n == this.aDirtPos.length && (this.crockeryCallback("allClean"), this.renderFunc = this.renderClean, this.posX = 0, this.posY = -25, TweenLite.to(this, .5, {
  1253. posX: 700,
  1254. delay: .5,
  1255. ease: "Back.easeIn",
  1256. onComplete: this.removed,
  1257. onCompleteParams: [this]
  1258. }), TweenLite.to(this, 1, {
  1259. posY: 0,
  1260. ease: "Elastic.easeOut"
  1261. }))
  1262. }, e.prototype.render = function(e) {
  1263. this.renderFunc(e)
  1264. }, e.prototype.renderClean = function(e) {
  1265. var t = this.crockeryId * this.oCrockeryImgData.oData.spriteWidth % this.oCrockeryImgData.img.width,
  1266. n = Math.floor(this.crockeryId / (this.oCrockeryImgData.img.width / this.oCrockeryImgData.oData.spriteWidth)) * this.oCrockeryImgData.oData.spriteHeight;
  1267. e.drawImage(this.oCrockeryImgData.img, t, n, this.oCrockeryImgData.oData.spriteWidth, this.oCrockeryImgData.oData.spriteHeight, this.x - this.oCrockeryImgData.oData.spriteWidth / 2 + this.posX, 325 - this.oCrockeryImgData.oData.spriteHeight / 2 + this.posY, this.oCrockeryImgData.oData.spriteWidth, this.oCrockeryImgData.oData.spriteHeight);
  1268. var r = 3 * this.crockeryId + 2,
  1269. t = r * this.oExpressionsImgData.oData.spriteWidth % this.oExpressionsImgData.img.width,
  1270. n = Math.floor(r / (this.oExpressionsImgData.img.width / this.oExpressionsImgData.oData.spriteWidth)) * this.oExpressionsImgData.oData.spriteHeight;
  1271. e.drawImage(this.oExpressionsImgData.img, t, n, this.oExpressionsImgData.oData.spriteWidth, this.oExpressionsImgData.oData.spriteHeight, this.x - this.oExpressionsImgData.oData.spriteWidth / 2 + this.posX, this.y - this.oExpressionsImgData.oData.spriteHeight / 2 + this.posY, this.oExpressionsImgData.oData.spriteWidth, this.oExpressionsImgData.oData.spriteHeight)
  1272. }, e.prototype.renderDirty = function(e) {
  1273. var t = this.crockeryId * this.oCrockeryImgData.oData.spriteWidth % this.oCrockeryImgData.img.width,
  1274. n = Math.floor(this.crockeryId / (this.oCrockeryImgData.img.width / this.oCrockeryImgData.oData.spriteWidth)) * this.oCrockeryImgData.oData.spriteHeight;
  1275. e.drawImage(this.oCrockeryImgData.img, t, n, this.oCrockeryImgData.oData.spriteWidth, this.oCrockeryImgData.oData.spriteHeight, this.x - this.oCrockeryImgData.oData.spriteWidth / 2, 325 - this.oCrockeryImgData.oData.spriteHeight / 2 + this.posY, this.oCrockeryImgData.oData.spriteWidth, this.oCrockeryImgData.oData.spriteHeight);
  1276. for (var r = 0; r < this.aDirtPos.length; r++)
  1277. if (Math.floor(this.aDirtPos[r][3]) < 4) {
  1278. e.save(), e.translate(this.aDirtPos[r][0] + this.x, this.aDirtPos[r][1] + this.y + this.posY), e.rotate(this.aDirtPos[r][2]);
  1279. var i = 4 * (r % 7) + Math.floor(this.aDirtPos[r][3]),
  1280. t = i * this.oDirtImgData.oData.spriteWidth % this.oDirtImgData.img.width,
  1281. n = Math.floor(i / (this.oDirtImgData.img.width / this.oDirtImgData.oData.spriteWidth)) * this.oDirtImgData.oData.spriteHeight;
  1282. e.drawImage(this.oDirtImgData.img, t, n, this.oDirtImgData.oData.spriteWidth, this.oDirtImgData.oData.spriteHeight, -this.oDirtImgData.oData.spriteWidth / 2, -this.oDirtImgData.oData.spriteHeight / 2, this.oDirtImgData.oData.spriteWidth, this.oDirtImgData.oData.spriteHeight), e.restore()
  1283. }
  1284. var i = 3 * this.crockeryId;
  1285. this.eyesOpen || i++;
  1286. var t = i * this.oExpressionsImgData.oData.spriteWidth % this.oExpressionsImgData.img.width,
  1287. n = Math.floor(i / (this.oExpressionsImgData.img.width / this.oExpressionsImgData.oData.spriteWidth)) * this.oExpressionsImgData.oData.spriteHeight;
  1288. e.drawImage(this.oExpressionsImgData.img, t, n, this.oExpressionsImgData.oData.spriteWidth, this.oExpressionsImgData.oData.spriteHeight, this.x - this.oExpressionsImgData.oData.spriteWidth / 2, this.y - this.oExpressionsImgData.oData.spriteHeight / 2 + this.posY, this.oExpressionsImgData.oData.spriteWidth, this.oExpressionsImgData.oData.spriteHeight)
  1289. }, e
  1290. }();
  1291. e.Crockery = t
  1292. }(Elements || (Elements = {}));
  1293. var __extends = this.__extends || function(e, t) {
  1294. function n() {
  1295. this.constructor = e
  1296. }
  1297. n.prototype = t.prototype, e.prototype = new n
  1298. },
  1299. Elements;
  1300. ! function(e) {
  1301. var t = function(e) {
  1302. function t(t, n, r, i, s) {
  1303. e.call(this, t, 0, n), this.vx = 0, this.vy = 0, this.x = r[0], this.y = r[1], this.vx = 100 * Math.random() - 50, this.vy = -100 * Math.random(), this.canvasWidth = i, this.canvasHeight = s, this.startTween()
  1304. }
  1305. return __extends(t, e), t.prototype.startTween = function() {
  1306. this.scaleX = this.scaleY = 0, TweenLite.to(this, .5, {
  1307. scaleX: 1,
  1308. scaleY: 1,
  1309. ease: "Back.easeOut"
  1310. })
  1311. }, t.prototype.update = function(e) {
  1312. this.vy += 200 * e, this.y += this.vy * e, this.vx *= .9, this.x += this.vx * e, this.y > this.canvasHeight + 100 && (this.removeMe = !0)
  1313. }, t
  1314. }(Utils.BasicSprite);
  1315. e.Bubble = t
  1316. }(Elements || (Elements = {}));
  1317. var requestAnimFrame = function() {
  1318. return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(e) {
  1319. window.setTimeout(e, 1e3 / 60, (new Date).getTime())
  1320. }
  1321. }(),
  1322. previousTime, canvas = document.getElementById("canvas"),
  1323. ctx = canvas.getContext("2d");
  1324. canvas.width = 450, canvas.height = 600;
  1325. var canvasX, canvasY, canvasScaleX, canvasScaleY, div = document.getElementById("viewporter"),
  1326. sound, music, audioType = 0,
  1327. muted = !1,
  1328. splash, splashTimer = 0,
  1329. assetLib, preAssetLib, rotatePause = !1,
  1330. manualPause = !1,
  1331. isMobile = !1,
  1332. gameState = "loading",
  1333. aLangs = new Array("EN"),
  1334. curLang = "",
  1335. isBugBrowser = !1,
  1336. isIE10 = !1;
  1337. navigator.userAgent.match(/MSIE\s([\d]+)/) && (isIE10 = !0);
  1338. var deviceAgent = navigator.userAgent.toLowerCase();
  1339. (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));
  1340. var userInput = new Utils.UserInput(canvas, isBugBrowser);
  1341. resizeCanvas(), window.onresize = function() {
  1342. setTimeout(function() {
  1343. resizeCanvas()
  1344. }, 1)
  1345. }, document.addEventListener("visibilitychange", function() {
  1346. document.hidden ? Howler.mute() : muted || Howler.unmute()
  1347. }, !1), window.addEventListener("load", function() {
  1348. setTimeout(function() {
  1349. resizeCanvas()
  1350. }, 0), window.addEventListener("orientationchange", function() {
  1351. resizeCanvas()
  1352. }, !1);
  1353. var e = {
  1354. id: "576742227280292100"
  1355. };
  1356. GameAPI.loadAPI(function(e) {
  1357. console.log("GameAPI version " + e.version + " loaded!"), spilAPI = e, oSpilLogoData = spilAPI.Branding.getLogo(), oSpilMoreGamesData = spilAPI.Branding.getLink("more_games"), loadPreAssets()
  1358. }, e)
  1359. }), isIE10 || "undefined" == typeof window.AudioContext && "undefined" == typeof window.webkitAudioContext && -1 != navigator.userAgent.indexOf("Android") ? (audioType = 0, music = new Audio("audio/music.ogg"), music.addEventListener("ended", function() {
  1360. this.currentTime = 0, this.play()
  1361. }, !1), music.play()) : (audioType = 1, sound = new Howl({
  1362. urls: ["audio/sound.ogg", "audio/sound.m4a"],
  1363. sprite: {
  1364. click: [0, 300],
  1365. startSplash: [500, 800],
  1366. wash0: [1500, 600],
  1367. wash1: [2500, 800],
  1368. wash2: [3500, 600],
  1369. wash3: [4500, 700],
  1370. gameEnd: [5500, 2500],
  1371. dishClean: [8500, 1e3]
  1372. }
  1373. }), music = new Howl({
  1374. urls: ["audio/music.ogg", "audio/music.m4a"],
  1375. volume: .25,
  1376. loop: !0
  1377. }));
  1378. var panel, hud, background, levelScore = 0,
  1379. highScore = 0,
  1380. levelNum = 0,
  1381. aLevelUps, levelBonusScore, bonusScore, aTutorials = new Array({
  1382. levelNum: 0,
  1383. shown: !1,
  1384. panelType: "tutorial0"
  1385. }),
  1386. panelFrame, gameTimer, water, crockery, crockeryId = Math.floor(5 * Math.random()),
  1387. aPrevWashPos, aCurWashPos, isWashing = !1,
  1388. bubbleLimiter, aBubbles, allowWashing, flipFlop = !0,
  1389. spilAPI, oSpilLogoData = {},
  1390. oSpilMoreGamesData = {},
  1391. oSpilLogoBut