game.min.js 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  1. function main() {
  2. jsGame.initImage([{
  3. id: "a",
  4. src: "img/a.png"
  5. }, {
  6. id: "ballon",
  7. src: "img/ballon.png"
  8. }, {
  9. id: "bomb",
  10. src: "img/bomb.png"
  11. }, {
  12. id: "bombfire",
  13. src: "img/bombfire.png"
  14. }, {
  15. id: "num1",
  16. src: "img/num1.png"
  17. }, {
  18. id: "num2",
  19. src: "img/num2.png"
  20. }, {
  21. id: "num3",
  22. src: "img/num3.png"
  23. }, {
  24. id: "explode",
  25. src: "img/explode.png"
  26. }, {
  27. id: "cloud",
  28. src: "img/cloud.png"
  29. }, {
  30. id: "coin",
  31. src: "img/coin.png"
  32. }, {
  33. id: "house",
  34. src: "img/house.png"
  35. }, {
  36. id: "cover",
  37. src: "img/cover.png"
  38. }, {
  39. id: "land",
  40. src: "img/land.png"
  41. }, {
  42. id: "bg",
  43. src: "img/bg.png"
  44. }, {
  45. id: "title",
  46. src: "img/title.png"
  47. }, {
  48. id: "statebar",
  49. src: "img/statebar.png"
  50. }, {
  51. id: "clue",
  52. src: "img/clue.png"
  53. }, {
  54. id: "clue1",
  55. src: "img/clue1.png"
  56. }, {
  57. id: "clue_coin",
  58. src: "img/clue-coin.png"
  59. }, {
  60. id: "clue_finger",
  61. src: "img/clue-finger.png"
  62. }, {
  63. id: "sound1",
  64. src: "img/sound1.png"
  65. }, {
  66. id: "sound2",
  67. src: "img/sound2.png"
  68. }, {
  69. id: "achieve",
  70. src: "img/achieve.png"
  71. }, {
  72. id: "achieve_dialog",
  73. src: "img/achieve-dialog.png"
  74. }, {
  75. id: "lock",
  76. src: "img/lock.png"
  77. }, {
  78. id: "back",
  79. src: "img/back.png"
  80. }, {
  81. id: "begin",
  82. src: "img/begin.png"
  83. }, {
  84. id: "exit1",
  85. src: "img/exit1.png"
  86. }, {
  87. id: "exit2",
  88. src: "img/exit2.png"
  89. }, {
  90. id: "rank",
  91. src: "img/rank.png"
  92. }, {
  93. id: "logo1",
  94. src: "img/logo1.png"
  95. }, {
  96. id: "logo2",
  97. src: "img/logo2.png"
  98. }, {
  99. id: "more",
  100. src: "img/more.png"
  101. }, {
  102. id: "help",
  103. src: "img/help.png"
  104. }, {
  105. id: "next2",
  106. src: "img/next2.png"
  107. }, {
  108. id: "pause",
  109. src: "img/pause.png"
  110. }, {
  111. id: "pause_bg",
  112. src: "img/pause-bg.png"
  113. }, {
  114. id: "resume",
  115. src: "img/resume.png"
  116. }, {
  117. id: "achieve0",
  118. src: "img/achieve0.png"
  119. }, {
  120. id: "achieve1",
  121. src: "img/achieve1.png"
  122. }, {
  123. id: "achieve2",
  124. src: "img/achieve2.png"
  125. }, {
  126. id: "achieve3",
  127. src: "img/achieve3.png"
  128. }, {
  129. id: "achieve4",
  130. src: "img/achieve4.png"
  131. }, {
  132. id: "achieve5",
  133. src: "img/achieve5.png"
  134. }, {
  135. id: "achieve6",
  136. src: "img/achieve6.png"
  137. }]);
  138. var a = {
  139. initTouch: function () {
  140. jsGame.touch.init(!0)
  141. },
  142. initCanvas: function () {
  143. a.width = window.innerWidth;
  144. if(a.width > 640) a.width = 640;
  145. a.height = window.innerHeight;
  146. //a.height > a.width ? a.height >= 1.5 * a.width ? a.scale = a.width / 320 : (a.width = 2 * a.height / 3 << 0, a.scale = a.height / 480) : a.clue = !0;
  147. jsGame.canvas.screen.setWidth(a.width);
  148. jsGame.canvas.screen.setHeight(a.height);
  149. a.scale = a.width / 320;
  150. a.canvas = document.getElementById("jsGameScreen");
  151. a.ctx = a.canvas.getContext("2d");
  152. a.ctx.strokeStyle =
  153. "white";
  154. a.ctx.lineWidth = 3 * a.scale + 0.5 << 0;
  155. a.initTouch()
  156. }
  157. };
  158. a.initCanvas();
  159. a.drawNum = function (d, m, b, f, c, e, g, l) {
  160. var k = c * l << 0;
  161. e = e * l << 0;
  162. if (0 >= d) a.ctx.drawImage(f, 0, 0, k, e, m, b, k, e);
  163. else {
  164. var h = d / 10 << 0,
  165. n = 0;
  166. d %= 10;
  167. for (var p = []; h || d;) p[n++] = d, d = h % 10, h = h / 10 << 0;
  168. d = p.reverse();
  169. h = d.length;
  170. for (n = 0; n < h; n++) a.ctx.drawImage(f, c * d[n] * l << 0, 0, k, e, m + (c - g) * n * l << 0, b, k, e)
  171. }
  172. };
  173. jsGame.initImageCallBack(function (d, m) {
  174. if (d >= m) jsGame.gameFlow.run();
  175. else try {
  176. var b = d / m,
  177. b = 1 < b ? 1 : b;
  178. a.ctx.fillStyle = "#8dab81";
  179. a.ctx.fillRect(0, 0, a.width, a.height);
  180. a.ctx.drawImage(jsGame.getImage("a"), 0, 0, 250, 81, (a.width - 250) / 2, (a.height - 81) / 2, 250, 81);
  181. a.ctx.drawImage(jsGame.getImage("a"), 2, 86, 246 * b, 10, (a.width - 246) / 2, (a.height - 81) / 2 + 51, 246 * b, 10)
  182. } catch (f) {}
  183. });
  184. jsGame.pageLoad(function (d) {
  185. a.addItem = function (b, f, c, e, g, l, k, h, n) {
  186. for (var p = c.length, m = p; m < p + f; m++) c[m] = {
  187. id: a.id++,
  188. name: b,
  189. img: e,
  190. altitude: a.house.altitude,
  191. x: a.id % (0.7 * a.width / g << 0) * g * 1.4 + g / 2,
  192. y: -200 * a.scale,
  193. w: g,
  194. h: l,
  195. v: k
  196. }, (h || n) && d.touch.create(c[m], h, n)
  197. };
  198. a.delItem = function (a, f) {
  199. d.touch.deleteImg(f);
  200. for (var c =
  201. a.length, e = 0; e < c; e++)
  202. if (a[e].id == f) {
  203. a.splice(e, 1);
  204. break
  205. }
  206. };
  207. a.addBallon = function (b) {
  208. var f = a.ballons.length,
  209. c = 58 * a.scale << 0;
  210. a.addItem("ballon", b, a.ballons, a.buffers.ballon, 55 * a.scale << 0, c, a.height / 120, !0, !0);
  211. for (var e = f; e < f + b; e++) a.ballons[e].tied = !1, a.ballons[e].y = a.height + c / 2, a.ballons[e].timer = 0, a.ballons[e].color = (100 * Math.random() << 0) % 5
  212. };
  213. a.delBallon = function (b) {
  214. a.delItem(a.ballons, b)
  215. };
  216. a.addBomb = function (b) {
  217. var f = a.bombs.length;
  218. a.addItem("bomb", b, a.bombs, a.buffers.bomb, 60 * a.scale << 0, 75 * a.scale <<
  219. 0, -(a.height / 150), !0, !0);
  220. for (var c = f; c < f + b; c++) a.bombs[c].timer = 5 * Math.random() + 5 << 0, a.bombs[c].altitude += a.height, a.bombs[c].coin = 0, a.bombs[c].flash = 0
  221. };
  222. a.delBomb = function (b) {
  223. a.delItem(a.bombs, b)
  224. };
  225. a.addCloud = function (b) {
  226. var f = a.clouds.length;
  227. a.addItem("cloud", b, a.clouds, a.buffers.cloud1, 135 * a.scale << 0, 84 * a.scale << 0, 0, !1, !1);
  228. for (var c = f; c < f + b; c++) switch (a.clouds[c].x = a.width * Math.random(), a.clouds[c].altitude += 2 * a.height * Math.random(), (100 * Math.random() << 0) % 3) {
  229. case 0:
  230. a.clouds[c].v = a.width / 100 << 0;
  231. break;
  232. case 1:
  233. a.clouds[c].img = a.buffers.cloud2;
  234. a.clouds[c].v = a.width / 200 << 0;
  235. a.clouds[c].w = 94.5 * a.scale << 0;
  236. a.clouds[c].h = 58.8 * a.scale << 0;
  237. break;
  238. case 2:
  239. a.clouds[c].img = a.buffers.cloud3, a.clouds[c].v = a.width / 300 << 0, a.clouds[c].w = 54 * a.scale << 0, a.clouds[c].h = 33.6 * a.scale << 0
  240. }
  241. };
  242. a.delCloud = function (b) {
  243. a.delItem(a.clouds, b)
  244. };
  245. a.addCoin = function (b, f, c, e) {
  246. var d = a.coins.length;
  247. a.addItem("coin", b, a.coins, a.buffers.coin, 51 * a.scale << 0, 51 * a.scale << 0, -(a.height / 100), !0, !1);
  248. for (var l = d; l < d + b; l++) null != f && null != c && null != e ? (a.coins[l].altitude =
  249. f, a.coins[l].x = c, a.coins[l].y = e) : (a.coins[l].altitude += a.height, a.coins[l].colected = !1)
  250. };
  251. a.delCoin = function (b) {
  252. a.delItem(a.coins, b)
  253. };
  254. a.showClue = function () {
  255. a.ctx.fillStyle = "white";
  256. a.ctx.fillRect(0, 0, a.width, a.height);
  257. a.ctx.drawImage(d.getImage("clue"), (a.width - 122) / 2, (a.height - 145) / 2)
  258. };
  259. a.initMusic = function () {
  260. a.music.bg = document.createElement("audio");
  261. a.music.bg.setAttribute("src", "sound/bgsound.mp3");
  262. a.music.bg.setAttribute("preload", !0);
  263. a.music.bg.setAttribute("autoplay", !0);
  264. a.music.bg.setAttribute("loop", !0);
  265. a.music.bg.load();
  266. a.music.bg.addEventListener("canplaythrough", function () {
  267. a.music.bg.play()
  268. }, !0);
  269. a.music.drop = document.createElement("audio");
  270. a.music.drop.setAttribute("src", "sound/drop.mp3");
  271. a.music.drop.setAttribute("preload", !0);
  272. a.music.drop.load();
  273. a.music.ring = [];
  274. for (var b = a.music.ringIndex = 0; 5 > b; b++) a.music.ring[b] = document.createElement("audio"), a.music.ring[b].setAttribute("src", "sound/ring.mp3"), a.music.ring[b].setAttribute("preload", !0), a.music.ring[b].load();
  275. a.music.bomb = [];
  276. for (b = a.music.bombIndex =
  277. 0; 5 > b; b++) a.music.bomb[b] = document.createElement("audio"), a.music.bomb[b].setAttribute("src", "sound/bomb.mp3"), a.music.bomb[b].setAttribute("preload", !0), a.music.bomb[b].load()
  278. };
  279. a.musicControl = function () {
  280. if (a.volume) a.music.bg.play();
  281. else {
  282. a.music.bg.pause();
  283. a.music.drop.pause();
  284. for (var b = a.music.ring.length, f = 0; f < b; f++) a.music.ring[f].pause();
  285. b = a.music.bomb.length;
  286. for (f = 0; f < b; f++) a.music.bomb[f].pause()
  287. }
  288. };
  289. a.addBuffer = function (b, f, c, e) {
  290. c = c + 0.5 << 0;
  291. e = e + 0.5 << 0;
  292. a.buffer[b] = null;
  293. a.buffer[b] = document.createElement("canvas");
  294. a.buffer[b].width = c;
  295. a.buffer[b].height = e;
  296. a.buffer[b].getContext("2d")
  297. .drawImage(d.getImage(f), 0, 0, c, e)
  298. };
  299. a.initBuffer = function () {
  300. var b = 0;
  301. a.addBuffer(b, "house", 116 * a.scale, 101 * a.scale);
  302. a.buffers.house = null;
  303. a.buffers.house = a.buffer[b++];
  304. a.addBuffer(b, "land", 320 * a.scale, 67 * a.scale);
  305. a.buffers.land = null;
  306. a.buffers.land = a.buffer[b++];
  307. a.addBuffer(b, "ballon", 275 * a.scale, 58 * a.scale);
  308. a.buffers.ballon = null;
  309. a.buffers.ballon = a.buffer[b++];
  310. a.addBuffer(b, "bomb", 60 * a.scale, 75 * a.scale);
  311. a.buffers.bomb = null;
  312. a.buffers.bomb =
  313. a.buffer[b++];
  314. a.addBuffer(b, "bombfire", 30 * a.scale, 15 * a.scale);
  315. a.buffers.bombfire = null;
  316. a.buffers.bombfire = a.buffer[b++];
  317. a.addBuffer(b, "num1", 600 * a.scale, 75 * a.scale);
  318. a.buffers.num1 = null;
  319. a.buffers.num1 = a.buffer[b++];
  320. a.addBuffer(b, "num2", 180 * a.scale, 19 * a.scale);
  321. a.buffers.num2 = null;
  322. a.buffers.num2 = a.buffer[b++];
  323. a.addBuffer(b, "num3", 470 * a.scale, 60 * a.scale);
  324. a.buffers.num3 = null;
  325. a.buffers.num3 = a.buffer[b++];
  326. a.addBuffer(b, "cloud", 135 * a.scale, 84 * a.scale);
  327. a.buffers.cloud1 = null;
  328. a.buffers.cloud1 = a.buffer[b++];
  329. a.addBuffer(b,
  330. "cloud", 94.5 * a.scale, 58.8 * a.scale);
  331. a.buffers.cloud2 = null;
  332. a.buffers.cloud2 = a.buffer[b++];
  333. a.addBuffer(b, "cloud", 54 * a.scale, 33.6 * a.scale);
  334. a.buffers.cloud3 = null;
  335. a.buffers.cloud3 = a.buffer[b++];
  336. a.addBuffer(b, "coin", 50 * a.scale, 51 * a.scale);
  337. a.buffers.coin = null;
  338. a.buffers.coin = a.buffer[b++];
  339. a.addBuffer(b, "cover", 213 * a.scale, 212 * a.scale);
  340. a.buffers.cover = null;
  341. a.buffers.cover = a.buffer[b++];
  342. a.addBuffer(b, "bg", 320 * a.scale, 1440 * a.scale);
  343. a.buffers.bg = null;
  344. a.buffers.bg = a.buffer[b++];
  345. a.addBuffer(b, "explode", 603 * a.scale,
  346. 163 * a.scale);
  347. a.buffers.explode = null;
  348. a.buffers.explode = a.buffer[b++];
  349. a.addBuffer(b, "statebar", 320 * a.scale, 60 * a.scale);
  350. a.buffers.statebar = null;
  351. a.buffers.statebar = a.buffer[b++];
  352. a.addBuffer(b, "title", 320 * a.scale, 134 * a.scale);
  353. a.buffers.title = null;
  354. a.buffers.title = a.buffer[b++];
  355. a.addBuffer(b, "sound1", 88 * a.scale, 38 * a.scale);
  356. a.buffers.sound1 = null;
  357. a.buffers.sound1 = a.buffer[b++];
  358. a.addBuffer(b, "sound2", 88 * a.scale, 38 * a.scale);
  359. a.buffers.sound2 = null;
  360. a.buffers.sound2 = a.buffer[b++];
  361. a.addBuffer(b, "achieve", 148 * a.scale,
  362. 68 * a.scale);
  363. a.buffers.achieve = null;
  364. a.buffers.achieve = a.buffer[b++];
  365. a.addBuffer(b, "achieve_dialog", 320 * a.scale, 480 * a.scale);
  366. a.buffers.achieve_dialog = null;
  367. a.buffers.achieve_dialog = a.buffer[b++];
  368. a.addBuffer(b, "lock", 73 * a.scale, 72 * a.scale);
  369. a.buffers.lock = null;
  370. a.buffers.lock = a.buffer[b++];
  371. a.addBuffer(b, "back", 148 * a.scale, 68 * a.scale);
  372. a.buffers.back = null;
  373. a.buffers.back = a.buffer[b++];
  374. a.addBuffer(b, "begin", 382 * a.scale, 185 * a.scale);
  375. a.buffers.begin = null;
  376. a.buffers.begin = a.buffer[b++];
  377. a.addBuffer(b, "exit1", 88 *
  378. a.scale, 38 * a.scale);
  379. a.buffers.exit1 = null;
  380. a.buffers.exit1 = a.buffer[b++];
  381. a.addBuffer(b, "exit2", 170 * a.scale, 80 * a.scale);
  382. a.buffers.exit2 = null;
  383. a.buffers.exit2 = a.buffer[b++];
  384. a.addBuffer(b, "rank", 148 * a.scale, 68 * a.scale);
  385. a.buffers.rank = null;
  386. a.buffers.rank = a.buffer[b++];
  387. a.addBuffer(b, "more", 148 * a.scale, 68 * a.scale);
  388. a.buffers.more = null;
  389. a.buffers.more = a.buffer[b++];
  390. a.addBuffer(b, "logo1", 320 * a.scale, 480 * a.scale);
  391. a.buffers.logo1 = null;
  392. a.buffers.logo1 = a.buffer[b++];
  393. a.addBuffer(b, "logo2", 320 * a.scale, 182 * a.scale);
  394. a.buffers.logo2 = null;
  395. a.buffers.logo2 = a.buffer[b++];
  396. a.addBuffer(b, "help", 306 * a.scale, 441 * a.scale);
  397. a.buffers.help = null;
  398. a.buffers.help = a.buffer[b++];
  399. a.addBuffer(b, "next2", 112 * a.scale, 36 * a.scale);
  400. a.buffers.next2 = null;
  401. a.buffers.next2 = a.buffer[b++];
  402. a.addBuffer(b, "pause", 88 * a.scale, 38 * a.scale);
  403. a.buffers.pause = null;
  404. a.buffers.pause = a.buffer[b++];
  405. a.addBuffer(b, "pause_bg", 321 * a.scale, 420 * a.scale);
  406. a.buffers.pause_bg = null;
  407. a.buffers.pause_bg = a.buffer[b++];
  408. a.addBuffer(b, "resume", 170 * a.scale, 80 * a.scale);
  409. a.buffers.resume =
  410. null;
  411. a.buffers.resume = a.buffer[b++]
  412. };
  413. a.initSize = function () {
  414. var b = a.scale;
  415. a.scales = {
  416. scope1: a.height + 50 * b << 0,
  417. scope2: a.width + 50 * b << 0,
  418. font2: (20 * b << 0) + "px Arial",
  419. coin1: 50 * b << 0,
  420. coin2: 40 * b << 0,
  421. statusbar1: 0.1 * a.width << 0
  422. };
  423. a.explode && (a.explode.w = 201 * b << 0, a.explode.h = 163 * b << 0);
  424. a.explodeDis = 50 * b << 0;
  425. a.cover = {
  426. id: "cover",
  427. img: a.buffers.cover,
  428. w: 213 * b << 0,
  429. h: 212 * b << 0
  430. };
  431. a.land && (a.land.x = a.width / 2 << 0, a.land.y = a.height - 33 * b << 0, a.land.w = 320 * b << 0, a.land.h = 67 * b << 0, a.house.img = a.buffers.land);
  432. a.house && (a.house.x = a.width / 2 <<
  433. 0, a.house.y = a.height - 57 * b << 0, a.house.w = 116 * b << 0, a.house.h = 101 * b << 0, a.house.img = a.buffers.house);
  434. if (a.ballons)
  435. for (var f = a.ballons.length, c = 0; c < f; c++) a.ballons[c].w = 54 * a.scale << 0, a.ballons[c].h = 65 * a.scale << 0;
  436. a.btns.begin && (a.btns.begin.x = 160 * b << 0, a.btns.begin.y = 250 * b << 0, a.btns.begin.w = 188 * b << 0, a.btns.begin.h = 185 * b << 0, a.btns.begin.img = a.buffers.begin, a.btns.achieve.x = 50 * b << 0, a.btns.achieve.y = 350 * b << 0, a.btns.achieve.w = 71 * b << 0, a.btns.achieve.h = 68 * b << 0, a.btns.achieve.img = a.buffers.achieve, a.btns.sound.x =
  437. 235 * b << 0, a.btns.sound.y = 22 * b << 0, a.btns.sound.w = 41 * b << 0, a.btns.sound.h = 38 * b << 0, a.btns.sound.img = a.buffers.sound1, a.btns.exit1.x = 285 * b << 0, a.btns.exit1.y = 22 * b << 0, a.btns.exit1.w = 41 * b << 0, a.btns.exit1.h = 38 * b << 0, a.btns.exit1.img = a.buffers.exit1, a.btns.clue1 && (a.btns.clue1.x = (a.width - 156) / 2 + 78, a.btns.clue1.y = a.height - 32));
  438. a.btns.help && (a.btns.help.x = a.width / 2 << 0, a.btns.help.y = a.height / 2 << 0, a.btns.help.w = a.width, a.btns.help.h = a.height, a.btns.help.img = a.buffers.help);
  439. a.btns.pause && (a.btns.sound.x = 235 * a.scale <<
  440. 0, a.btns.sound.y = 30 * a.scale << 0, a.btns.sound.w = 44 * a.scale << 0, a.btns.sound.h = 38 * a.scale << 0, a.btns.sound.img = a.buffers.sound1, a.btns.pause.x = 285 * a.scale << 0, a.btns.pause.y = 30 * a.scale << 0, a.btns.pause.w = 44 * a.scale << 0, a.btns.pause.h = 38 * a.scale << 0, a.btns.pause.img = a.buffers.pause);
  441. a.btns.resume && (a.btns.resume.x = 0.3 * a.width << 0, a.btns.resume.y = 265 * a.scale << 0, a.btns.resume.w = 85 * a.scale << 0, a.btns.resume.h = 80 * a.scale << 0, a.btns.resume.img = a.buffers.resume, a.btns.exit2.x = 0.7 * a.width << 0, a.btns.exit2.y = 265 * a.scale <<
  442. 0, a.btns.exit2.w = 85 * a.scale << 0, a.btns.exit2.h = 80 * a.scale << 0, a.btns.exit2.img = a.buffers.exit2)
  443. };
  444. a.initLocalStorage = function () {
  445. try {
  446. var b = localStorage.getItem("flyhouse");
  447. b ? (b = JSON.parse(b), a.achieve = b.achieve) : a.localStorage()
  448. } catch (f) {
  449. console.log(f)
  450. }
  451. };
  452. a.localStorage = function () {
  453. try {
  454. localStorage.setItem("flyhouse", JSON.stringify({
  455. achieve: a.achieve
  456. }))
  457. } catch (b) {
  458. console.log(b)
  459. }
  460. };
  461. a.init = function () {
  462. a.initCanvas();
  463. var b = 1440 * a.scale - a.height << 0;
  464. a.bg = {
  465. init: b,
  466. current: b,
  467. target: b
  468. };
  469. a.timer = 20;
  470. a.touchTime =
  471. 0;
  472. a.startX = 0;
  473. a.paused = !0;
  474. a.money = 0;
  475. a.ballons = [];
  476. a.bombs = [];
  477. a.clouds = [];
  478. a.coins = [];
  479. a.explodes = [];
  480. a.explode = {
  481. id: "explode",
  482. img: a.buffers.explode,
  483. w: 201 * a.scale << 0,
  484. h: 163 * a.scale << 0,
  485. index: 0
  486. };
  487. a.invincible = 0;
  488. a.dragFlag = !1;
  489. a.offsetX = 0;
  490. a.score = 0;
  491. a.level = 1;
  492. a.clue = !1;
  493. a.shake = 0;
  494. a.housePos = 0;
  495. a.land.img = a.buffers.land;
  496. a.land.altitude = 0;
  497. a.land.x = a.width / 2 << 0;
  498. a.land.y = a.height - 33 * a.scale;
  499. a.land.w = 320 * a.scale;
  500. a.land.h = 67 * a.scale;
  501. a.house.img = a.buffers.house;
  502. a.house.altitude = 0;
  503. a.house.target = 0;
  504. a.house.x = a.width / 2 << 0;
  505. a.house.y = a.height - 57 * a.scale;
  506. a.house.w = 116 * a.scale;
  507. a.house.h = 101 * a.scale;
  508. a.house.ballons = 0;
  509. a.house.timer = 0;
  510. a.achieve = [!1, !1, !1, !1, !1, !1, !1, !1, !1, !1];
  511. a.achieveCount = [0, 0];
  512. a.achieveTimer = 0;
  513. a.achieveFlag = 0;
  514. a.initLocalStorage();
  515. a.clueTimer1 = 0;
  516. a.clueTimer2 = 0; - 1 == navigator.userAgent.toLowerCase()
  517. .indexOf("iphone") && -1 == navigator.userAgent.toLowerCase()
  518. .indexOf("ipod") || window.navigator.standalone || a.createClueDialog()
  519. };
  520. a.refresh = function () {
  521. if (a.paused) a.ctx.drawImage(a.buffers.statebar, 0, 0), a.drawNum(a.house.altitude,
  522. a.scales.statusbar1, 8 * a.scale << 0, a.buffers.num2, 18, 19, 2, a.scale), a.drawNum(a.money, a.scales.statusbar1, 33 * a.scale << 0, a.buffers.num2, 18, 19, 2, a.scale), a.showPauseDialog();
  523. else {
  524. var b = a.ctx;
  525. try {
  526. b.drawImage(a.buffers.bg, 0, a.bg.current, a.width, a.height, 0, 0, a.width, a.height)
  527. } catch (f) {}
  528. for (var c = a.clouds.length, e = 0; e < c; e++) {
  529. var g = a.clouds[e];
  530. !g || -50 > g.y || g.y > a.scales.scope1 || -50 > g.x || g.x > a.scales.scope2 || b.drawImage(g.img, g.x - g.w / 2 << 0, g.y - g.h / 2 << 0)
  531. }
  532. 0 == a.house.altitude && b.drawImage(a.buffers.land, a.width /
  533. 2 - a.land.w / 2 << 0, a.height - a.land.h << 0);
  534. b.drawImage(a.buffers.house, a.house.x - a.house.w / 2 << 0, a.house.y - a.house.h / 2 << 0);
  535. if (c = a.ballons.length)
  536. for (var g = a.house.x << 0, l = a.house.y - 0.31 * a.house.h << 0, e = 0; e < c; e++) {
  537. var k = a.ballons[e];
  538. k.tied && (d.canvas.beginPath(), d.canvas.moveTo(g, l), d.canvas.lineTo(k.x, k.y + 0.45 * k.h), d.canvas.stroke());
  539. b.drawImage(a.buffers.ballon, 55 * k.color * a.scale << 0, 0, k.w, k.h, k.x - k.w / 2 << 0, k.y - k.h / 2 << 0, k.w, k.h)
  540. }
  541. 0 < a.invincible && b.drawImage(a.buffers.cover, a.house.x - a.cover.w / 2 << 0, a.house.y -
  542. a.cover.h / 2 << 0);
  543. c = a.coins.length;
  544. for (e = 0; e < c; e++) g = a.coins[e], !g || -50 > g.y || g.y > a.scales.scope1 || -50 > g.x || g.x > a.scales.scope2 || b.drawImage(a.buffers.coin, g.x - g.w / 2 << 0, g.y - g.h / 2 << 0);
  545. c = a.bombs.length;
  546. g = a.buffers.bomb;
  547. l = a.buffers.bombfire;
  548. k = a.buffers.num1;
  549. for (e = 0; e < c; e++) {
  550. var h = a.bombs[e];
  551. if (h && !(-50 > h.y || h.y > a.scales.scope1 || -50 > h.x || h.x > a.scales.scope2)) {
  552. b.drawImage(g, h.x - h.w / 2 << 0, h.y - h.h / 2 << 0);
  553. var n = 0,
  554. m = 15 * a.scale << 0;
  555. switch (h.flash) {
  556. case 0:
  557. h.flash = 1;
  558. break;
  559. case 1:
  560. n = m, h.flash = 0
  561. }
  562. b.drawImage(l, n, 0, m, m,
  563. h.x << 0, h.y - h.h / 2 << 0, m, m);
  564. a.drawNum(h.timer, h.x - h.w / 2 << 0, h.y - h.h / 2 << 0, k, 60, 75, 0, a.scale)
  565. }
  566. }
  567. a.update();
  568. if (0 < a.achieveTimer) {
  569. a.achieveTimer--;
  570. b.drawImage(d.getImage("achieve6"), 0.15 * a.width << 0, 70 * a.scale << 0, 100 * a.scale << 0, 19 * a.scale << 0);
  571. e = c = 0;
  572. switch (a.achieveFlag) {
  573. case 0:
  574. c = 79 * a.scale << 0;
  575. e = 19 * a.scale << 0;
  576. break;
  577. case 1:
  578. c = 79 * a.scale << 0;
  579. e = 19 * a.scale << 0;
  580. break;
  581. case 2:
  582. c = 99 * a.scale << 0;
  583. e = 19 * a.scale << 0;
  584. break;
  585. case 3:
  586. c = 59 * a.scale << 0;
  587. e = 19 * a.scale << 0;
  588. break;
  589. case 4:
  590. c = 99 * a.scale << 0;
  591. e = 19 * a.scale << 0;
  592. break;
  593. case 5:
  594. c = 99 * a.scale <<
  595. 0, e = 19 * a.scale << 0
  596. }
  597. b.drawImage(d.getImage("achieve" + a.achieveFlag), 0.55 * a.width << 0, 70 * a.scale << 0, c, e)
  598. }
  599. 0 < a.clueTimer1 && (a.clueTimer1--, b.drawImage(d.getImage("clue_coin"), 0.1 * a.width << 0, 60 * a.scale << 0, 197 * a.scale << 0, 72 * a.scale << 0));
  600. 0 < a.clueTimer2 && (a.clueTimer2--, b.drawImage(d.getImage("clue_finger"), a.house.x + a.house.w / 4, a.house.y - a.house.h / 3, 135 * a.scale << 0, 55 * a.scale << 0));
  601. b.drawImage(a.buffers.statebar, 0, 0);
  602. a.drawNum(a.house.altitude, a.scales.statusbar1, 8 * a.scale << 0, a.buffers.num2, 18, 19, 2, a.scale);
  603. a.drawNum(a.money, a.scales.statusbar1, 33 * a.scale << 0, a.buffers.num2, 18, 19, 2, a.scale);
  604. a.showGamePage()
  605. }
  606. };
  607. a.update = function () {
  608. a.timer--;
  609. 0 >= a.timer && (a.timer = 20);
  610. 0 < a.invincible && a.invincible--;
  611. a.updateCloud();
  612. a.updateHouse();
  613. a.updateBallon();
  614. a.updateCoin();
  615. a.updateBomb();
  616. a.updateExplode();
  617. a.updateScore()
  618. };
  619. a.updateAchieve = function () {
  620. !a.achieve[0] && 100 <= a.achieveCount[0] ? (a.achieve[0] = !0, a.localStorage(), a.achieveTimer = 100, a.achieveFlag = 0, a.sinaAchieve(9)) : !a.achieve[1] && 200 <= a.achieveCount[1] ? (a.achieve[1] = !0, a.localStorage(), a.achieveTimer = 100, a.achieveFlag = 1, a.sinaAchieve(5)) : !a.achieve[2] && 5E3 <= a.house.altitude ? (a.achieve[2] = !0, a.localStorage(), a.achieveTimer = 100, a.achieveFlag = 2, a.sinaAchieve(1)) : !a.achieve[3] && 2E3 <= a.money ? (a.achieve[3] = !0, a.localStorage(), a.achieveTimer = 100, a.achieveFlag = 3, a.sinaAchieve(3)) : !a.achieve[4] && 12E3 <= a.house.altitude ? (a.achieve[4] = !0, a.localStorage(), a.achieveTimer = 100, a.achieveFlag = 4, a.sinaAchieve(4)) : !a.achieve[5] && 8E3 <= a.house.altitude ? (a.achieve[5] = !0, a.localStorage(),
  621. a.achieveTimer = 100, a.achieveFlag = 5, a.sinaAchieve(2)) : !a.achieve[6] && 14E3 <= a.house.altitude ? (a.achieve[6] = !0, a.localStorage(), a.sinaAchieve(6)) : !a.achieve[7] && 3E3 <= a.money ? (a.achieve[7] = !0, a.localStorage(), a.sinaAchieve(7)) : !a.achieve[8] && 300 <= a.achieveCount[1] ? (a.achieve[8] = !0, a.localStorage(), a.sinaAchieve(8)) : !a.achieve[9] && 16E3 <= a.house.altitude && (a.achieve[9] = !0, a.localStorage(), a.sinaAchieve(10))
  622. };
  623. a.updateScore = function () {
  624. var b = a.house.altitude + a.money;
  625. b > a.score && (a.score = b);
  626. };
  627. a.updateHouse = function () {
  628. if (0 <
  629. a.house.timer) {
  630. if (20 < a.house.timer) {
  631. var b = (a.house.target - a.house.altitude) / (a.house.timer - 20);
  632. a.house.altitude = a.house.altitude + b << 0;
  633. a.house.y -= b / 5
  634. } else b = (a.bg.target - a.bg.current) / a.house.timer, a.bg.current += b, a.house.y += (a.housePos - a.house.y) / a.house.timer, a.bg.current = 0 > a.bg.current ? 0 : a.bg.current << 0, a.bg.current = a.bg.current > a.bg.init ? a.bg.init : a.bg.current << 0;
  635. a.house.timer--
  636. } else a.house.altitude = a.house.target, a.housePos = a.house.y;
  637. a.house.target != a.house.altitude ? (0 == a.house.target && (a.house.x -=
  638. (a.house.x - a.width / 2) / a.house.timer, a.house.y -= (a.house.y - a.height + a.house.h / 2) / a.house.timer), a.house.target < a.house.altitude && a.volume && a.music.drop.play(), a.level = 3200 > a.house.altitude ? 1 : 6400 > a.house.altitude ? 2 : 9600 > a.house.altitude ? 3 : 4) : 0 == a.house.altitude && (a.house.x = a.width / 2 << 0, a.house.y = a.height + 1 - a.house.h / 2 << 0)
  639. };
  640. a.updateBallon = function () {
  641. var b = a.ballons.length;
  642. (1 > b - a.house.ballons || b - a.house.ballons < 2 * a.level && !(a.timer % 10) && 0.2 > Math.random()) && a.addBallon(1);
  643. for (var f = 0; f < b; f++) a.ballons[f].tied &&
  644. (a.ballons[f].timer = 10);
  645. for (f = 0; f < b; f++) {
  646. var c = a.ballons[f];
  647. if (c.tied || c.selected) 0 < c.timer && (c.x -= (c.x - (a.house.x + c.offsetX * Math.pow(-1, f % 2))) / c.timer, c.y -= (c.y - (a.house.y - c.offsetY)) / c.timer, c.x <<= 0, c.y <<= 0, c.timer--);
  648. else if (c.altitude += c.v, c.altitude <<= 0, c.y = a.house.altitude - c.altitude + a.height, c.y < -a.height || c.y > 2 * a.height) a.delBallon(c.id), f--, b--;
  649. c.exploded && (a.explodes[a.explodes.length] = {
  650. x: c.x,
  651. y: c.y,
  652. timer: 10
  653. }, c.tied && (c.tied = !1, a.house.ballons = a.getBallonsNum(), a.house.timer = 40, a.house.target =
  654. 200 * a.house.ballons, a.bg.target = a.bg.init - 20 * a.house.ballons, a.bg.target = 0 > a.bg.target ? 0 : a.bg.target, a.achieveCount[1]++), a.delBallon(c.id), f--, b--, a.volume && (a.music.bomb[a.music.bombIndex].play(), a.music.bombIndex = (a.music.bombIndex + 1) % 5))
  655. }
  656. };
  657. a.getBallonsNum = function () {
  658. for (var b = a.ballons.length, f = 0, c = 0; c < b; c++) a.ballons[c].tied && f++;
  659. return f
  660. };
  661. a.addToHouse = function (b) {
  662. b.tied || (b.tied = !0, a.house.ballons = a.getBallonsNum(), b.v = 0, b.timer = 15, a.offsetX = a.offsetX > 0.7 * a.house.w ? 0 : a.offsetX + a.house.w / 10,
  663. b.offsetX = a.offsetX << 0, b.offsetY = (Math.random() + 1) * a.house.h * 0.65 << 0, a.house.timer = 40, a.house.target = 200 * a.house.ballons, a.bg.target = a.bg.init - 20 * a.house.ballons, a.bg.target = 0 > a.bg.target ? 0 : a.bg.target, a.newGame2 && (a.clueTimer2 = 60, a.newGame2 = !1))
  664. };
  665. a.updateBomb = function () {
  666. var b = a.bombs.length;
  667. (1 > b || 0 == a.timer % 10 && b < 3 * a.level && Math.random() < 0.2 * a.level) && a.addBomb(1);
  668. for (var f = 0; f < b; f++) {
  669. var c = a.bombs[f];
  670. if (c) {
  671. c.selected ? c.altitude = a.house.altitude + a.height - c.y : (c.altitude += c.v, c.altitude <<= 0, c.y = a.height -
  672. c.altitude + a.house.altitude);
  673. if (0 < a.invincible)
  674. if (Math.abs(c.x - a.house.x) < a.cover.w / 2 && Math.abs(c.y - a.house.y) < a.cover.h / 2) c.exploded = !0;
  675. else {
  676. for (var e = a.bombs.length, d = 0; d < e; d++) f != d && Math.abs(a.bombs[d].x - c.x) < a.explodeDis && Math.abs(a.bombs[d].y - c.y) < a.explodeDis && (c.exploded = !0, a.bombs[d].exploded = !0);
  677. e = a.ballons.length;
  678. for (d = 0; d < e; d++) Math.abs(a.ballons[d].x - c.x) < a.explodeDis && Math.abs(a.ballons[d].y - c.y) < a.explodeDis && !a.ballons[d].tied && (c.exploded = !0, a.ballons[d].exploded = !0)
  679. } else {
  680. e = a.bombs.length;
  681. for (d = 0; d < e; d++) f != d && Math.abs(a.bombs[d].x - c.x) < a.explodeDis && Math.abs(a.bombs[d].y - c.y) < a.explodeDis && (c.exploded = !0, a.bombs[d].exploded = !0);
  682. e = a.ballons.length;
  683. for (d = 0; d < e; d++) Math.abs(a.ballons[d].x - c.x) < a.explodeDis && Math.abs(a.ballons[d].y - c.y) < a.explodeDis && (c.exploded = !0, a.ballons[d].exploded = !0)
  684. }
  685. 20 == a.timer && c.timer--;
  686. if (c.exploded || 1 > c.timer) a.explodes[a.explodes.length] = {
  687. x: c.x,
  688. y: c.y,
  689. timer: 10
  690. }, c.coin && a.addCoin(1, c.altitude, c.x, c.y), a.delBomb(c.id), f--, b--, a.volume && (a.music.bomb[a.music.bombIndex].play(),
  691. a.music.bombIndex = (a.music.bombIndex + 1) % 5);
  692. if (c.y > 2 * a.height || c.y < -a.height) a.delBomb(c.id), f--, b--
  693. }
  694. }
  695. };
  696. a.updateCoin = function () {
  697. var b = a.coins.length;
  698. (1 > b || 0 == a.timer % 13 && b < 2 * a.level && Math.random() < 2 * a.level) && a.addCoin(1);
  699. for (var d = 0; d < b; d++) {
  700. var c = a.coins[d];
  701. if (c.colected) 0 < c.timer-- ? (c.x -= c.vx, c.y -= c.vy) : (a.delCoin(c.id), d--, b--);
  702. else if (c.altitude += c.v, c.altitude <<= 0, c.y = a.height - c.altitude + a.house.altitude, c.y > 2 * a.height || c.y < -a.height) a.delCoin(c.id), d--, b--
  703. }
  704. };
  705. a.collectCoin = function (b) {
  706. b.colected ||
  707. (a.money += 10 / a.level << 0, b.timer = 5, b.vx = (b.x - a.scales.coin1) / b.timer, b.vy = (b.y - a.scales.coin2) / b.timer, b.colected = !0, a.volume && (a.music.ring[a.music.ringIndex].play(), a.music.ringIndex = (a.music.ringIndex + 1) % 5));
  708. a.newGame1 && 100 <= a.money && (a.newGame1 = !1, a.clueTimer1 = 60)
  709. };
  710. a.updateCloud = function () {
  711. if (!(5E3 < a.house.altitude)) {
  712. var b = a.clouds.length;
  713. 3E3 < a.house.altitude ? 0 == a.timer % 10 && 3 > b && 0.5 < Math.random() && a.addCloud(1) : 1500 < a.house.altitude ? 0 == a.timer % 10 && 7 > b && 0.5 < Math.random() && a.addCloud(1) : 0 == a.timer %
  714. 10 && 5 > b && 0.5 < Math.random() && a.addCloud(1);
  715. for (var d = 0; d < b; d++) {
  716. var c = a.clouds[d];
  717. c.x = (c.x + c.v) % (2 * a.width);
  718. c.y = a.height - c.altitude + a.house.altitude;
  719. if (c.y > 2 * a.height || c.y < -a.height) a.delCloud(c.id), d--, b--
  720. }
  721. }
  722. };
  723. a.updateExplode = function () {
  724. for (var b = a.explodes.length, d = a.explode, c = 0; c < b; c++) {
  725. var e = a.explodes[c];
  726. e.timer--;
  727. 0 <= e.timer ? (8 < e.timer ? d.index = 0 : 6 < e.timer ? d.index = 1 : 0 < e.timer && (d.index = 2), a.ctx.drawImage(a.buffers.explode, d.index * d.w << 0, 0, d.w, d.h, e.x - d.w / 2 << 0, e.y - d.h / 2 << 0, d.w, d.h)) : (a.explodes.splice(c,
  728. 1), c--, b--)
  729. }
  730. };
  731. window.onorientationchange = function () {
  732. switch (window.orientation) {
  733. case 0:
  734. case 180:
  735. a.initCanvas();
  736. a.clue = !1;
  737. if (a.newGame) try {
  738. a.initCanvas(), a.scaleTmp = a.scale, a.initBuffer(), a.initSize(), a.land = {
  739. id: "land",
  740. name: "land",
  741. img: a.buffers.land,
  742. altitude: 0,
  743. x: a.width / 2 << 0,
  744. y: a.height - 33 * a.scale,
  745. w: 320 * a.scale,
  746. h: 67 * a.scale
  747. }, a.house = {
  748. id: "house",
  749. name: "house",
  750. img: a.buffers.house,
  751. altitude: 0,
  752. target: 0,
  753. x: a.width / 2 << 0,
  754. y: a.height - 57 * a.scale,
  755. w: 116 * a.scale,
  756. h: 101 * a.scale,
  757. ballons: 0,
  758. timer: 0
  759. }, d.touch.create(a.house, !1, !0), a.init(), a.createLogoPage(), a.showLogoPage(), a.newGame = !1
  760. } catch (b) {
  761. window.location.reload(!1)
  762. }
  763. break;
  764. case -90:
  765. case 90:
  766. a.initCanvas(), a.clue = !0, a.showClue()
  767. }
  768. };
  769. a.drawBtns = function (b) {
  770. var d = 0;
  771. b.selected && (d = b.w);
  772. a.ctx.drawImage(b.img, d, 0, b.w, b.h, b.x - b.w / 2 + 0.5 << 0, b.y - b.h / 2 + 0.5 << 0, b.w, b.h)
  773. };
  774. a.createLogoPage = function () {
  775. if (!(a.btns.begin || a.btns.achieve || a.btns.sound)) {
  776. a.btns.begin = {
  777. id: a.id++,
  778. name: "begin",
  779. img: a.buffers.begin,
  780. x: 160 * a.scale << 0,
  781. y: 250 * a.scale << 0,
  782. w: 191 * a.scale << 0,
  783. h: 185 * a.scale << 0
  784. };
  785. d.touch.create(a.btns.begin, !0, !1);
  786. a.btns.achieve = {
  787. id: a.id++,
  788. name: "achieve",
  789. img: a.buffers.achieve,
  790. x: 50 * a.scale << 0,
  791. y: 350 * a.scale << 0,
  792. w: 74 * a.scale << 0,
  793. h: 68 * a.scale << 0
  794. };
  795. d.touch.create(a.btns.achieve, !0, !1);
  796. a.btns.sound = {
  797. id: a.id++,
  798. name: "sound",
  799. img: a.buffers.sound1,
  800. x: 285 * a.scale << 0,
  801. y: 22 * a.scale << 0,
  802. w: 44 * a.scale << 0,
  803. h: 38 * a.scale << 0
  804. };
  805. d.touch.create(a.btns.sound, !0, !1);
  806. a.logoBallons = [];
  807. for (var b = 0; 7 > b; b++) a.logoBallons[b] = {
  808. x: Math.random() * a.width * 0.9 + 55 * a.scale,
  809. y: a.height * (Math.random() + 1),
  810. v: 3 * (Math.random() + 1) * a.scale,
  811. color: (100 * Math.random() <<
  812. 0) % 5
  813. }
  814. }
  815. };
  816. a.delLogoPage = function () {
  817. a.btns.begin && (d.touch.deleteImg(a.btns.sound.id), a.btns.sound = null, d.touch.deleteImg(a.btns.begin.id), a.btns.begin = null, d.touch.deleteImg(a.btns.achieve.id), a.btns.achieve = null, a.logoBallons = null)
  818. };
  819. a.showLogoPage = function () {
  820. a.ctx.drawImage(a.buffers.logo1, 0, 0);
  821. a.height > 480 * a.scale && (a.ctx.drawImage(a.buffers.logo2, 0, 460 * a.scale), a.height > 640 * a.scale && a.ctx.drawImage(a.buffers.logo2, 0, 620 * a.scale));
  822. for (var b = 55 * a.scale << 0, d = 58 * a.scale << 0, c = 0; 7 > c; c++) {
  823. var e = a.logoBallons[c];
  824. e.y -= e.v;
  825. e.y < 80 * a.scale && (e.x = Math.random() * a.width * 0.9 + 55 * a.scale, e.y = a.height * (Math.random() + 1), e.v = 3 * (Math.random() + 1) * a.scale, e.color = (100 * Math.random() << 0) % 5);
  826. a.ctx.drawImage(a.buffers.ballon, 55 * e.color * a.scale << 0, 0, b, d, e.x, e.y, b, d)
  827. }
  828. a.ctx.drawImage(a.buffers.title, 0, 0);
  829. a.btns.sound.img = a.volume ? a.buffers.sound1 : a.buffers.sound2;
  830. a.drawBtns(a.btns.sound);
  831. a.drawBtns(a.btns.begin);
  832. a.drawBtns(a.btns.achieve);
  833. //a.showClueDialog()
  834. };
  835. a.createAchievePage = function () {
  836. a.btns.achieve_bg || (a.btns.achieve_bg = {
  837. id: a.id++,
  838. name: "achieve_bg",
  839. img: null,
  840. x: a.width / 2 << 0,
  841. y: a.height / 2 << 0,
  842. w: a.width,
  843. h: a.height
  844. }, d.touch.create(a.btns.achieve_bg, !0, !1), a.btns.next2 = {
  845. id: a.id++,
  846. name: "next2",
  847. img: a.buffers.next2,
  848. x: 0.15 * a.width << 0,
  849. y: 25 * a.scale << 0,
  850. w: 56 * a.scale << 0,
  851. h: 36 * a.scale << 0
  852. }, d.touch.create(a.btns.next2, !0, !1))
  853. };
  854. a.delAchievePage = function () {
  855. a.btns.achieve_bg && (d.touch.deleteImg(a.btns.achieve_bg.id), a.btns.achieve_bg = null, d.touch.deleteImg(a.btns.next2.id), a.btns.next2 = null)
  856. };
  857. a.showAchievePage = function () {
  858. a.ctx.drawImage(a.buffers.bg,
  859. 0, 1440 * a.scale - a.height << 0, a.width, a.height, 0, 0, a.width, a.height);
  860. a.ctx.drawImage(a.buffers.achieve_dialog, 0, 0);
  861. for (var b = 0; 6 > b; b++) switch (b) {
  862. case 0:
  863. !a.achieve[b] && a.ctx.drawImage(a.buffers.lock, 47 * a.scale << 0, 75 * a.scale << 0);
  864. break;
  865. case 1:
  866. !a.achieve[b] && a.ctx.drawImage(a.buffers.lock, 47 * a.scale << 0, 210 * a.scale << 0);
  867. break;
  868. case 2:
  869. !a.achieve[b] && a.ctx.drawImage(a.buffers.lock, 47 * a.scale << 0, 345 * a.scale << 0);
  870. break;
  871. case 3:
  872. !a.achieve[b] && a.ctx.drawImage(a.buffers.lock, 198 * a.scale << 0, 75 * a.scale << 0);
  873. break;
  874. case 4:
  875. !a.achieve[b] &&
  876. a.ctx.drawImage(a.buffers.lock, 198 * a.scale << 0, 210 * a.scale << 0);
  877. break;
  878. case 5:
  879. !a.achieve[b] && a.ctx.drawImage(a.buffers.lock, 198 * a.scale << 0, 345 * a.scale << 0)
  880. }
  881. a.drawBtns(a.btns.next2)
  882. };
  883. a.createHelpPage = function () {
  884. a.btns.help || (a.btns.help = {
  885. id: a.id++,
  886. name: "help",
  887. img: null,
  888. x: a.width / 2 << 0,
  889. y: a.height / 2 << 0,
  890. w: a.width,
  891. h: a.height
  892. }, d.touch.create(a.btns.help, !0, !1))
  893. };
  894. a.delHelpPage = function () {
  895. a.btns.help && (d.touch.deleteImg(a.btns.help.id), a.btns.help = null)
  896. };
  897. a.showHelpPage = function () {
  898. a.ctx.fillStyle = "#8AAD82";
  899. a.ctx.fillRect(0,
  900. 0, a.width, a.height);
  901. a.ctx.drawImage(a.buffers.help, (a.width - 306 * a.scale) / 2, (a.height - 441 * a.scale) / 2)
  902. };
  903. a.createGamePage = function () {
  904. a.btns.sound || a.btns.pause || (a.btns.sound = {
  905. id: a.id++,
  906. name: "sound",
  907. img: a.buffers.sound1,
  908. x: 235 * a.scale << 0,
  909. y: 30 * a.scale << 0,
  910. w: 44 * a.scale << 0,
  911. h: 38 * a.scale << 0
  912. }, d.touch.create(a.btns.sound, !0, !1), a.btns.pause = {
  913. id: a.id++,
  914. name: "pause",
  915. img: a.buffers.pause,
  916. x: 285 * a.scale << 0,
  917. y: 30 * a.scale << 0,
  918. w: 44 * a.scale << 0,
  919. h: 38 * a.scale << 0
  920. }, d.touch.create(a.btns.pause, !0, !1))
  921. };
  922. a.delGamePage = function () {
  923. a.btns.pause &&
  924. (d.touch.deleteImg(a.btns.sound.id), a.btns.sound = null, d.touch.deleteImg(a.btns.pause.id), a.btns.pause = null)
  925. };
  926. a.showGamePage = function () {
  927. a.btns.sound.img = a.volume ? a.buffers.sound1 : a.buffers.sound2;
  928. a.drawBtns(a.btns.sound);
  929. a.drawBtns(a.btns.pause)
  930. };
  931. a.createPauseDialog = function () {
  932. a.btns.resume || a.btns.exit2 || (a.btns.resume = {
  933. id: a.id++,
  934. name: "resume",
  935. img: a.buffers.resume,
  936. x: 0.3 * a.width << 0,
  937. y: 265 * a.scale << 0,
  938. w: 85 * a.scale << 0,
  939. h: 80 * a.scale << 0
  940. }, d.touch.create(a.btns.resume, !0, !1), a.btns.exit2 = {
  941. id: a.id++,
  942. name: "exit2",
  943. img: a.buffers.exit2,
  944. x: 0.7 * a.width << 0,
  945. y: 265 * a.scale << 0,
  946. w: 85 * a.scale << 0,
  947. h: 80 * a.scale << 0
  948. }, d.touch.create(a.btns.exit2, !0, !1))
  949. };
  950. a.delPauseDialog = function () {
  951. a.btns.resume && (d.touch.deleteImg(a.btns.resume.id), a.btns.resume = null, d.touch.deleteImg(a.btns.exit2.id), a.btns.exit2 = null)
  952. };
  953. a.showPauseDialog = function () {
  954. a.ctx.drawImage(a.buffers.pause_bg, 0, 60 * a.scale << 0);
  955. a.drawNum(a.score, 0.1 * a.width << 0, 130 * a.scale << 0, a.buffers.num3, 47, 60, 0, a.scale);
  956. a.drawBtns(a.btns.resume);
  957. a.drawBtns(a.btns.exit2)
  958. };
  959. a.createClueDialog =
  960. function () {
  961. a.btns.clue1 || (a.btns.clue1 = {
  962. id: a.id++,
  963. name: "clue1",
  964. img: d.getImage("clue1"),
  965. x: (a.width - 156) / 2 + 78,
  966. y: a.height - 32,
  967. w: 156,
  968. h: 63
  969. }, d.touch.create(a.btns.clue1, !0, !1))
  970. };
  971. a.delClueDialog = function () {
  972. a.btns.clue1 && (d.touch.deleteImg(a.btns.clue1.id), a.btns.clue1 = null)
  973. };
  974. a.showClueDialog = function () {
  975. a.btns.clue1 && a.ctx.drawImage(a.btns.clue1.img, a.btns.clue1.x - 78, a.btns.clue1.y - 32)
  976. };
  977. a.sinaRank = function (a) {
  978. d.ajax({
  979. type: "get",
  980. dataType: "html",
  981. url: "" +
  982. d.request.get("wyx_session_key") + "&rank_id=1&value=" + a + "&platform_id=2",
  983. before: function () {},
  984. success: function (a) {
  985. console.log(a)
  986. },
  987. error: function () {},
  988. complete: function () {
  989. isSend = !1
  990. }
  991. })
  992. };
  993. a.sinaAchieve = function (a) {
  994. d.ajax({
  995. type: "get",
  996. dataType: "html",
  997. url: "",
  998. before: function () {},
  999. success: function (a) {
  1000. console.log(a)
  1001. },
  1002. error: function () {},
  1003. complete: function () {
  1004. isSend = !1
  1005. }
  1006. })
  1007. };
  1008. d.touch.click(function (b) {
  1009. switch (b.name) {
  1010. case "ballon":
  1011. a.addToHouse(b);
  1012. break;
  1013. case "coin":
  1014. a.collectCoin(b);
  1015. break;
  1016. case "bomb":
  1017. b.exploded = !0;
  1018. b.coin = 1;
  1019. break;
  1020. case "sound":
  1021. a.volume = !a.volume;
  1022. a.musicControl();
  1023. break;
  1024. case "clue1":
  1025. a.delClueDialog();
  1026. break;
  1027. case "pause":
  1028. // updateShare(a.score);Play68.setRankingScoreDesc(a.score);
  1029. a.paused = !0;
  1030. a.createPauseDialog();
  1031. break;
  1032. case "resume":
  1033. a.delPauseDialog();
  1034. a.paused = !1;
  1035. break;
  1036. case "exit2":
  1037. a.delPauseDialog();
  1038. a.delGamePage();
  1039. a.init();
  1040. a.createLogoPage();
  1041. a.state = 0;
  1042. break;
  1043. case "begin":
  1044. document.getElementById('tips').style.display = "block";
  1045. a.delLogoPage();
  1046. a.delClueDialog();
  1047. a.createHelpPage();
  1048. a.state = 1;
  1049. break;
  1050. case "achieve":
  1051. // Play68.goHome();
  1052. break;
  1053. case "exit1":
  1054. a.music.bg.pause();
  1055. window.close();
  1056. break;
  1057. case "help":
  1058. a.delHelpPage();
  1059. a.createGamePage();
  1060. a.state = 2;
  1061. a.paused = !1;
  1062. break;
  1063. case "achieve_bg":
  1064. case "next2":
  1065. a.delAchievePage(), a.createLogoPage(), a.state = 0
  1066. }
  1067. });
  1068. d.touch.draged(function (b) {
  1069. "ballon" == b.name ? a.addToHouse(b) : "bomb" == b.name ? (b.exploded = !0, b.coin = 1) : "house" == b.name && 0 < a.house.ballons && (a.housePos = a.house.y);
  1070. a.dragFlag = !0
  1071. });
  1072. d.touch.touchStart(function () {
  1073. a.touchTime =
  1074. (new Date)
  1075. .getTime();
  1076. a.startX = d.touch.getStartPos()
  1077. .x;
  1078. a.dragFlag = !1
  1079. });
  1080. d.touch.touchEnd(function () {
  1081. 1E3 > (new Date)
  1082. .getTime() - a.touchTime && d.touch.getReleasePos()
  1083. .x - a.startX > a.width / 2 && !a.dragFlag && 0 == a.invincible && "swiperight" == d.touch.getGesture() && 100 <= a.money && (a.invincible = 60, a.money -= 100, a.achieveCount[0]++)
  1084. });
  1085. d.setRunFrequency(50);
  1086. a.newGame1 = !0;
  1087. a.newGame2 = !0;
  1088. a.state = 0;
  1089. a.id = 0;
  1090. a.scaleTmp = 0;
  1091. a.volume = !0;
  1092. a.music = {};
  1093. a.initMusic();
  1094. a.buffer = [];
  1095. a.buffers = {};
  1096. a.btns = {};
  1097. a.newGame = !0;
  1098. /* if (window.innerHeight >
  1099. window.innerWidth) */ try {
  1100. a.initCanvas(), a.scaleTmp = a.scale, a.initBuffer(), a.initSize(), a.land = {
  1101. id: "land",
  1102. name: "land",
  1103. img: a.buffers.land,
  1104. altitude: 0,
  1105. x: a.width / 2 << 0,
  1106. y: a.height - 33 * a.scale,
  1107. w: 320 * a.scale,
  1108. h: 67 * a.scale
  1109. }, a.house = {
  1110. id: "house",
  1111. name: "house",
  1112. img: a.buffers.house,
  1113. altitude: 0,
  1114. target: 0,
  1115. x: a.width / 2 << 0,
  1116. y: a.height - 57 * a.scale,
  1117. w: 116 * a.scale,
  1118. h: 101 * a.scale,
  1119. ballons: 0,
  1120. timer: 0
  1121. }, d.touch.create(a.house, !1, !0), a.init(), a.createLogoPage(), a.showLogoPage(), a.newGame = !1
  1122. } catch (m) {
  1123. window.location.reload(!1)
  1124. } /* else a.clue = !0, a.showClue(); */
  1125. d.run(function () {
  1126. if (a.clue) a.showClue();
  1127. else switch (a.state) {
  1128. case 0:
  1129. a.showLogoPage();
  1130. break;
  1131. case 1:
  1132. a.showHelpPage();
  1133. break;
  1134. case 2:
  1135. a.refresh();
  1136. break;
  1137. case 3:
  1138. a.showAchievePage()
  1139. }
  1140. })
  1141. })
  1142. };