123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- function main() {
- var c = {
- isShowClue1: !0,
- isFirstInGame: !0,
- init: function () {
- jsGame.canvas.screen.setWidth(c.width);
- jsGame.canvas.screen.setHeight(c.height);
- c.width < c.height && (c.clue = !0);
- 300 <= c.height ? c.isShowClue1 = !1 : c.isFirstInGame && (c.isFirstInGame = !1, c.isShowClue1 = !0)
- },
- initCanvas: function () {
- jsGame.canvas.screen.getTouch() ? (window.scrollTo(0, -5), c.height = window.innerHeight, c.width = window.innerWidth, jsGame.canvas.screen.setHeight(c.height), c.top = 0, c.left = 0) : (c.height = 1136, c.width = 640, c.top = 0, c.left = (window.innerWidth - c.width) / 2);
- c.init();
- c.canvas = document.getElementById("jsGameScreen");
- c.ctx = c.canvas.getContext("2d")
- }
- };
- window.onresize = function () {
- c.initCanvas()
- };
- jsGame.initImage([{
- id: "a",
- src: "img/a.png"
- }, {
- id: "back0",
- src: "img/back0.jpg"
- }, {
- id: "tree0",
- src: "img/tree0.png"
- }, {
- id: "leaf0",
- src: "img/leaf0.png"
- }, {
- id: "leaf0L",
- src: "img/leaf0L.png"
- }, {
- id: "stump0",
- src: "img/stump0.png"
- }, {
- id: "back1",
- src: "img/back1.jpg"
- }, {
- id: "tree1",
- src: "img/tree1.png"
- }, {
- id: "leaf1",
- src: "img/leaf1.png"
- }, {
- id: "leaf1L",
- src: "img/leaf1L.png"
- }, {
- id: "stump1",
- src: "img/stump1.png"
- }, {
- id: "man0",
- src: "img/man0.png"
- }, {
- id: "man1",
- src: "img/man1.png"
- }, {
- id: "man2",
- src: "img/man2.png"
- }, {
- id: "man3",
- src: "img/man3.png"
- }, {
- id: "man0L",
- src: "img/man0L.png"
- }, {
- id: "man1L",
- src: "img/man1L.png"
- }, {
- id: "man2L",
- src: "img/man2L.png"
- }, {
- id: "man3L",
- src: "img/man3L.png"
- }, {
- id: "dead",
- src: "img/dead.png"
- }, {
- id: "arrow",
- src: "img/arrow.png"
- }, {
- id: "arrowL",
- src: "img/arrowL.png"
- }, {
- id: "hp",
- src: "img/hp.png"
- }, {
- id: "hp2",
- src: "img/hp2.png"
- }, {
- id: "hpbar",
- src: "img/hpbar.png"
- }, {
- id: "menu",
- src: "img/menu.png"
- }, {
- id: "num",
- src: "img/num.png"
- }, {
- id: "btnRank",
- src: "img/btnRank.png"
- }, {
- id: "btnPlay",
- src: "img/btnPlay.png"
- }, {
- id: "btnShare",
- src: "img/btnShare.png"
- }, {
- id: "btnSound",
- src: "img/sound.png"
- }, {
- id: "btnMore",
- src: "img/duopao.png"
- }, {
- id: "btnMiji",
- src: "img/btnmiji.png"
- }, {
- id: "title",
- src: "img/title.png"
- }]).setRunFrequency(jsGame.canvas.screen.getTouch() ? 50 : 60);
- jsGame.initImageCallBack(function (b, r) {
- if (b >= r) jsGame.gameFlow.run();
- else try {
- var x = b / r,
- x = 1 < x ? 1 : x;
- c.ctx.fillStyle = "#FFFFFF";
- c.ctx.fillRect(0, 0, c.width, c.height);
- c.ctx.drawImage(jsGame.getImage("a"), 0, 0, 250, 81, (c.width - 250) / 2, (c.height - 81) / 2, 250, 81);
- c.ctx.drawImage(jsGame.getImage("a"), 2, 86, 246 * x, 10, (c.width - 246) / 2, (c.height - 81) / 2 + 51, 246 * x, 10)
- } catch (H) { }
- jsGame.initAudio([{
- id: "swav",
- src: "",
- loop: !1,
- preload: !0
- }, {
- id: "smp3",
- src: "",
- loop: !1,
- preload: !0
- }])
- });
- jsGame.init(640, 1136).pageLoad(function (b) {
- function r() {
- var a = b.commandFuns.getRandom(2);
- G == a == 0 && (I++, 4 < I && (a = b.commandFuns.getRandom(1) + 1, I = 0));
- a == K != 0 && (J++, 4 < J && (a = 1 == a ? 2 : 1, J = 0));
- 0 != G && (a = 0);
- K = G;
- return G = a
- }
- function x() {
- return t.direction && 2 == d[0].type || !t.direction && 1 == d[0].type || 0 >= u ? (t.isDead = !0, h = 2, v > D && (D = v, jsGame.localStorage.setItem("timbermanhscore", D)), g = 0, l = -700, function (a) {
- s = a;
- z = s.rank;
- window.shareData.timeLineLink = s.url;
- a = "";
- 0 < z && 100 >= z && (a = ",在全球真汉子排名第" + z);
- document.title = window.shareData.tTitle = "我一次就能啪啪" + v + "下" + a + ",有本事就来挑战!"
- }, !0) : !1
- }
- function H(a) {
- if (0 == h) {
- if (k(f, a.x, a.y)) {
- f.isPressed = !0;
- return
- }
- if (k(e, a.x, a.y)) {
- e.isPressed = !0;
- return
- }
- h = 1;
- g = -1
- }
- 1 == h ? k(f, a.x, a.y) ? f.isPressed = !0 : k(e, a.x, a.y) ? e.isPressed = !0 : (0 < a.x && a.x < b.canvas.screen.getWidth() / 2 ? t.direction = !0 : t.direction = !1, -1 == g && (0 == y && (0 <= navigator.userAgent.toLowerCase().indexOf("android") ? b.audio.play("swav", 0, 1) : b.audio.play("smp3", 0, 1)), t.cut(), a = parseInt(v / 10), 8 < a && (a = 8), u += 10 - a, 268 < u && (u = 268)), A = !0) : 2 == h && -1 == g && (k(q, a.x, a.y) && (q.isPressed = !0), k(m, a.x, a.y) && (m.isPressed = !0), k(n, a.x, a.y) && (n.isPressed = !0), k(p, a.x, a.y) && (p.isPressed = !0))
- }
- function L(a) {
- 0 == h || 1 == h ? (k(f, a.x, a.y) || (f.isPressed = !1), k(e, a.x, a.y) || (e.isPressed = !1)) : 2 == h && -1 == g && (k(q, a.x, a.y) || (q.isPressed = !1), k(m, a.x, a.y) || (m.isPressed = !1), k(n, a.x, a.y) || (n.isPressed = !1), k(p, a.x, a.y) || (p.isPressed = !1))
- }
- function M(a) {
- A = !1;
- if (0 == h || 1 == h) f.isPressed && k(f, a.x, a.y) ? (y = 1 == y ? 0 : 1, jsGame.localStorage.setItem("timbermansound", y), f.isPressed = !1) : e.isPressed && k(e, a.x, a.y) && (window.location.href = "http://game.apiwck.com/", e.isPressed = !1);
- else if (2 == h && -1 == g) if (q.isPressed && k(q, a.x, a.y)) {
- E = b.commandFuns.getRandom(1);
- h = 0;
- d = [];
- d.push(new Tree(0, 0));
- d.push(new Tree(1, 0));
- d.push(new Tree(2, 0));
- d.push(new Tree(3, r()));
- d.push(new Tree(4, r()));
- d.push(new Tree(5, r()));
- d.push(new Tree(6, r()));
- d.push(new Tree(7, r()));
- for (a = 0; a < d.length; a++) d[a].left = (b.canvas.screen.getWidth() - b.getImage("tree0").width) / 2;
- t = new Man;
- g = -1;
- B = 0;
- u = 135;
- A = !1;
- l = -700;
- v = 0;
- z = -1;
- q.isPressed = !1
- } else m.isPressed && k(m, a.x, a.y) ? (share(v, z), m.isPressed = !1) : n.isPressed && k(n, a.x, a.y) ? (window.location.href = "http://ddqian2.aliapp.com/game/", n.isPressed = !1) : p.isPressed && k(p, a.x, a.y) && (dp_Ranking(), p.isPressed = !1)
- }
- function C(a, c, d, e, f, g, h, k, l, m) {
- b.canvas.drawImage(a, c * e, d * f, e, f, g, h, k, l, m)
- }
- function k(a, b, c) {
- return b > a.x && c > a.y && b < a.x + a.w && c < a.y + a.h ? !0 : !1
- }
- function F(a, c, d, e) {
- b.canvas.font("40px 宋体");
- b.canvas.fillStyle("rgb(0,0,0)");
- b.canvas.fillText(a, c + 1, d + 1);
- b.canvas.fillText(a, c - 1, d - 1);
- b.canvas.fillText(a, c + 2, d + 2);
- b.canvas.fillText(a, c - 2, d - 2);
- b.canvas.fillText(a, c + 1, d - 1);
- b.canvas.fillText(a, c - 1, d + 1);
- b.canvas.fillText(a, c + 2, d - 2);
- b.canvas.fillText(a, c - 2, d + 2);
- b.canvas.fillStyle(e);
- b.canvas.fillText(a, c, d)
- }
- c.showClue = function () {
- window.scrollTo(0, -5);
- c.ctx.fillStyle = "#ffffff";
- c.ctx.fillRect(0, 0, window.innerWidth, window.innerHeight);
- b.canvas.drawImage("h", (window.innerWidth - 153) / 2, (window.innerHeight - 122) / 2)
- };
- Tree = function (a, c) {
- this.id = a;
- this.type = c;
- this.height = b.getImage("tree0").height;
- this.width = b.getImage("tree0").width;
- this.top = 746 - this.id * this.height;
- this.dropH = this.offsetY = this.offsetX = 0;
- this.drawTree = function (a, c) {
- b.canvas.drawImage("tree" + c, a + this.offsetX, this.top);
- 1 == this.type ? b.canvas.drawImage("leaf" + c, a + this.width + this.offsetX, this.top + 20) : 2 == this.type && b.canvas.drawImage("leaf" + c + "L", a - b.getImage("leaf0L").width + this.offsetX, this.top + 20)
- };
- this.resetId = function (a) {
- this.id = a;
- this.top = 746 - this.id * this.height
- };
- this.reset = function () {
- this.offsetY = this.offsetX = 0;
- this.dropH = this.top
- };
- this.fly = function (a) {
- a ? (this.offsetX += 80, this.offsetY -= 40) : (this.offsetX -= 80, this.offsetY += 40)
- };
- this.drop = function () {
- this.offsetY += 20;
- if (this.top + this.offsetY - this.dropH > this.height) return this.offsetY = this.height + this.dropH - this.top, this.top += this.offsetY, !1;
- this.top += this.offsetY;
- return !0
- }
- };
- Man = function () {
- this.status = 0;
- this.direction = !0;
- this.AniCount = 0;
- this.isDead = !1;
- this.drawMan = function () {
- this.isDead ? this.direction ? b.canvas.drawImage("dead", 100, 800) : b.canvas.drawImage("dead", b.canvas.screen.getWidth() - b.getImage("dead").width - 100, 800) : this.direction ? b.canvas.drawImage("man" + this.status, 80, 700) : b.canvas.drawImage("man" + this.status + "L", b.canvas.screen.getWidth() - b.getImage("man0").width - 80, 700)
- };
- this.tick = function () {
- 2 > this.status ? 0 == this.AniCount % 6 && (0 == this.status ? this.status = 1 : 1 == this.status && (this.status = 0)) : 0 == this.AniCount % 2 && (2 == this.status ? this.status = 3 : 3 == this.status && (this.status = 0));
- 6 <= this.AniCount && (this.AniCount = 0);
- this.AniCount++
- };
- this.cut = function () {
- 2 > this.status && (this.status = 2)
- }
- };
- var h = 0,
- s = null,
- d = [],
- t = {},
- g = -1,
- B = 0,
- u = 0,
- A = !1,
- l = -700,
- v = 0,
- D = 0,
- E = 1,
- y = 1,
- z = -1,
- O = document.getElementById("jsGameScreen").getContext("2d"),
- q = {
- x: 0,
- y: 660,
- w: 142,
- h: 128,
- isPressed: !1,
- draw: C
- },
- m = {
- x: 0,
- y: 660,
- w: 206,
- h: 128,
- isPressed: !1,
- draw: C
- },
- p = {
- x: 0,
- y: 660,
- w: 142,
- h: 128,
- isPressed: !1,
- draw: C
- },
- f = {
- x: 0,
- y: 60,
- w: 95,
- h: 84,
- isPressed: !1,
- draw: C
- },
- e = {
- x: 0,
- y: 60,
- w: 95,
- h: 84,
- isPressed: !1,
- draw: C
- },
- n = {
- x: 0,
- y: 800,
- w: 206,
- h: 128,
- isPressed: !1,
- draw: C
- };
- (function () {
- jsGame.localStorage.init();
- E = b.commandFuns.getRandom(1);
- h = 0;
- d = [];
- d.push(new Tree(0, 0));
- d.push(new Tree(1, 0));
- d.push(new Tree(2, 0));
- d.push(new Tree(3, r()));
- d.push(new Tree(4, r()));
- d.push(new Tree(5, r()));
- d.push(new Tree(6, r()));
- d.push(new Tree(7, r()));
- for (var a = 0; a < d.length; a++) d[a].left = (b.canvas.screen.getWidth() - b.getImage("tree0").width) / 2;
- t = new Man;
- g = -1;
- B = 0;
- u = 136;
- A = !1;
- l = -700;
- v = 0;
- y = 1;
- z = -1;
- null != jsGame.localStorage.getItem("timbermanhscore") && (D = parseInt(jsGame.localStorage.getItem("timbermanhscore")));
- null != jsGame.localStorage.getItem("timbermansound") && (y = parseInt(jsGame.localStorage.getItem("timbermansound")))
- })();
- var G = 0,
- K = 0,
- I = 0,
- J = 0,
- w = {
- x: 0,
- y: 0
- };
- b.events.touchStart(function (a) {
- w = {
- x: a.touches[0].clientX,
- y: a.touches[0].clientY
- };
- H(w)
- }).touchMove(function (a) {
- w = {
- x: a.touches[0].clientX - c.left,
- y: a.touches[0].clientY - c.top
- };
- L(w)
- }).touchEnd(function (a) {
- M(w)
- }).mouseMove(function (a) {
- w = {
- x: a.clientX - c.left,
- y: a.clientY - c.top
- };
- L(w)
- }).mouseDown(function (a) {
- w = {
- x: a.clientX - c.left,
- y: a.clientY - c.top
- };
- H(w)
- }).mouseUp(function (a) {
- w = {
- x: a.clientX - c.left,
- y: a.clientY - c.top
- };
- M(w)
- });
- var N = 0;
- b.run(function () {
- window.scrollTo(0, -5);
- switch (N) {
- case 0:
- N = 1;
- c.initCanvas();
- break;
- case 1:
- b.canvas.drawImage("back" + E, 0, 0, b.getImage("back0").width, b.getImage("back0").height, 0, 0, b.canvas.screen.getWidth(), b.canvas.screen.getHeight());
- for (var a = d.length - 1; 0 <= a; a--) d[a].drawTree((b.canvas.screen.getWidth() - b.getImage("tree0").width) / 2, E);
- b.canvas.drawImage("stump" + E, (b.canvas.screen.getWidth() - b.getImage("stump0").width) / 2, 746 + b.getImage("tree0").height);
- t.drawMan();
- if (0 == h) b.canvas.drawImage("title", (b.canvas.screen.getWidth() - b.getImage("title").width) / 2, 180), b.canvas.drawImage("arrow", 60 + B, 500), b.canvas.drawImage("arrowL", b.canvas.screen.getWidth() - b.getImage("arrowL").width - 60 - B, 500), f.x = 40, f.draw("btnSound", y, 0, f.w, f.h, f.x, f.y, f.w, f.h), e.x = b.canvas.screen.getWidth() - e.w - 40, e.draw("btnMore", e.isPressed ? 1 : 0, 0, e.w, e.h, e.x, e.y, e.w, e.h);
- else if (1 == h) b.canvas.drawNumber(v, "num", 48, 60, b.canvas.screen.getWidth() / 2, 200, !1).drawImage("score", 200, 200), b.canvas.drawImage("hpbar", (b.canvas.screen.getWidth() - b.getImage("hpbar").width) / 2, 60), A ? b.canvas.drawImage("hp2", 0, 0, b.getImage("hp2").width, b.getImage("hp2").height, (b.canvas.screen.getWidth() - b.getImage("hpbar").width) / 2 + 23, 77, u, b.getImage("hp2").height) : b.canvas.drawImage("hp", 0, 0, b.getImage("hp").width, b.getImage("hp").height, (b.canvas.screen.getWidth() - b.getImage("hpbar").width) / 2 + 23, 77, u, b.getImage("hp").height), f.x = 40, f.draw("btnSound", y, 0, f.w, f.h, f.x, f.y, f.w, f.h), e.x = b.canvas.screen.getWidth() - e.w - 40, e.draw("btnMore", e.isPressed ? 1 : 0, 0, e.w, e.h, e.x, e.y, e.w, e.h);
- else if (2 == h) {
- b.canvas.drawImage("menu", (b.canvas.screen.getWidth() - b.getImage("menu").width) / 2, 0 + l);
- F("当前次数:", 200, 140 + l, "rgb(255,255,255)");
- b.canvas.drawNumber(v, "num", 48, 60, 540, 100 + l, !1).drawImage("score", 200, 200);
- F("最高次数:", 200, 240 + l, "rgb(255,255,255)");
- b.canvas.drawNumber(D, "num", 48, 60, 540, 200 + l, !1).drawImage("score", 200, 200);
- if (s) for (0 < s.rank && 100 >= s.rank ? F("你的全球排名是第" + s.rank, 200, 340 + l, "rgb(255,255,255)") : F("你未上榜,请继续努力", 200, 340 + l, "rgb(255,255,255)"), a = 0; a < s.othersInfo.length; a++) O.drawImage(s.othersInfo[a].avatar, 0, 0, s.othersInfo[a].avatar.width, s.othersInfo[a].avatar.height, 200, 400 + l + 50 * a, 50, 50), F(s.othersInfo[a].name.substring(0, 6) + ":" + s.othersInfo[a].score + "分", 260, 440 + l + 50 * a, "rgb(255,255,255)"); -1 == g && (q.x = 60, q.draw("btnPlay", q.isPressed ? 1 : 0, 0, q.w, q.h, q.x, q.y, q.w, q.h), p.x = b.canvas.screen.getWidth() - p.w - 60, p.draw("btnRank", p.isPressed ? 1 : 0, 0, p.w, p.h, p.x, p.y, p.w, p.h), m.x = (b.canvas.screen.getWidth() - m.w) / 2, m.draw("btnShare", m.isPressed ? 1 : 0, 0, m.w, m.h, m.x, m.y, m.w, m.h), n.x = (b.canvas.screen.getWidth() - n.w) / 2)
- }
- a: if (t.tick(), 0 == h) g++,
- 3 <= g && (B = 0 == B ? 5 : 0, g = 0);
- else if (1 == h) {
- A = !1;
- u--;
- 0 > u && (u = 0);
- x();
- if (3 == t.status && -1 == g) {
- for (a = 0; a < d.length; a++) d[a].reset();
- g = 0
- }
- if (0 <= g) for (d[0].fly(t.direction), g++, a = 1; a < d.length; a++) if (!d[a].drop()) {
- 1 == h && (g = -1);
- d.shift();
- d.push(new Tree(7, r()));
- for (a = 0; a < d.length; a++) d[a].resetId(a);
- x() || v++;
- break a
- }
- } else 2 == h && 0 <= g && (g++, 0 < l + 10 * g ? (l = 0, g = -1, l = 0) : l += 10 * g)
- }
- })
- })
- };
- ;
|