Main.min.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. function main() {
  2. var c = {
  3. isShowClue1: !0,
  4. isFirstInGame: !0,
  5. init: function () {
  6. jsGame.canvas.screen.setWidth(c.width);
  7. jsGame.canvas.screen.setHeight(c.height);
  8. c.width < c.height && (c.clue = !0);
  9. 300 <= c.height ? c.isShowClue1 = !1 : c.isFirstInGame && (c.isFirstInGame = !1, c.isShowClue1 = !0)
  10. },
  11. initCanvas: function () {
  12. 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);
  13. c.init();
  14. c.canvas = document.getElementById("jsGameScreen");
  15. c.ctx = c.canvas.getContext("2d")
  16. }
  17. };
  18. window.onresize = function () {
  19. c.initCanvas()
  20. };
  21. jsGame.initImage([{
  22. id: "a",
  23. src: "img/a.png"
  24. }, {
  25. id: "back0",
  26. src: "img/back0.jpg"
  27. }, {
  28. id: "tree0",
  29. src: "img/tree0.png"
  30. }, {
  31. id: "leaf0",
  32. src: "img/leaf0.png"
  33. }, {
  34. id: "leaf0L",
  35. src: "img/leaf0L.png"
  36. }, {
  37. id: "stump0",
  38. src: "img/stump0.png"
  39. }, {
  40. id: "back1",
  41. src: "img/back1.jpg"
  42. }, {
  43. id: "tree1",
  44. src: "img/tree1.png"
  45. }, {
  46. id: "leaf1",
  47. src: "img/leaf1.png"
  48. }, {
  49. id: "leaf1L",
  50. src: "img/leaf1L.png"
  51. }, {
  52. id: "stump1",
  53. src: "img/stump1.png"
  54. }, {
  55. id: "man0",
  56. src: "img/man0.png"
  57. }, {
  58. id: "man1",
  59. src: "img/man1.png"
  60. }, {
  61. id: "man2",
  62. src: "img/man2.png"
  63. }, {
  64. id: "man3",
  65. src: "img/man3.png"
  66. }, {
  67. id: "man0L",
  68. src: "img/man0L.png"
  69. }, {
  70. id: "man1L",
  71. src: "img/man1L.png"
  72. }, {
  73. id: "man2L",
  74. src: "img/man2L.png"
  75. }, {
  76. id: "man3L",
  77. src: "img/man3L.png"
  78. }, {
  79. id: "dead",
  80. src: "img/dead.png"
  81. }, {
  82. id: "arrow",
  83. src: "img/arrow.png"
  84. }, {
  85. id: "arrowL",
  86. src: "img/arrowL.png"
  87. }, {
  88. id: "hp",
  89. src: "img/hp.png"
  90. }, {
  91. id: "hp2",
  92. src: "img/hp2.png"
  93. }, {
  94. id: "hpbar",
  95. src: "img/hpbar.png"
  96. }, {
  97. id: "menu",
  98. src: "img/menu.png"
  99. }, {
  100. id: "num",
  101. src: "img/num.png"
  102. }, {
  103. id: "btnRank",
  104. src: "img/btnRank.png"
  105. }, {
  106. id: "btnPlay",
  107. src: "img/btnPlay.png"
  108. }, {
  109. id: "btnShare",
  110. src: "img/btnShare.png"
  111. }, {
  112. id: "btnSound",
  113. src: "img/sound.png"
  114. }, {
  115. id: "btnMore",
  116. src: "img/duopao.png"
  117. }, {
  118. id: "btnMiji",
  119. src: "img/btnmiji.png"
  120. }, {
  121. id: "title",
  122. src: "img/title.png"
  123. }]).setRunFrequency(jsGame.canvas.screen.getTouch() ? 50 : 60);
  124. jsGame.initImageCallBack(function (b, r) {
  125. if (b >= r) jsGame.gameFlow.run();
  126. else try {
  127. var x = b / r,
  128. x = 1 < x ? 1 : x;
  129. c.ctx.fillStyle = "#FFFFFF";
  130. c.ctx.fillRect(0, 0, c.width, c.height);
  131. c.ctx.drawImage(jsGame.getImage("a"), 0, 0, 250, 81, (c.width - 250) / 2, (c.height - 81) / 2, 250, 81);
  132. c.ctx.drawImage(jsGame.getImage("a"), 2, 86, 246 * x, 10, (c.width - 246) / 2, (c.height - 81) / 2 + 51, 246 * x, 10)
  133. } catch (H) { }
  134. jsGame.initAudio([{
  135. id: "swav",
  136. src: "",
  137. loop: !1,
  138. preload: !0
  139. }, {
  140. id: "smp3",
  141. src: "",
  142. loop: !1,
  143. preload: !0
  144. }])
  145. });
  146. jsGame.init(640, 1136).pageLoad(function (b) {
  147. function r() {
  148. var a = b.commandFuns.getRandom(2);
  149. G == a == 0 && (I++, 4 < I && (a = b.commandFuns.getRandom(1) + 1, I = 0));
  150. a == K != 0 && (J++, 4 < J && (a = 1 == a ? 2 : 1, J = 0));
  151. 0 != G && (a = 0);
  152. K = G;
  153. return G = a
  154. }
  155. function x() {
  156. 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) {
  157. s = a;
  158. z = s.rank;
  159. window.shareData.timeLineLink = s.url;
  160. a = "";
  161. 0 < z && 100 >= z && (a = ",在全球真汉子排名第" + z);
  162. document.title = window.shareData.tTitle = "我一次就能啪啪" + v + "下" + a + ",有本事就来挑战!"
  163. }, !0) : !1
  164. }
  165. function H(a) {
  166. if (0 == h) {
  167. if (k(f, a.x, a.y)) {
  168. f.isPressed = !0;
  169. return
  170. }
  171. if (k(e, a.x, a.y)) {
  172. e.isPressed = !0;
  173. return
  174. }
  175. h = 1;
  176. g = -1
  177. }
  178. 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))
  179. }
  180. function L(a) {
  181. 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))
  182. }
  183. function M(a) {
  184. A = !1;
  185. 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);
  186. else if (2 == h && -1 == g) if (q.isPressed && k(q, a.x, a.y)) {
  187. E = b.commandFuns.getRandom(1);
  188. h = 0;
  189. d = [];
  190. d.push(new Tree(0, 0));
  191. d.push(new Tree(1, 0));
  192. d.push(new Tree(2, 0));
  193. d.push(new Tree(3, r()));
  194. d.push(new Tree(4, r()));
  195. d.push(new Tree(5, r()));
  196. d.push(new Tree(6, r()));
  197. d.push(new Tree(7, r()));
  198. for (a = 0; a < d.length; a++) d[a].left = (b.canvas.screen.getWidth() - b.getImage("tree0").width) / 2;
  199. t = new Man;
  200. g = -1;
  201. B = 0;
  202. u = 135;
  203. A = !1;
  204. l = -700;
  205. v = 0;
  206. z = -1;
  207. q.isPressed = !1
  208. } 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)
  209. }
  210. function C(a, c, d, e, f, g, h, k, l, m) {
  211. b.canvas.drawImage(a, c * e, d * f, e, f, g, h, k, l, m)
  212. }
  213. function k(a, b, c) {
  214. return b > a.x && c > a.y && b < a.x + a.w && c < a.y + a.h ? !0 : !1
  215. }
  216. function F(a, c, d, e) {
  217. b.canvas.font("40px 宋体");
  218. b.canvas.fillStyle("rgb(0,0,0)");
  219. b.canvas.fillText(a, c + 1, d + 1);
  220. b.canvas.fillText(a, c - 1, d - 1);
  221. b.canvas.fillText(a, c + 2, d + 2);
  222. b.canvas.fillText(a, c - 2, d - 2);
  223. b.canvas.fillText(a, c + 1, d - 1);
  224. b.canvas.fillText(a, c - 1, d + 1);
  225. b.canvas.fillText(a, c + 2, d - 2);
  226. b.canvas.fillText(a, c - 2, d + 2);
  227. b.canvas.fillStyle(e);
  228. b.canvas.fillText(a, c, d)
  229. }
  230. c.showClue = function () {
  231. window.scrollTo(0, -5);
  232. c.ctx.fillStyle = "#ffffff";
  233. c.ctx.fillRect(0, 0, window.innerWidth, window.innerHeight);
  234. b.canvas.drawImage("h", (window.innerWidth - 153) / 2, (window.innerHeight - 122) / 2)
  235. };
  236. Tree = function (a, c) {
  237. this.id = a;
  238. this.type = c;
  239. this.height = b.getImage("tree0").height;
  240. this.width = b.getImage("tree0").width;
  241. this.top = 746 - this.id * this.height;
  242. this.dropH = this.offsetY = this.offsetX = 0;
  243. this.drawTree = function (a, c) {
  244. b.canvas.drawImage("tree" + c, a + this.offsetX, this.top);
  245. 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)
  246. };
  247. this.resetId = function (a) {
  248. this.id = a;
  249. this.top = 746 - this.id * this.height
  250. };
  251. this.reset = function () {
  252. this.offsetY = this.offsetX = 0;
  253. this.dropH = this.top
  254. };
  255. this.fly = function (a) {
  256. a ? (this.offsetX += 80, this.offsetY -= 40) : (this.offsetX -= 80, this.offsetY += 40)
  257. };
  258. this.drop = function () {
  259. this.offsetY += 20;
  260. if (this.top + this.offsetY - this.dropH > this.height) return this.offsetY = this.height + this.dropH - this.top, this.top += this.offsetY, !1;
  261. this.top += this.offsetY;
  262. return !0
  263. }
  264. };
  265. Man = function () {
  266. this.status = 0;
  267. this.direction = !0;
  268. this.AniCount = 0;
  269. this.isDead = !1;
  270. this.drawMan = function () {
  271. 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)
  272. };
  273. this.tick = function () {
  274. 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));
  275. 6 <= this.AniCount && (this.AniCount = 0);
  276. this.AniCount++
  277. };
  278. this.cut = function () {
  279. 2 > this.status && (this.status = 2)
  280. }
  281. };
  282. var h = 0,
  283. s = null,
  284. d = [],
  285. t = {},
  286. g = -1,
  287. B = 0,
  288. u = 0,
  289. A = !1,
  290. l = -700,
  291. v = 0,
  292. D = 0,
  293. E = 1,
  294. y = 1,
  295. z = -1,
  296. O = document.getElementById("jsGameScreen").getContext("2d"),
  297. q = {
  298. x: 0,
  299. y: 660,
  300. w: 142,
  301. h: 128,
  302. isPressed: !1,
  303. draw: C
  304. },
  305. m = {
  306. x: 0,
  307. y: 660,
  308. w: 206,
  309. h: 128,
  310. isPressed: !1,
  311. draw: C
  312. },
  313. p = {
  314. x: 0,
  315. y: 660,
  316. w: 142,
  317. h: 128,
  318. isPressed: !1,
  319. draw: C
  320. },
  321. f = {
  322. x: 0,
  323. y: 60,
  324. w: 95,
  325. h: 84,
  326. isPressed: !1,
  327. draw: C
  328. },
  329. e = {
  330. x: 0,
  331. y: 60,
  332. w: 95,
  333. h: 84,
  334. isPressed: !1,
  335. draw: C
  336. },
  337. n = {
  338. x: 0,
  339. y: 800,
  340. w: 206,
  341. h: 128,
  342. isPressed: !1,
  343. draw: C
  344. };
  345. (function () {
  346. jsGame.localStorage.init();
  347. E = b.commandFuns.getRandom(1);
  348. h = 0;
  349. d = [];
  350. d.push(new Tree(0, 0));
  351. d.push(new Tree(1, 0));
  352. d.push(new Tree(2, 0));
  353. d.push(new Tree(3, r()));
  354. d.push(new Tree(4, r()));
  355. d.push(new Tree(5, r()));
  356. d.push(new Tree(6, r()));
  357. d.push(new Tree(7, r()));
  358. for (var a = 0; a < d.length; a++) d[a].left = (b.canvas.screen.getWidth() - b.getImage("tree0").width) / 2;
  359. t = new Man;
  360. g = -1;
  361. B = 0;
  362. u = 136;
  363. A = !1;
  364. l = -700;
  365. v = 0;
  366. y = 1;
  367. z = -1;
  368. null != jsGame.localStorage.getItem("timbermanhscore") && (D = parseInt(jsGame.localStorage.getItem("timbermanhscore")));
  369. null != jsGame.localStorage.getItem("timbermansound") && (y = parseInt(jsGame.localStorage.getItem("timbermansound")))
  370. })();
  371. var G = 0,
  372. K = 0,
  373. I = 0,
  374. J = 0,
  375. w = {
  376. x: 0,
  377. y: 0
  378. };
  379. b.events.touchStart(function (a) {
  380. w = {
  381. x: a.touches[0].clientX,
  382. y: a.touches[0].clientY
  383. };
  384. H(w)
  385. }).touchMove(function (a) {
  386. w = {
  387. x: a.touches[0].clientX - c.left,
  388. y: a.touches[0].clientY - c.top
  389. };
  390. L(w)
  391. }).touchEnd(function (a) {
  392. M(w)
  393. }).mouseMove(function (a) {
  394. w = {
  395. x: a.clientX - c.left,
  396. y: a.clientY - c.top
  397. };
  398. L(w)
  399. }).mouseDown(function (a) {
  400. w = {
  401. x: a.clientX - c.left,
  402. y: a.clientY - c.top
  403. };
  404. H(w)
  405. }).mouseUp(function (a) {
  406. w = {
  407. x: a.clientX - c.left,
  408. y: a.clientY - c.top
  409. };
  410. M(w)
  411. });
  412. var N = 0;
  413. b.run(function () {
  414. window.scrollTo(0, -5);
  415. switch (N) {
  416. case 0:
  417. N = 1;
  418. c.initCanvas();
  419. break;
  420. case 1:
  421. 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());
  422. for (var a = d.length - 1; 0 <= a; a--) d[a].drawTree((b.canvas.screen.getWidth() - b.getImage("tree0").width) / 2, E);
  423. b.canvas.drawImage("stump" + E, (b.canvas.screen.getWidth() - b.getImage("stump0").width) / 2, 746 + b.getImage("tree0").height);
  424. t.drawMan();
  425. 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);
  426. 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);
  427. else if (2 == h) {
  428. b.canvas.drawImage("menu", (b.canvas.screen.getWidth() - b.getImage("menu").width) / 2, 0 + l);
  429. F("当前次数:", 200, 140 + l, "rgb(255,255,255)");
  430. b.canvas.drawNumber(v, "num", 48, 60, 540, 100 + l, !1).drawImage("score", 200, 200);
  431. F("最高次数:", 200, 240 + l, "rgb(255,255,255)");
  432. b.canvas.drawNumber(D, "num", 48, 60, 540, 200 + l, !1).drawImage("score", 200, 200);
  433. 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)
  434. }
  435. a: if (t.tick(), 0 == h) g++,
  436. 3 <= g && (B = 0 == B ? 5 : 0, g = 0);
  437. else if (1 == h) {
  438. A = !1;
  439. u--;
  440. 0 > u && (u = 0);
  441. x();
  442. if (3 == t.status && -1 == g) {
  443. for (a = 0; a < d.length; a++) d[a].reset();
  444. g = 0
  445. }
  446. if (0 <= g) for (d[0].fly(t.direction), g++, a = 1; a < d.length; a++) if (!d[a].drop()) {
  447. 1 == h && (g = -1);
  448. d.shift();
  449. d.push(new Tree(7, r()));
  450. for (a = 0; a < d.length; a++) d[a].resetId(a);
  451. x() || v++;
  452. break a
  453. }
  454. } else 2 == h && 0 <= g && (g++, 0 < l + 10 * g ? (l = 0, g = -1, l = 0) : l += 10 * g)
  455. }
  456. })
  457. })
  458. };
  459. ;