123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143 |
- function main() {
- jsGame.initImage([{
- id: "a",
- src: "img/a.png"
- }, {
- id: "ballon",
- src: "img/ballon.png"
- }, {
- id: "bomb",
- src: "img/bomb.png"
- }, {
- id: "bombfire",
- src: "img/bombfire.png"
- }, {
- id: "num1",
- src: "img/num1.png"
- }, {
- id: "num2",
- src: "img/num2.png"
- }, {
- id: "num3",
- src: "img/num3.png"
- }, {
- id: "explode",
- src: "img/explode.png"
- }, {
- id: "cloud",
- src: "img/cloud.png"
- }, {
- id: "coin",
- src: "img/coin.png"
- }, {
- id: "house",
- src: "img/house.png"
- }, {
- id: "cover",
- src: "img/cover.png"
- }, {
- id: "land",
- src: "img/land.png"
- }, {
- id: "bg",
- src: "img/bg.png"
- }, {
- id: "title",
- src: "img/title.png"
- }, {
- id: "statebar",
- src: "img/statebar.png"
- }, {
- id: "clue",
- src: "img/clue.png"
- }, {
- id: "clue1",
- src: "img/clue1.png"
- }, {
- id: "clue_coin",
- src: "img/clue-coin.png"
- }, {
- id: "clue_finger",
- src: "img/clue-finger.png"
- }, {
- id: "sound1",
- src: "img/sound1.png"
- }, {
- id: "sound2",
- src: "img/sound2.png"
- }, {
- id: "achieve",
- src: "img/achieve.png"
- }, {
- id: "achieve_dialog",
- src: "img/achieve-dialog.png"
- }, {
- id: "lock",
- src: "img/lock.png"
- }, {
- id: "back",
- src: "img/back.png"
- }, {
- id: "begin",
- src: "img/begin.png"
- }, {
- id: "exit1",
- src: "img/exit1.png"
- }, {
- id: "exit2",
- src: "img/exit2.png"
- }, {
- id: "rank",
- src: "img/rank.png"
- }, {
- id: "logo1",
- src: "img/logo1.png"
- }, {
- id: "logo2",
- src: "img/logo2.png"
- }, {
- id: "more",
- src: "img/more.png"
- }, {
- id: "help",
- src: "img/help.png"
- }, {
- id: "next2",
- src: "img/next2.png"
- }, {
- id: "pause",
- src: "img/pause.png"
- }, {
- id: "pause_bg",
- src: "img/pause-bg.png"
- }, {
- id: "resume",
- src: "img/resume.png"
- }, {
- id: "achieve0",
- src: "img/achieve0.png"
- }, {
- id: "achieve1",
- src: "img/achieve1.png"
- }, {
- id: "achieve2",
- src: "img/achieve2.png"
- }, {
- id: "achieve3",
- src: "img/achieve3.png"
- }, {
- id: "achieve4",
- src: "img/achieve4.png"
- }, {
- id: "achieve5",
- src: "img/achieve5.png"
- }, {
- id: "achieve6",
- src: "img/achieve6.png"
- }]);
- var a = {
- initTouch: function () {
- jsGame.touch.init(!0)
- },
- initCanvas: function () {
- a.width = window.innerWidth;
- if(a.width > 640) a.width = 640;
- a.height = window.innerHeight;
- //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;
- jsGame.canvas.screen.setWidth(a.width);
- jsGame.canvas.screen.setHeight(a.height);
- a.scale = a.width / 320;
- a.canvas = document.getElementById("jsGameScreen");
- a.ctx = a.canvas.getContext("2d");
- a.ctx.strokeStyle =
- "white";
- a.ctx.lineWidth = 3 * a.scale + 0.5 << 0;
- a.initTouch()
- }
- };
- a.initCanvas();
- a.drawNum = function (d, m, b, f, c, e, g, l) {
- var k = c * l << 0;
- e = e * l << 0;
- if (0 >= d) a.ctx.drawImage(f, 0, 0, k, e, m, b, k, e);
- else {
- var h = d / 10 << 0,
- n = 0;
- d %= 10;
- for (var p = []; h || d;) p[n++] = d, d = h % 10, h = h / 10 << 0;
- d = p.reverse();
- h = d.length;
- 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)
- }
- };
- jsGame.initImageCallBack(function (d, m) {
- if (d >= m) jsGame.gameFlow.run();
- else try {
- var b = d / m,
- b = 1 < b ? 1 : b;
- a.ctx.fillStyle = "#8dab81";
- a.ctx.fillRect(0, 0, a.width, a.height);
- a.ctx.drawImage(jsGame.getImage("a"), 0, 0, 250, 81, (a.width - 250) / 2, (a.height - 81) / 2, 250, 81);
- a.ctx.drawImage(jsGame.getImage("a"), 2, 86, 246 * b, 10, (a.width - 246) / 2, (a.height - 81) / 2 + 51, 246 * b, 10)
- } catch (f) {}
- });
- jsGame.pageLoad(function (d) {
- a.addItem = function (b, f, c, e, g, l, k, h, n) {
- for (var p = c.length, m = p; m < p + f; m++) c[m] = {
- id: a.id++,
- name: b,
- img: e,
- altitude: a.house.altitude,
- x: a.id % (0.7 * a.width / g << 0) * g * 1.4 + g / 2,
- y: -200 * a.scale,
- w: g,
- h: l,
- v: k
- }, (h || n) && d.touch.create(c[m], h, n)
- };
- a.delItem = function (a, f) {
- d.touch.deleteImg(f);
- for (var c =
- a.length, e = 0; e < c; e++)
- if (a[e].id == f) {
- a.splice(e, 1);
- break
- }
- };
- a.addBallon = function (b) {
- var f = a.ballons.length,
- c = 58 * a.scale << 0;
- a.addItem("ballon", b, a.ballons, a.buffers.ballon, 55 * a.scale << 0, c, a.height / 120, !0, !0);
- 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
- };
- a.delBallon = function (b) {
- a.delItem(a.ballons, b)
- };
- a.addBomb = function (b) {
- var f = a.bombs.length;
- a.addItem("bomb", b, a.bombs, a.buffers.bomb, 60 * a.scale << 0, 75 * a.scale <<
- 0, -(a.height / 150), !0, !0);
- 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
- };
- a.delBomb = function (b) {
- a.delItem(a.bombs, b)
- };
- a.addCloud = function (b) {
- var f = a.clouds.length;
- a.addItem("cloud", b, a.clouds, a.buffers.cloud1, 135 * a.scale << 0, 84 * a.scale << 0, 0, !1, !1);
- 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) {
- case 0:
- a.clouds[c].v = a.width / 100 << 0;
- break;
- case 1:
- a.clouds[c].img = a.buffers.cloud2;
- a.clouds[c].v = a.width / 200 << 0;
- a.clouds[c].w = 94.5 * a.scale << 0;
- a.clouds[c].h = 58.8 * a.scale << 0;
- break;
- case 2:
- 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
- }
- };
- a.delCloud = function (b) {
- a.delItem(a.clouds, b)
- };
- a.addCoin = function (b, f, c, e) {
- var d = a.coins.length;
- a.addItem("coin", b, a.coins, a.buffers.coin, 51 * a.scale << 0, 51 * a.scale << 0, -(a.height / 100), !0, !1);
- for (var l = d; l < d + b; l++) null != f && null != c && null != e ? (a.coins[l].altitude =
- f, a.coins[l].x = c, a.coins[l].y = e) : (a.coins[l].altitude += a.height, a.coins[l].colected = !1)
- };
- a.delCoin = function (b) {
- a.delItem(a.coins, b)
- };
- a.showClue = function () {
- a.ctx.fillStyle = "white";
- a.ctx.fillRect(0, 0, a.width, a.height);
- a.ctx.drawImage(d.getImage("clue"), (a.width - 122) / 2, (a.height - 145) / 2)
- };
- a.initMusic = function () {
- a.music.bg = document.createElement("audio");
- a.music.bg.setAttribute("src", "sound/bgsound.mp3");
- a.music.bg.setAttribute("preload", !0);
- a.music.bg.setAttribute("autoplay", !0);
- a.music.bg.setAttribute("loop", !0);
- a.music.bg.load();
- a.music.bg.addEventListener("canplaythrough", function () {
- a.music.bg.play()
- }, !0);
- a.music.drop = document.createElement("audio");
- a.music.drop.setAttribute("src", "sound/drop.mp3");
- a.music.drop.setAttribute("preload", !0);
- a.music.drop.load();
- a.music.ring = [];
- 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();
- a.music.bomb = [];
- for (b = a.music.bombIndex =
- 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()
- };
- a.musicControl = function () {
- if (a.volume) a.music.bg.play();
- else {
- a.music.bg.pause();
- a.music.drop.pause();
- for (var b = a.music.ring.length, f = 0; f < b; f++) a.music.ring[f].pause();
- b = a.music.bomb.length;
- for (f = 0; f < b; f++) a.music.bomb[f].pause()
- }
- };
- a.addBuffer = function (b, f, c, e) {
- c = c + 0.5 << 0;
- e = e + 0.5 << 0;
- a.buffer[b] = null;
- a.buffer[b] = document.createElement("canvas");
- a.buffer[b].width = c;
- a.buffer[b].height = e;
- a.buffer[b].getContext("2d")
- .drawImage(d.getImage(f), 0, 0, c, e)
- };
- a.initBuffer = function () {
- var b = 0;
- a.addBuffer(b, "house", 116 * a.scale, 101 * a.scale);
- a.buffers.house = null;
- a.buffers.house = a.buffer[b++];
- a.addBuffer(b, "land", 320 * a.scale, 67 * a.scale);
- a.buffers.land = null;
- a.buffers.land = a.buffer[b++];
- a.addBuffer(b, "ballon", 275 * a.scale, 58 * a.scale);
- a.buffers.ballon = null;
- a.buffers.ballon = a.buffer[b++];
- a.addBuffer(b, "bomb", 60 * a.scale, 75 * a.scale);
- a.buffers.bomb = null;
- a.buffers.bomb =
- a.buffer[b++];
- a.addBuffer(b, "bombfire", 30 * a.scale, 15 * a.scale);
- a.buffers.bombfire = null;
- a.buffers.bombfire = a.buffer[b++];
- a.addBuffer(b, "num1", 600 * a.scale, 75 * a.scale);
- a.buffers.num1 = null;
- a.buffers.num1 = a.buffer[b++];
- a.addBuffer(b, "num2", 180 * a.scale, 19 * a.scale);
- a.buffers.num2 = null;
- a.buffers.num2 = a.buffer[b++];
- a.addBuffer(b, "num3", 470 * a.scale, 60 * a.scale);
- a.buffers.num3 = null;
- a.buffers.num3 = a.buffer[b++];
- a.addBuffer(b, "cloud", 135 * a.scale, 84 * a.scale);
- a.buffers.cloud1 = null;
- a.buffers.cloud1 = a.buffer[b++];
- a.addBuffer(b,
- "cloud", 94.5 * a.scale, 58.8 * a.scale);
- a.buffers.cloud2 = null;
- a.buffers.cloud2 = a.buffer[b++];
- a.addBuffer(b, "cloud", 54 * a.scale, 33.6 * a.scale);
- a.buffers.cloud3 = null;
- a.buffers.cloud3 = a.buffer[b++];
- a.addBuffer(b, "coin", 50 * a.scale, 51 * a.scale);
- a.buffers.coin = null;
- a.buffers.coin = a.buffer[b++];
- a.addBuffer(b, "cover", 213 * a.scale, 212 * a.scale);
- a.buffers.cover = null;
- a.buffers.cover = a.buffer[b++];
- a.addBuffer(b, "bg", 320 * a.scale, 1440 * a.scale);
- a.buffers.bg = null;
- a.buffers.bg = a.buffer[b++];
- a.addBuffer(b, "explode", 603 * a.scale,
- 163 * a.scale);
- a.buffers.explode = null;
- a.buffers.explode = a.buffer[b++];
- a.addBuffer(b, "statebar", 320 * a.scale, 60 * a.scale);
- a.buffers.statebar = null;
- a.buffers.statebar = a.buffer[b++];
- a.addBuffer(b, "title", 320 * a.scale, 134 * a.scale);
- a.buffers.title = null;
- a.buffers.title = a.buffer[b++];
- a.addBuffer(b, "sound1", 88 * a.scale, 38 * a.scale);
- a.buffers.sound1 = null;
- a.buffers.sound1 = a.buffer[b++];
- a.addBuffer(b, "sound2", 88 * a.scale, 38 * a.scale);
- a.buffers.sound2 = null;
- a.buffers.sound2 = a.buffer[b++];
- a.addBuffer(b, "achieve", 148 * a.scale,
- 68 * a.scale);
- a.buffers.achieve = null;
- a.buffers.achieve = a.buffer[b++];
- a.addBuffer(b, "achieve_dialog", 320 * a.scale, 480 * a.scale);
- a.buffers.achieve_dialog = null;
- a.buffers.achieve_dialog = a.buffer[b++];
- a.addBuffer(b, "lock", 73 * a.scale, 72 * a.scale);
- a.buffers.lock = null;
- a.buffers.lock = a.buffer[b++];
- a.addBuffer(b, "back", 148 * a.scale, 68 * a.scale);
- a.buffers.back = null;
- a.buffers.back = a.buffer[b++];
- a.addBuffer(b, "begin", 382 * a.scale, 185 * a.scale);
- a.buffers.begin = null;
- a.buffers.begin = a.buffer[b++];
- a.addBuffer(b, "exit1", 88 *
- a.scale, 38 * a.scale);
- a.buffers.exit1 = null;
- a.buffers.exit1 = a.buffer[b++];
- a.addBuffer(b, "exit2", 170 * a.scale, 80 * a.scale);
- a.buffers.exit2 = null;
- a.buffers.exit2 = a.buffer[b++];
- a.addBuffer(b, "rank", 148 * a.scale, 68 * a.scale);
- a.buffers.rank = null;
- a.buffers.rank = a.buffer[b++];
- a.addBuffer(b, "more", 148 * a.scale, 68 * a.scale);
- a.buffers.more = null;
- a.buffers.more = a.buffer[b++];
- a.addBuffer(b, "logo1", 320 * a.scale, 480 * a.scale);
- a.buffers.logo1 = null;
- a.buffers.logo1 = a.buffer[b++];
- a.addBuffer(b, "logo2", 320 * a.scale, 182 * a.scale);
- a.buffers.logo2 = null;
- a.buffers.logo2 = a.buffer[b++];
- a.addBuffer(b, "help", 306 * a.scale, 441 * a.scale);
- a.buffers.help = null;
- a.buffers.help = a.buffer[b++];
- a.addBuffer(b, "next2", 112 * a.scale, 36 * a.scale);
- a.buffers.next2 = null;
- a.buffers.next2 = a.buffer[b++];
- a.addBuffer(b, "pause", 88 * a.scale, 38 * a.scale);
- a.buffers.pause = null;
- a.buffers.pause = a.buffer[b++];
- a.addBuffer(b, "pause_bg", 321 * a.scale, 420 * a.scale);
- a.buffers.pause_bg = null;
- a.buffers.pause_bg = a.buffer[b++];
- a.addBuffer(b, "resume", 170 * a.scale, 80 * a.scale);
- a.buffers.resume =
- null;
- a.buffers.resume = a.buffer[b++]
- };
- a.initSize = function () {
- var b = a.scale;
- a.scales = {
- scope1: a.height + 50 * b << 0,
- scope2: a.width + 50 * b << 0,
- font2: (20 * b << 0) + "px Arial",
- coin1: 50 * b << 0,
- coin2: 40 * b << 0,
- statusbar1: 0.1 * a.width << 0
- };
- a.explode && (a.explode.w = 201 * b << 0, a.explode.h = 163 * b << 0);
- a.explodeDis = 50 * b << 0;
- a.cover = {
- id: "cover",
- img: a.buffers.cover,
- w: 213 * b << 0,
- h: 212 * b << 0
- };
- 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);
- a.house && (a.house.x = a.width / 2 <<
- 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);
- if (a.ballons)
- 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;
- 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 =
- 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));
- 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);
- a.btns.pause && (a.btns.sound.x = 235 * a.scale <<
- 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);
- 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 <<
- 0, a.btns.exit2.w = 85 * a.scale << 0, a.btns.exit2.h = 80 * a.scale << 0, a.btns.exit2.img = a.buffers.exit2)
- };
- a.initLocalStorage = function () {
- try {
- var b = localStorage.getItem("flyhouse");
- b ? (b = JSON.parse(b), a.achieve = b.achieve) : a.localStorage()
- } catch (f) {
- console.log(f)
- }
- };
- a.localStorage = function () {
- try {
- localStorage.setItem("flyhouse", JSON.stringify({
- achieve: a.achieve
- }))
- } catch (b) {
- console.log(b)
- }
- };
- a.init = function () {
- a.initCanvas();
- var b = 1440 * a.scale - a.height << 0;
- a.bg = {
- init: b,
- current: b,
- target: b
- };
- a.timer = 20;
- a.touchTime =
- 0;
- a.startX = 0;
- a.paused = !0;
- a.money = 0;
- a.ballons = [];
- a.bombs = [];
- a.clouds = [];
- a.coins = [];
- a.explodes = [];
- a.explode = {
- id: "explode",
- img: a.buffers.explode,
- w: 201 * a.scale << 0,
- h: 163 * a.scale << 0,
- index: 0
- };
- a.invincible = 0;
- a.dragFlag = !1;
- a.offsetX = 0;
- a.score = 0;
- a.level = 1;
- a.clue = !1;
- a.shake = 0;
- a.housePos = 0;
- a.land.img = a.buffers.land;
- a.land.altitude = 0;
- a.land.x = a.width / 2 << 0;
- a.land.y = a.height - 33 * a.scale;
- a.land.w = 320 * a.scale;
- a.land.h = 67 * a.scale;
- a.house.img = a.buffers.house;
- a.house.altitude = 0;
- a.house.target = 0;
- a.house.x = a.width / 2 << 0;
- a.house.y = a.height - 57 * a.scale;
- a.house.w = 116 * a.scale;
- a.house.h = 101 * a.scale;
- a.house.ballons = 0;
- a.house.timer = 0;
- a.achieve = [!1, !1, !1, !1, !1, !1, !1, !1, !1, !1];
- a.achieveCount = [0, 0];
- a.achieveTimer = 0;
- a.achieveFlag = 0;
- a.initLocalStorage();
- a.clueTimer1 = 0;
- a.clueTimer2 = 0; - 1 == navigator.userAgent.toLowerCase()
- .indexOf("iphone") && -1 == navigator.userAgent.toLowerCase()
- .indexOf("ipod") || window.navigator.standalone || a.createClueDialog()
- };
- a.refresh = function () {
- if (a.paused) a.ctx.drawImage(a.buffers.statebar, 0, 0), a.drawNum(a.house.altitude,
- 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();
- else {
- var b = a.ctx;
- try {
- b.drawImage(a.buffers.bg, 0, a.bg.current, a.width, a.height, 0, 0, a.width, a.height)
- } catch (f) {}
- for (var c = a.clouds.length, e = 0; e < c; e++) {
- var g = a.clouds[e];
- !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)
- }
- 0 == a.house.altitude && b.drawImage(a.buffers.land, a.width /
- 2 - a.land.w / 2 << 0, a.height - a.land.h << 0);
- b.drawImage(a.buffers.house, a.house.x - a.house.w / 2 << 0, a.house.y - a.house.h / 2 << 0);
- if (c = a.ballons.length)
- for (var g = a.house.x << 0, l = a.house.y - 0.31 * a.house.h << 0, e = 0; e < c; e++) {
- var k = a.ballons[e];
- k.tied && (d.canvas.beginPath(), d.canvas.moveTo(g, l), d.canvas.lineTo(k.x, k.y + 0.45 * k.h), d.canvas.stroke());
- 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)
- }
- 0 < a.invincible && b.drawImage(a.buffers.cover, a.house.x - a.cover.w / 2 << 0, a.house.y -
- a.cover.h / 2 << 0);
- c = a.coins.length;
- 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);
- c = a.bombs.length;
- g = a.buffers.bomb;
- l = a.buffers.bombfire;
- k = a.buffers.num1;
- for (e = 0; e < c; e++) {
- var h = a.bombs[e];
- if (h && !(-50 > h.y || h.y > a.scales.scope1 || -50 > h.x || h.x > a.scales.scope2)) {
- b.drawImage(g, h.x - h.w / 2 << 0, h.y - h.h / 2 << 0);
- var n = 0,
- m = 15 * a.scale << 0;
- switch (h.flash) {
- case 0:
- h.flash = 1;
- break;
- case 1:
- n = m, h.flash = 0
- }
- b.drawImage(l, n, 0, m, m,
- h.x << 0, h.y - h.h / 2 << 0, m, m);
- a.drawNum(h.timer, h.x - h.w / 2 << 0, h.y - h.h / 2 << 0, k, 60, 75, 0, a.scale)
- }
- }
- a.update();
- if (0 < a.achieveTimer) {
- a.achieveTimer--;
- b.drawImage(d.getImage("achieve6"), 0.15 * a.width << 0, 70 * a.scale << 0, 100 * a.scale << 0, 19 * a.scale << 0);
- e = c = 0;
- switch (a.achieveFlag) {
- case 0:
- c = 79 * a.scale << 0;
- e = 19 * a.scale << 0;
- break;
- case 1:
- c = 79 * a.scale << 0;
- e = 19 * a.scale << 0;
- break;
- case 2:
- c = 99 * a.scale << 0;
- e = 19 * a.scale << 0;
- break;
- case 3:
- c = 59 * a.scale << 0;
- e = 19 * a.scale << 0;
- break;
- case 4:
- c = 99 * a.scale << 0;
- e = 19 * a.scale << 0;
- break;
- case 5:
- c = 99 * a.scale <<
- 0, e = 19 * a.scale << 0
- }
- b.drawImage(d.getImage("achieve" + a.achieveFlag), 0.55 * a.width << 0, 70 * a.scale << 0, c, e)
- }
- 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));
- 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));
- b.drawImage(a.buffers.statebar, 0, 0);
- a.drawNum(a.house.altitude, 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.showGamePage()
- }
- };
- a.update = function () {
- a.timer--;
- 0 >= a.timer && (a.timer = 20);
- 0 < a.invincible && a.invincible--;
- a.updateCloud();
- a.updateHouse();
- a.updateBallon();
- a.updateCoin();
- a.updateBomb();
- a.updateExplode();
- a.updateScore()
- };
- a.updateAchieve = function () {
- !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(),
- 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))
- };
- a.updateScore = function () {
- var b = a.house.altitude + a.money;
- b > a.score && (a.score = b);
- };
- a.updateHouse = function () {
- if (0 <
- a.house.timer) {
- if (20 < a.house.timer) {
- var b = (a.house.target - a.house.altitude) / (a.house.timer - 20);
- a.house.altitude = a.house.altitude + b << 0;
- a.house.y -= b / 5
- } 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;
- a.house.timer--
- } else a.house.altitude = a.house.target, a.housePos = a.house.y;
- a.house.target != a.house.altitude ? (0 == a.house.target && (a.house.x -=
- (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)
- };
- a.updateBallon = function () {
- var b = a.ballons.length;
- (1 > b - a.house.ballons || b - a.house.ballons < 2 * a.level && !(a.timer % 10) && 0.2 > Math.random()) && a.addBallon(1);
- for (var f = 0; f < b; f++) a.ballons[f].tied &&
- (a.ballons[f].timer = 10);
- for (f = 0; f < b; f++) {
- var c = a.ballons[f];
- 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--);
- 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--;
- c.exploded && (a.explodes[a.explodes.length] = {
- x: c.x,
- y: c.y,
- timer: 10
- }, c.tied && (c.tied = !1, a.house.ballons = a.getBallonsNum(), 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.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))
- }
- };
- a.getBallonsNum = function () {
- for (var b = a.ballons.length, f = 0, c = 0; c < b; c++) a.ballons[c].tied && f++;
- return f
- };
- a.addToHouse = function (b) {
- 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,
- 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))
- };
- a.updateBomb = function () {
- var b = a.bombs.length;
- (1 > b || 0 == a.timer % 10 && b < 3 * a.level && Math.random() < 0.2 * a.level) && a.addBomb(1);
- for (var f = 0; f < b; f++) {
- var c = a.bombs[f];
- if (c) {
- c.selected ? c.altitude = a.house.altitude + a.height - c.y : (c.altitude += c.v, c.altitude <<= 0, c.y = a.height -
- c.altitude + a.house.altitude);
- if (0 < a.invincible)
- 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;
- else {
- 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);
- e = a.ballons.length;
- 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)
- } else {
- e = a.bombs.length;
- 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);
- e = a.ballons.length;
- 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)
- }
- 20 == a.timer && c.timer--;
- if (c.exploded || 1 > c.timer) a.explodes[a.explodes.length] = {
- x: c.x,
- y: c.y,
- timer: 10
- }, 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(),
- a.music.bombIndex = (a.music.bombIndex + 1) % 5);
- if (c.y > 2 * a.height || c.y < -a.height) a.delBomb(c.id), f--, b--
- }
- }
- };
- a.updateCoin = function () {
- var b = a.coins.length;
- (1 > b || 0 == a.timer % 13 && b < 2 * a.level && Math.random() < 2 * a.level) && a.addCoin(1);
- for (var d = 0; d < b; d++) {
- var c = a.coins[d];
- if (c.colected) 0 < c.timer-- ? (c.x -= c.vx, c.y -= c.vy) : (a.delCoin(c.id), d--, b--);
- 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--
- }
- };
- a.collectCoin = function (b) {
- b.colected ||
- (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));
- a.newGame1 && 100 <= a.money && (a.newGame1 = !1, a.clueTimer1 = 60)
- };
- a.updateCloud = function () {
- if (!(5E3 < a.house.altitude)) {
- var b = a.clouds.length;
- 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 %
- 10 && 5 > b && 0.5 < Math.random() && a.addCloud(1);
- for (var d = 0; d < b; d++) {
- var c = a.clouds[d];
- c.x = (c.x + c.v) % (2 * a.width);
- c.y = a.height - c.altitude + a.house.altitude;
- if (c.y > 2 * a.height || c.y < -a.height) a.delCloud(c.id), d--, b--
- }
- }
- };
- a.updateExplode = function () {
- for (var b = a.explodes.length, d = a.explode, c = 0; c < b; c++) {
- var e = a.explodes[c];
- e.timer--;
- 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,
- 1), c--, b--)
- }
- };
- window.onorientationchange = function () {
- switch (window.orientation) {
- case 0:
- case 180:
- a.initCanvas();
- a.clue = !1;
- if (a.newGame) try {
- a.initCanvas(), a.scaleTmp = a.scale, a.initBuffer(), a.initSize(), a.land = {
- id: "land",
- name: "land",
- img: a.buffers.land,
- altitude: 0,
- x: a.width / 2 << 0,
- y: a.height - 33 * a.scale,
- w: 320 * a.scale,
- h: 67 * a.scale
- }, a.house = {
- id: "house",
- name: "house",
- img: a.buffers.house,
- altitude: 0,
- target: 0,
- x: a.width / 2 << 0,
- y: a.height - 57 * a.scale,
- w: 116 * a.scale,
- h: 101 * a.scale,
- ballons: 0,
- timer: 0
- }, d.touch.create(a.house, !1, !0), a.init(), a.createLogoPage(), a.showLogoPage(), a.newGame = !1
- } catch (b) {
- window.location.reload(!1)
- }
- break;
- case -90:
- case 90:
- a.initCanvas(), a.clue = !0, a.showClue()
- }
- };
- a.drawBtns = function (b) {
- var d = 0;
- b.selected && (d = b.w);
- 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)
- };
- a.createLogoPage = function () {
- if (!(a.btns.begin || a.btns.achieve || a.btns.sound)) {
- a.btns.begin = {
- id: a.id++,
- name: "begin",
- img: a.buffers.begin,
- x: 160 * a.scale << 0,
- y: 250 * a.scale << 0,
- w: 191 * a.scale << 0,
- h: 185 * a.scale << 0
- };
- d.touch.create(a.btns.begin, !0, !1);
- a.btns.achieve = {
- id: a.id++,
- name: "achieve",
- img: a.buffers.achieve,
- x: 50 * a.scale << 0,
- y: 350 * a.scale << 0,
- w: 74 * a.scale << 0,
- h: 68 * a.scale << 0
- };
- d.touch.create(a.btns.achieve, !0, !1);
- a.btns.sound = {
- id: a.id++,
- name: "sound",
- img: a.buffers.sound1,
- x: 285 * a.scale << 0,
- y: 22 * a.scale << 0,
- w: 44 * a.scale << 0,
- h: 38 * a.scale << 0
- };
- d.touch.create(a.btns.sound, !0, !1);
- a.logoBallons = [];
- for (var b = 0; 7 > b; b++) a.logoBallons[b] = {
- x: Math.random() * a.width * 0.9 + 55 * a.scale,
- y: a.height * (Math.random() + 1),
- v: 3 * (Math.random() + 1) * a.scale,
- color: (100 * Math.random() <<
- 0) % 5
- }
- }
- };
- a.delLogoPage = function () {
- 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)
- };
- a.showLogoPage = function () {
- a.ctx.drawImage(a.buffers.logo1, 0, 0);
- 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));
- for (var b = 55 * a.scale << 0, d = 58 * a.scale << 0, c = 0; 7 > c; c++) {
- var e = a.logoBallons[c];
- e.y -= e.v;
- 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);
- a.ctx.drawImage(a.buffers.ballon, 55 * e.color * a.scale << 0, 0, b, d, e.x, e.y, b, d)
- }
- a.ctx.drawImage(a.buffers.title, 0, 0);
- a.btns.sound.img = a.volume ? a.buffers.sound1 : a.buffers.sound2;
- a.drawBtns(a.btns.sound);
- a.drawBtns(a.btns.begin);
- a.drawBtns(a.btns.achieve);
- //a.showClueDialog()
- };
- a.createAchievePage = function () {
- a.btns.achieve_bg || (a.btns.achieve_bg = {
- id: a.id++,
- name: "achieve_bg",
- img: null,
- x: a.width / 2 << 0,
- y: a.height / 2 << 0,
- w: a.width,
- h: a.height
- }, d.touch.create(a.btns.achieve_bg, !0, !1), a.btns.next2 = {
- id: a.id++,
- name: "next2",
- img: a.buffers.next2,
- x: 0.15 * a.width << 0,
- y: 25 * a.scale << 0,
- w: 56 * a.scale << 0,
- h: 36 * a.scale << 0
- }, d.touch.create(a.btns.next2, !0, !1))
- };
- a.delAchievePage = function () {
- 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)
- };
- a.showAchievePage = function () {
- a.ctx.drawImage(a.buffers.bg,
- 0, 1440 * a.scale - a.height << 0, a.width, a.height, 0, 0, a.width, a.height);
- a.ctx.drawImage(a.buffers.achieve_dialog, 0, 0);
- for (var b = 0; 6 > b; b++) switch (b) {
- case 0:
- !a.achieve[b] && a.ctx.drawImage(a.buffers.lock, 47 * a.scale << 0, 75 * a.scale << 0);
- break;
- case 1:
- !a.achieve[b] && a.ctx.drawImage(a.buffers.lock, 47 * a.scale << 0, 210 * a.scale << 0);
- break;
- case 2:
- !a.achieve[b] && a.ctx.drawImage(a.buffers.lock, 47 * a.scale << 0, 345 * a.scale << 0);
- break;
- case 3:
- !a.achieve[b] && a.ctx.drawImage(a.buffers.lock, 198 * a.scale << 0, 75 * a.scale << 0);
- break;
- case 4:
- !a.achieve[b] &&
- a.ctx.drawImage(a.buffers.lock, 198 * a.scale << 0, 210 * a.scale << 0);
- break;
- case 5:
- !a.achieve[b] && a.ctx.drawImage(a.buffers.lock, 198 * a.scale << 0, 345 * a.scale << 0)
- }
- a.drawBtns(a.btns.next2)
- };
- a.createHelpPage = function () {
- a.btns.help || (a.btns.help = {
- id: a.id++,
- name: "help",
- img: null,
- x: a.width / 2 << 0,
- y: a.height / 2 << 0,
- w: a.width,
- h: a.height
- }, d.touch.create(a.btns.help, !0, !1))
- };
- a.delHelpPage = function () {
- a.btns.help && (d.touch.deleteImg(a.btns.help.id), a.btns.help = null)
- };
- a.showHelpPage = function () {
- a.ctx.fillStyle = "#8AAD82";
- a.ctx.fillRect(0,
- 0, a.width, a.height);
- a.ctx.drawImage(a.buffers.help, (a.width - 306 * a.scale) / 2, (a.height - 441 * a.scale) / 2)
- };
- a.createGamePage = function () {
- a.btns.sound || a.btns.pause || (a.btns.sound = {
- id: a.id++,
- name: "sound",
- img: a.buffers.sound1,
- x: 235 * a.scale << 0,
- y: 30 * a.scale << 0,
- w: 44 * a.scale << 0,
- h: 38 * a.scale << 0
- }, d.touch.create(a.btns.sound, !0, !1), a.btns.pause = {
- id: a.id++,
- name: "pause",
- img: a.buffers.pause,
- x: 285 * a.scale << 0,
- y: 30 * a.scale << 0,
- w: 44 * a.scale << 0,
- h: 38 * a.scale << 0
- }, d.touch.create(a.btns.pause, !0, !1))
- };
- a.delGamePage = function () {
- a.btns.pause &&
- (d.touch.deleteImg(a.btns.sound.id), a.btns.sound = null, d.touch.deleteImg(a.btns.pause.id), a.btns.pause = null)
- };
- a.showGamePage = function () {
- a.btns.sound.img = a.volume ? a.buffers.sound1 : a.buffers.sound2;
- a.drawBtns(a.btns.sound);
- a.drawBtns(a.btns.pause)
- };
- a.createPauseDialog = function () {
- a.btns.resume || a.btns.exit2 || (a.btns.resume = {
- id: a.id++,
- name: "resume",
- img: a.buffers.resume,
- x: 0.3 * a.width << 0,
- y: 265 * a.scale << 0,
- w: 85 * a.scale << 0,
- h: 80 * a.scale << 0
- }, d.touch.create(a.btns.resume, !0, !1), a.btns.exit2 = {
- id: a.id++,
- name: "exit2",
- img: a.buffers.exit2,
- x: 0.7 * a.width << 0,
- y: 265 * a.scale << 0,
- w: 85 * a.scale << 0,
- h: 80 * a.scale << 0
- }, d.touch.create(a.btns.exit2, !0, !1))
- };
- a.delPauseDialog = function () {
- 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)
- };
- a.showPauseDialog = function () {
- a.ctx.drawImage(a.buffers.pause_bg, 0, 60 * a.scale << 0);
- a.drawNum(a.score, 0.1 * a.width << 0, 130 * a.scale << 0, a.buffers.num3, 47, 60, 0, a.scale);
- a.drawBtns(a.btns.resume);
- a.drawBtns(a.btns.exit2)
-
- };
- a.createClueDialog =
- function () {
- a.btns.clue1 || (a.btns.clue1 = {
- id: a.id++,
- name: "clue1",
- img: d.getImage("clue1"),
- x: (a.width - 156) / 2 + 78,
- y: a.height - 32,
- w: 156,
- h: 63
- }, d.touch.create(a.btns.clue1, !0, !1))
- };
- a.delClueDialog = function () {
- a.btns.clue1 && (d.touch.deleteImg(a.btns.clue1.id), a.btns.clue1 = null)
- };
- a.showClueDialog = function () {
- a.btns.clue1 && a.ctx.drawImage(a.btns.clue1.img, a.btns.clue1.x - 78, a.btns.clue1.y - 32)
- };
- a.sinaRank = function (a) {
- d.ajax({
- type: "get",
- dataType: "html",
- url: "" +
- d.request.get("wyx_session_key") + "&rank_id=1&value=" + a + "&platform_id=2",
- before: function () {},
- success: function (a) {
- console.log(a)
- },
- error: function () {},
- complete: function () {
- isSend = !1
- }
- })
- };
- a.sinaAchieve = function (a) {
- d.ajax({
- type: "get",
- dataType: "html",
- url: "",
- before: function () {},
- success: function (a) {
- console.log(a)
- },
- error: function () {},
- complete: function () {
- isSend = !1
- }
- })
- };
- d.touch.click(function (b) {
- switch (b.name) {
- case "ballon":
- a.addToHouse(b);
- break;
- case "coin":
- a.collectCoin(b);
- break;
- case "bomb":
- b.exploded = !0;
- b.coin = 1;
- break;
- case "sound":
- a.volume = !a.volume;
- a.musicControl();
- break;
- case "clue1":
- a.delClueDialog();
- break;
- case "pause":
- // updateShare(a.score);Play68.setRankingScoreDesc(a.score);
- a.paused = !0;
- a.createPauseDialog();
- break;
- case "resume":
- a.delPauseDialog();
- a.paused = !1;
- break;
- case "exit2":
- a.delPauseDialog();
- a.delGamePage();
- a.init();
- a.createLogoPage();
- a.state = 0;
- break;
- case "begin":
- document.getElementById('tips').style.display = "block";
- a.delLogoPage();
- a.delClueDialog();
- a.createHelpPage();
- a.state = 1;
- break;
- case "achieve":
- // Play68.goHome();
- break;
- case "exit1":
- a.music.bg.pause();
- window.close();
- break;
- case "help":
- a.delHelpPage();
- a.createGamePage();
- a.state = 2;
- a.paused = !1;
- break;
- case "achieve_bg":
- case "next2":
- a.delAchievePage(), a.createLogoPage(), a.state = 0
- }
- });
- d.touch.draged(function (b) {
- "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);
- a.dragFlag = !0
- });
- d.touch.touchStart(function () {
- a.touchTime =
- (new Date)
- .getTime();
- a.startX = d.touch.getStartPos()
- .x;
- a.dragFlag = !1
- });
- d.touch.touchEnd(function () {
- 1E3 > (new Date)
- .getTime() - a.touchTime && d.touch.getReleasePos()
- .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]++)
- });
- d.setRunFrequency(50);
- a.newGame1 = !0;
- a.newGame2 = !0;
- a.state = 0;
- a.id = 0;
- a.scaleTmp = 0;
- a.volume = !0;
- a.music = {};
- a.initMusic();
- a.buffer = [];
- a.buffers = {};
- a.btns = {};
- a.newGame = !0;
- /* if (window.innerHeight >
- window.innerWidth) */ try {
- a.initCanvas(), a.scaleTmp = a.scale, a.initBuffer(), a.initSize(), a.land = {
- id: "land",
- name: "land",
- img: a.buffers.land,
- altitude: 0,
- x: a.width / 2 << 0,
- y: a.height - 33 * a.scale,
- w: 320 * a.scale,
- h: 67 * a.scale
- }, a.house = {
- id: "house",
- name: "house",
- img: a.buffers.house,
- altitude: 0,
- target: 0,
- x: a.width / 2 << 0,
- y: a.height - 57 * a.scale,
- w: 116 * a.scale,
- h: 101 * a.scale,
- ballons: 0,
- timer: 0
- }, d.touch.create(a.house, !1, !0), a.init(), a.createLogoPage(), a.showLogoPage(), a.newGame = !1
- } catch (m) {
- window.location.reload(!1)
- } /* else a.clue = !0, a.showClue(); */
- d.run(function () {
- if (a.clue) a.showClue();
- else switch (a.state) {
- case 0:
- a.showLogoPage();
- break;
- case 1:
- a.showHelpPage();
- break;
- case 2:
- a.refresh();
- break;
- case 3:
- a.showAchievePage()
- }
- })
- })
- };
|