main.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. !function a(b, c, d) {
  2. function e(g, h) {
  3. if (!c[g]) {
  4. if (!b[g]) {
  5. var i = "function" == typeof require && require;
  6. if (!h && i) return i(g, !0);
  7. if (f) return f(g, !0);
  8. var j = new Error("Cannot find module '" + g + "'");
  9. throw j.code = "MODULE_NOT_FOUND", j;
  10. }
  11. var k = c[g] = {
  12. exports: {}
  13. };
  14. b[g][0].call(k.exports, function(a) {
  15. var c = b[g][1][a];
  16. return e(c ? c : a);
  17. }, k, k.exports, a, b, c, d);
  18. }
  19. return c[g].exports;
  20. }
  21. for (var f = "function" == typeof require && require, g = 0; g < d.length; g++) e(d[g]);
  22. return e;
  23. }({
  24. 1: [ function(a, b) {
  25. var c = a("./util"), d = a("eventemitter2").EventEmitter2;
  26. d.extend = c.extend, b.exports = d;
  27. }, {
  28. "./util": 5,
  29. eventemitter2: 6
  30. } ],
  31. 2: [ function(a, b) {
  32. a("./init");
  33. var c = a("./event"), d = function() {
  34. this.isStart = !1, this.isStop = !0, this.isResume = !1, this.isPause = !0, this.sprits = [],
  35. this.timer = null;
  36. }, e = {
  37. init: function() {
  38. this.emit("init"), this.render();
  39. },
  40. start: function() {
  41. this.isStart = !0, this.isStop = !0, this.resume(), this.emit("start");
  42. },
  43. stop: function() {
  44. this.isStart = !1, this.isStop = !0, this.pause(), this.emit("stop");
  45. },
  46. pause: function() {
  47. this.isPause = !0, this.isResume = !1, this.emit("pause");
  48. },
  49. resume: function() {
  50. this.isResume = !0, this.isPause = !1, this.emit("resume");
  51. },
  52. render: function() {
  53. function a() {
  54. var c = b.sprits;
  55. b.sprits = [];
  56. for (var d = 0, e = c.length; e > d; d++) {
  57. var f = c[d];
  58. if (f.isToRemove) b.emit("sprit removed", f), "function" == typeof f._after_remove && (f._after_remove(),
  59. delete f._after_remove); else {
  60. var f = c[d];
  61. b.sprits.push(f), f.move();
  62. }
  63. }
  64. b.timer = requestAnimationFrame(a);
  65. }
  66. var b = this;
  67. a();
  68. },
  69. add: function(a) {
  70. if ("function" != typeof a.move) throw "Sprit should have a `move` function.";
  71. a.isToRemove = !1, this.sprits.push(a), this.emit("sprit added", a);
  72. },
  73. remove: function(a, b) {
  74. a.isToRemove = !0, a._after_remove = b;
  75. }
  76. };
  77. b.exports = c.extend(d, e);
  78. }, {
  79. "./event": 1,
  80. "./init": 3
  81. } ],
  82. 3: [ function() {
  83. for (var a = 0, b = [ "webkit", "moz" ], c = 0; c < b.length && !window.requestAnimationFrame; ++c) window.requestAnimationFrame = window[b[c] + "RequestAnimationFrame"],
  84. window.cancelAnimationFrame = window[b[c] + "CancelAnimationFrame"] || window[b[c] + "CancelRequestAnimationFrame"];
  85. window.requestAnimationFrame || (window.requestAnimationFrame = function(b) {
  86. var c = new Date().getTime(), d = Math.max(0, 16 - (c - a)), e = window.setTimeout(function() {
  87. b(c + d);
  88. }, d);
  89. return a = c + d, e;
  90. }), window.cancelAnimationFrame || (window.cancelAnimationFrame = function(a) {
  91. clearTimeout(a);
  92. });
  93. }, {} ],
  94. 4: [ function(a, b) {
  95. var c = a("./event"), d = new c();
  96. d.images = {
  97. pool: {},
  98. count: 0,
  99. loadedCount: 0
  100. }, d.images.set = function(a, b, c) {
  101. var e = new Image();
  102. if (d.images.pool[a]) throw new Error("id " + a + " existed.");
  103. return e.addEventListener("load", function() {
  104. e.isLoaded = !0, "function" == typeof c && (c(e), d.emit("image loaded", e)), d.images.loadedCount++,
  105. d.images.loadedCount === d.images.count && d.emit("all images loaded");
  106. }), e.src = b, d.images.pool[a] = e, d.images.count++, e;
  107. }, d.images.get = function(a) {
  108. return d.images.pool[a];
  109. }, b.exports = d;
  110. }, {
  111. "./event": 1
  112. } ],
  113. 5: [ function(a, b) {
  114. function c(a, b) {
  115. function d() {
  116. a.apply(this, arguments);
  117. }
  118. function e() {}
  119. var f = this;
  120. e.prototype = f.prototype, d.prototype = new e();
  121. for (var g in b) d.prototype[g] = b[g];
  122. return d.prototype.constructor = a, d.name = a.name, d.extend = c, d;
  123. }
  124. function d(a) {
  125. var b = document.querySelectorAll(a);
  126. return 1 == b.length ? b[0] : b;
  127. }
  128. var e = function() {
  129. var a = 0;
  130. return function() {
  131. var b = a, c = a = +new Date();
  132. return Math.floor(1e3 / (c - b));
  133. };
  134. }();
  135. b.exports = {
  136. extend: c,
  137. $: d,
  138. fps: e
  139. };
  140. }, {} ],
  141. 6: [ function(a, b, c) {
  142. !function() {
  143. function a() {
  144. this._events = {}, this._conf && b.call(this, this._conf);
  145. }
  146. function b(a) {
  147. a && (this._conf = a, a.delimiter && (this.delimiter = a.delimiter), a.maxListeners && (this._events.maxListeners = a.maxListeners),
  148. a.wildcard && (this.wildcard = a.wildcard), a.newListener && (this.newListener = a.newListener),
  149. this.wildcard && (this.listenerTree = {}));
  150. }
  151. function d(a) {
  152. this._events = {}, this.newListener = !1, b.call(this, a);
  153. }
  154. function e(a, b, c, d) {
  155. if (!c) return [];
  156. var f, g, h, i, j, k, l, m = [], n = b.length, o = b[d], p = b[d + 1];
  157. if (d === n && c._listeners) {
  158. if ("function" == typeof c._listeners) return a && a.push(c._listeners), [ c ];
  159. for (f = 0, g = c._listeners.length; g > f; f++) a && a.push(c._listeners[f]);
  160. return [ c ];
  161. }
  162. if ("*" === o || "**" === o || c[o]) {
  163. if ("*" === o) {
  164. for (h in c) "_listeners" !== h && c.hasOwnProperty(h) && (m = m.concat(e(a, b, c[h], d + 1)));
  165. return m;
  166. }
  167. if ("**" === o) {
  168. l = d + 1 === n || d + 2 === n && "*" === p, l && c._listeners && (m = m.concat(e(a, b, c, n)));
  169. for (h in c) "_listeners" !== h && c.hasOwnProperty(h) && ("*" === h || "**" === h ? (c[h]._listeners && !l && (m = m.concat(e(a, b, c[h], n))),
  170. m = m.concat(e(a, b, c[h], d))) : m = m.concat(h === p ? e(a, b, c[h], d + 2) : e(a, b, c[h], d)));
  171. return m;
  172. }
  173. m = m.concat(e(a, b, c[o], d + 1));
  174. }
  175. if (i = c["*"], i && e(a, b, i, d + 1), j = c["**"]) if (n > d) {
  176. j._listeners && e(a, b, j, n);
  177. for (h in j) "_listeners" !== h && j.hasOwnProperty(h) && (h === p ? e(a, b, j[h], d + 2) : h === o ? e(a, b, j[h], d + 1) : (k = {},
  178. k[h] = j[h], e(a, b, {
  179. "**": k
  180. }, d + 1)));
  181. } else j._listeners ? e(a, b, j, n) : j["*"] && j["*"]._listeners && e(a, b, j["*"], n);
  182. return m;
  183. }
  184. function f(a, b) {
  185. a = "string" == typeof a ? a.split(this.delimiter) : a.slice();
  186. for (var c = 0, d = a.length; d > c + 1; c++) if ("**" === a[c] && "**" === a[c + 1]) return;
  187. for (var e = this.listenerTree, f = a.shift(); f; ) {
  188. if (e[f] || (e[f] = {}), e = e[f], 0 === a.length) {
  189. if (e._listeners) {
  190. if ("function" == typeof e._listeners) e._listeners = [ e._listeners, b ]; else if (g(e._listeners) && (e._listeners.push(b),
  191. !e._listeners.warned)) {
  192. var i = h;
  193. "undefined" != typeof this._events.maxListeners && (i = this._events.maxListeners),
  194. i > 0 && e._listeners.length > i && (e._listeners.warned = !0, console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.", e._listeners.length),
  195. console.trace());
  196. }
  197. } else e._listeners = b;
  198. return !0;
  199. }
  200. f = a.shift();
  201. }
  202. return !0;
  203. }
  204. var g = Array.isArray ? Array.isArray : function(a) {
  205. return "[object Array]" === Object.prototype.toString.call(a);
  206. }, h = 10;
  207. d.prototype.delimiter = ".", d.prototype.setMaxListeners = function(b) {
  208. this._events || a.call(this), this._events.maxListeners = b, this._conf || (this._conf = {}),
  209. this._conf.maxListeners = b;
  210. }, d.prototype.event = "", d.prototype.once = function(a, b) {
  211. return this.many(a, 1, b), this;
  212. }, d.prototype.many = function(a, b, c) {
  213. function d() {
  214. 0 === --b && e.off(a, d), c.apply(this, arguments);
  215. }
  216. var e = this;
  217. if ("function" != typeof c) throw new Error("many only accepts instances of Function");
  218. return d._origin = c, this.on(a, d), e;
  219. }, d.prototype.emit = function() {
  220. this._events || a.call(this);
  221. var b = arguments[0];
  222. if ("newListener" === b && !this.newListener && !this._events.newListener) return !1;
  223. if (this._all) {
  224. for (var c = arguments.length, d = new Array(c - 1), f = 1; c > f; f++) d[f - 1] = arguments[f];
  225. for (f = 0, c = this._all.length; c > f; f++) this.event = b, this._all[f].apply(this, d);
  226. }
  227. if ("error" === b && !(this._all || this._events.error || this.wildcard && this.listenerTree.error)) throw arguments[1] instanceof Error ? arguments[1] : new Error("Uncaught, unspecified 'error' event.");
  228. var g;
  229. if (this.wildcard) {
  230. g = [];
  231. var h = "string" == typeof b ? b.split(this.delimiter) : b.slice();
  232. e.call(this, g, h, this.listenerTree, 0);
  233. } else g = this._events[b];
  234. if ("function" == typeof g) {
  235. if (this.event = b, 1 === arguments.length) g.call(this); else if (arguments.length > 1) switch (arguments.length) {
  236. case 2:
  237. g.call(this, arguments[1]);
  238. break;
  239. case 3:
  240. g.call(this, arguments[1], arguments[2]);
  241. break;
  242. default:
  243. for (var c = arguments.length, d = new Array(c - 1), f = 1; c > f; f++) d[f - 1] = arguments[f];
  244. g.apply(this, d);
  245. }
  246. return !0;
  247. }
  248. if (g) {
  249. for (var c = arguments.length, d = new Array(c - 1), f = 1; c > f; f++) d[f - 1] = arguments[f];
  250. for (var i = g.slice(), f = 0, c = i.length; c > f; f++) this.event = b, i[f].apply(this, d);
  251. return i.length > 0 || !!this._all;
  252. }
  253. return !!this._all;
  254. }, d.prototype.on = function(b, c) {
  255. if ("function" == typeof b) return this.onAny(b), this;
  256. if ("function" != typeof c) throw new Error("on only accepts instances of Function");
  257. if (this._events || a.call(this), this.emit("newListener", b, c), this.wildcard) return f.call(this, b, c),
  258. this;
  259. if (this._events[b]) {
  260. if ("function" == typeof this._events[b]) this._events[b] = [ this._events[b], c ]; else if (g(this._events[b]) && (this._events[b].push(c),
  261. !this._events[b].warned)) {
  262. var d = h;
  263. "undefined" != typeof this._events.maxListeners && (d = this._events.maxListeners),
  264. d > 0 && this._events[b].length > d && (this._events[b].warned = !0, console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.", this._events[b].length),
  265. console.trace());
  266. }
  267. } else this._events[b] = c;
  268. return this;
  269. }, d.prototype.onAny = function(a) {
  270. if ("function" != typeof a) throw new Error("onAny only accepts instances of Function");
  271. return this._all || (this._all = []), this._all.push(a), this;
  272. }, d.prototype.addListener = d.prototype.on, d.prototype.off = function(a, b) {
  273. if ("function" != typeof b) throw new Error("removeListener only takes instances of Function");
  274. var c, d = [];
  275. if (this.wildcard) {
  276. var f = "string" == typeof a ? a.split(this.delimiter) : a.slice();
  277. d = e.call(this, null, f, this.listenerTree, 0);
  278. } else {
  279. if (!this._events[a]) return this;
  280. c = this._events[a], d.push({
  281. _listeners: c
  282. });
  283. }
  284. for (var h = 0; h < d.length; h++) {
  285. var i = d[h];
  286. if (c = i._listeners, g(c)) {
  287. for (var j = -1, k = 0, l = c.length; l > k; k++) if (c[k] === b || c[k].listener && c[k].listener === b || c[k]._origin && c[k]._origin === b) {
  288. j = k;
  289. break;
  290. }
  291. if (0 > j) continue;
  292. return this.wildcard ? i._listeners.splice(j, 1) : this._events[a].splice(j, 1),
  293. 0 === c.length && (this.wildcard ? delete i._listeners : delete this._events[a]),
  294. this;
  295. }
  296. (c === b || c.listener && c.listener === b || c._origin && c._origin === b) && (this.wildcard ? delete i._listeners : delete this._events[a]);
  297. }
  298. return this;
  299. }, d.prototype.offAny = function(a) {
  300. var b, c = 0, d = 0;
  301. if (a && this._all && this._all.length > 0) {
  302. for (b = this._all, c = 0, d = b.length; d > c; c++) if (a === b[c]) return b.splice(c, 1),
  303. this;
  304. } else this._all = [];
  305. return this;
  306. }, d.prototype.removeListener = d.prototype.off, d.prototype.removeAllListeners = function(b) {
  307. if (0 === arguments.length) return !this._events || a.call(this), this;
  308. if (this.wildcard) for (var c = "string" == typeof b ? b.split(this.delimiter) : b.slice(), d = e.call(this, null, c, this.listenerTree, 0), f = 0; f < d.length; f++) {
  309. var g = d[f];
  310. g._listeners = null;
  311. } else {
  312. if (!this._events[b]) return this;
  313. this._events[b] = null;
  314. }
  315. return this;
  316. }, d.prototype.listeners = function(b) {
  317. if (this.wildcard) {
  318. var c = [], d = "string" == typeof b ? b.split(this.delimiter) : b.slice();
  319. return e.call(this, c, d, this.listenerTree, 0), c;
  320. }
  321. return this._events || a.call(this), this._events[b] || (this._events[b] = []),
  322. g(this._events[b]) || (this._events[b] = [ this._events[b] ]), this._events[b];
  323. }, d.prototype.listenersAny = function() {
  324. return this._all ? this._all : [];
  325. }, "function" == typeof define && define.amd ? define(function() {
  326. return d;
  327. }) : "object" == typeof c ? c.EventEmitter2 = d : window.EventEmitter2 = d;
  328. }();
  329. }, {} ],
  330. 7: [ function(a, b) {
  331. var c, d, e, f, g, h, i, j, k, l, m, n, o = {}.hasOwnProperty, p = function(a, b) {
  332. function c() {
  333. this.constructor = a;
  334. }
  335. for (var d in b) o.call(b, d) && (a[d] = b[d]);
  336. return c.prototype = b.prototype, a.prototype = new c(), a.__super__ = b.prototype,
  337. a;
  338. };
  339. f = a("eventemitter2").EventEmitter2, n = a("./common.coffee"), h = n.HEIGHT, m = n.WIDTH,
  340. j = n.RATE, k = 3.5, l = 4.5, c = .2, e = 2e3, i = .6, g = .9, d = function(a) {
  341. function b() {
  342. b.__super__.constructor.call(this, this), this.x = 0, this.y = 0, this.vx = k, this.vy = l,
  343. this.then = null, this.acc = null, this.bird = null, this.leftBricksPos = [], this.rightBricksPos = [],
  344. this.rotateY = 180, this.rotateZ = 0, this.width = 50, this.height = 32, this.isRunning = !1,
  345. this.FLIPP_DIRCT = -1;
  346. }
  347. return p(b, a), b.prototype.init = function(a, b) {
  348. return this.bird = a, this.bounds = b, this.bird.width = this.width, this.bird.height = this.height,
  349. this.reset(), this.draw(), this.show();
  350. }, b.prototype.show = function() {
  351. return this.bird.style.display = "block";
  352. }, b.prototype.reset = function() {
  353. var a;
  354. return this.isDie = !0, this.isRunning = !1, this.x = this.CENTER_X = (m - this.bird.width) / 2,
  355. this.y = this.CENTER_Y = h / 2 - this.bird.height + 10, this.vx = 0, this.vy = 0,
  356. this.rotateZ = 0, this.FLIPP_DIRCT = -1, this.leftBricksPos = [], this.rightBricksPos = [],
  357. this.turnRight(), this.changeBirdStatus(a = !1), this.bird.className = "bird";
  358. }, b.prototype.revive = function() {
  359. return this.isDie = !1, this.isRunning = !0, this.vx = k, this.vy = -l;
  360. }, b.prototype.move = function() {
  361. var a, b;
  362. if (!this.then) return this.acc = 0, this.then = +new Date();
  363. for (a = +new Date(), b = a - this.then, this.acc += b; this.acc > j; ) this.update(),
  364. this.acc -= j;
  365. return this.then = a, this.draw();
  366. }, b.prototype.update = function() {
  367. return this.isRunning ? this.isDie ? this.bounce() : (this.updateX(), this.updateY()) : this.flipping();
  368. }, b.prototype.updateX = function() {
  369. return this.checkTouchSideBricks(), (this.x > m - this.bird.width || this.x < 0) && (this.x = this.x < 0 ? 0 : m - this.bird.width,
  370. this.vx = -this.vx, this.vx > 0 ? this.turnRight() : this.turnLeft(), this.emit("turn around")),
  371. this.x += this.vx;
  372. }, b.prototype.checkTouchSideBricks = function() {
  373. var a, b, c, d, e, f, g;
  374. if (this.x < this.bounds.left) {
  375. if (!(this.vx < 0)) return;
  376. a = this.leftBricksPos;
  377. } else {
  378. if (!(this.x > this.bounds.right - this.bird.width)) return;
  379. if (!(this.vx > 0)) return;
  380. a = this.rightBricksPos;
  381. }
  382. for (e = 0, f = a.length; f > e; e++) if (c = a[e], b = this.bounds.up + c * this.bounds.brickWidth,
  383. d = b + this.bounds.brickWidth, b < (g = this.y) && d > g) return this.die();
  384. }, b.prototype.bounce = function() {
  385. return this.vy += .5, this.y += this.vy, this.x += this.vx, this.rotateZ += this.vRotateZ,
  386. (this.x < 0 || this.x > m - this.bird.width) && (this.vx = -this.vx * i, this.x = this.x < 0 ? 0 : m - this.bird.width),
  387. (this.y <= this.bounds.up || this.y >= this.bounds.down - this.bird.height) && (this.vy = -this.vy * i,
  388. this.vx = this.vx * g, this.y = this.y <= this.bounds.up ? this.bounds.up : this.bounds.down - this.bird.height),
  389. this.vRotateZ = 15 * (this.vx / k);
  390. }, b.prototype.flipping = function() {
  391. var a;
  392. return a = 12, this.y >= this.CENTER_Y + 5 ? this.FLIPP_DIRCT = -1 : this.y <= this.CENTER_Y - a && (this.FLIPP_DIRCT = 1),
  393. this.y += .6 * this.FLIPP_DIRCT;
  394. }, b.prototype.updateY = function() {
  395. return this.isDie ? void 0 : (this.y <= this.bounds.up || this.y >= this.bounds.down - this.bird.height ? this.die() : this.vy += c,
  396. this.y += this.vy);
  397. }, b.prototype.turnRight = function() {
  398. return this.rotateY = 0;
  399. }, b.prototype.turnLeft = function() {
  400. return this.rotateY = 180;
  401. }, b.prototype.draw = function() {
  402. return this.bird.style.webkitTransform = "translate3d(" + this.x + "px, " + this.y + "px, 0) rotateY(" + this.rotateY + "deg) rotateZ(" + this.rotateZ + "deg)";
  403. }, b.prototype.flip = function() {
  404. return this.vy = -l;
  405. }, b.prototype.die = function() {
  406. var a;
  407. return this.vx = -this.vx / this.vx * 5, this.vy = -l, this.vRotateZ = 15, this.isDie = !0,
  408. this.emit("die"), this.changeBirdStatus(a = !0), this.bounce(), setTimeout(function(a) {
  409. return function() {
  410. return a.emit("die end");
  411. };
  412. }(this), e);
  413. }, b.prototype.changeBirdStatus = function(a) {
  414. return a ? (this.bird.src = "assets/dead-bird.png", this.rotateY = 0) : this.bird.src = "assets/bird.png";
  415. }, b.prototype.isOnTheGround = function() {
  416. return this.y >= this.bounds.down - this.bird.height ? !0 : !1;
  417. }, b;
  418. }(f), b.exports = new d();
  419. }, {
  420. "./common.coffee": 10,
  421. eventemitter2: 6
  422. } ],
  423. 8: [ function(a, b) {
  424. var c, d, e, f, g, h, i, j, k, l, m, n = {}.hasOwnProperty, o = function(a, b) {
  425. function c() {
  426. this.constructor = a;
  427. }
  428. for (var d in b) n.call(b, d) && (a[d] = b[d]);
  429. return c.prototype = b.prototype, a.prototype = new c(), a.__super__ = b.prototype,
  430. a;
  431. };
  432. c = a("../../lib/util").$, f = a("eventemitter2").EventEmitter2, m = a("./common.coffee"),
  433. i = m.WIDTH, g = m.HEIGHT, h = .8, d = 20, k = c(".left-wall"), l = c(".right-wall"),
  434. e = function(a) {
  435. function b() {
  436. this.leftBrick = null, this.rightBrick = null, this.topBrick = null, this.bottomBrick = null,
  437. this.brickWidth = null, this.dist = null, this.bricksCount = 1, this.leftBricksPos = null,
  438. this.rightBricksPos = null;
  439. }
  440. return o(b, a), b.prototype.init = function(a, b) {
  441. return this.dist = b, this.brickWidth = a, this.setGroups(b / 2), this.initBricks(a),
  442. this.initBottomBricks(), this.initTopBricks(), this.initWalls();
  443. }, b.prototype.initBricks = function(a) {
  444. var b, c;
  445. return b = "#fed37f", c = d, this.leftBrick = j("left"), this.leftBrick.style.cssText = "border-left: " + c + "px solid " + b + ";\nborder-top: " + a / 2 + "px solid transparent;\nborder-bottom: " + a / 2 + "px solid transparent;",
  446. this.rightBrick = j("right"), this.rightBrick.style.cssText = "border-right: " + c + "px solid " + b + ";\nborder-top: " + a / 2 + "px solid transparent;\nborder-bottom: " + a / 2 + "px solid transparent;",
  447. this.bottomBrick = j("bottom"), this.bottomBrick.style.cssText = "border-bottom: " + c + "px solid " + b + ";\nborder-right: " + a / 2 + "px solid transparent;\nborder-left: " + a / 2 + "px solid transparent;\ntop: " + -c * h + "px;",
  448. this.topBrick = j("top"), this.topBrick.style.cssText = "border-top: " + c + "px solid " + b + ";\nborder-right: " + a / 2 + "px solid transparent;\nborder-left: " + a / 2 + "px solid transparent;\nbottom: " + -c * h + "px;";
  449. }, b.prototype.setGroups = function(a) {
  450. return c(".up-ground").style.height = "" + a + "px", c(".down-ground").style.height = "" + a + "px";
  451. }, b.prototype.initBottomBricks = function() {
  452. var a, b, d, e, f, g;
  453. for (b = c(".down-ground"), g = [], d = e = 0, f = i / this.brickWidth - 1; f >= 0 ? f >= e : e >= f; d = f >= 0 ? ++e : --e) a = this.bottomBrick.cloneNode(!0),
  454. a.style.left = "" + d * this.brickWidth + "px", g.push(b.appendChild(a));
  455. return g;
  456. }, b.prototype.initTopBricks = function() {
  457. var a, b, d, e, f, g;
  458. for (d = c(".up-ground"), g = [], b = e = 0, f = i / this.brickWidth - 1; f >= 0 ? f >= e : e >= f; b = f >= 0 ? ++e : --e) a = this.topBrick.cloneNode(!0),
  459. a.style.left = "" + b * this.brickWidth + "px", g.push(d.appendChild(a));
  460. return g;
  461. }, b.prototype.getBounds = function() {
  462. var a, b, c, e;
  463. return e = this.dist / 2 + d * h, a = g - (this.dist / 2 + d * h), b = d, c = i - d,
  464. {
  465. up: e,
  466. down: a,
  467. left: b,
  468. right: c,
  469. brickWidth: this.brickWidth
  470. };
  471. }, b.prototype.initWalls = function() {
  472. return k.style.height = "" + 11 * this.brickWidth + "px", k.style.width = "" + d + "px",
  473. l.style.height = "" + 11 * this.brickWidth + "px", l.style.width = "" + d + "px",
  474. window.a = this;
  475. }, b.prototype.hideLeft = function() {
  476. return this.leftBricksPos = [], k.style.webkitTransform = "translate3d(" + -d + "px, 0, 0)";
  477. }, b.prototype.showLeftWithRandomBricks = function() {
  478. var a, b, c, d, e, f, g;
  479. for (k.innerHTML = "", d = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], this.leftBricksPos = [],
  480. b = f = 1, g = this.bricksCount; g >= 1 ? g >= f : f >= g; b = g >= 1 ? ++f : --f) c = Math.floor(Math.random() * d.length),
  481. e = d[c], d.splice(c, 1), this.leftBricksPos.push(e), a = this.leftBrick.cloneNode(!0),
  482. a.style.webkitTransform = "translate3d(0, " + e * this.brickWidth + "px, 0)", k.appendChild(a);
  483. return this.emit("left bricks change", this.leftBricksPos), k.style.webkitTransform = "translate3d(0, 0, 0)";
  484. }, b.prototype.hideRight = function() {
  485. return this.rightBricksPos = [], l.style.webkitTransform = "translate3d(" + d + "px, 0, 0)";
  486. }, b.prototype.showRightWithRandomBricks = function() {
  487. var a, b, c, d, e, f, g;
  488. for (l.innerHTML = "", d = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], this.rightBricksPos = [],
  489. b = f = 1, g = this.bricksCount; g >= 1 ? g >= f : f >= g; b = g >= 1 ? ++f : --f) c = Math.floor(Math.random() * d.length),
  490. e = d[c], d.splice(c, 1), this.rightBricksPos.push(e), a = this.rightBrick.cloneNode(!0),
  491. a.style.webkitTransform = "translate3d(0, " + e * this.brickWidth + "px, 0)", l.appendChild(a);
  492. return this.emit("right bricks change", this.rightBricksPos), l.style.webkitTransform = "translate3d(0, 0, 0)";
  493. }, b;
  494. }(f), j = function(a) {
  495. var b;
  496. return b = document.createElement("div"), b.className = "angle " + a, b;
  497. }, b.exports = new e();
  498. }, {
  499. "../../lib/util": 5,
  500. "./common.coffee": 10,
  501. eventemitter2: 6
  502. } ],
  503. 9: [ function(a, b) {
  504. var c, d, e, f, g, h, i = {}.hasOwnProperty, j = function(a, b) {
  505. function c() {
  506. this.constructor = a;
  507. }
  508. for (var d in b) i.call(b, d) && (a[d] = b[d]);
  509. return c.prototype = b.prototype, a.prototype = new c(), a.__super__ = b.prototype,
  510. a;
  511. };
  512. c = a("../../lib/util").$, e = a("eventemitter2").EventEmitter2, h = a("./common.coffee"),
  513. g = h.WIDTH, f = h.HEIGHT, d = function(a) {
  514. function b() {
  515. b.__super__.constructor.call(this, this), this.$candy = c(".candy"), this.width = 25,
  516. this.height = 25, this.isShow = !1, this.$showScore1 = c("#showScore1"), this.$showScore2 = c("#showScore2"),
  517. this.x = 0, this.y = 0, this.score1Lock = !1;
  518. }
  519. return j(b, a), b.prototype.init = function(a) {
  520. return this.bounds = a, this.$candy.style.width = "" + this.width + "px", this.$candy.style.height = "" + this.height + "px";
  521. }, b.prototype.show = function() {
  522. return this.$candy.style.display = "block", this.isShow = !0;
  523. }, b.prototype.hideScore = function() {
  524. return this.$isShowScore1 ? this.$showScore2.style.display = "none" : this.$showScore1.style.display = "none";
  525. }, b.prototype.hide = function() {
  526. return this.$candy.style.display = "none", this.isShow = !1;
  527. }, b.prototype.moveToRandomPos = function(a) {
  528. var b, c, d;
  529. return b = 25, c = a ? this.bounds.right - this.width - b : this.bounds.left + b,
  530. d = this.bounds.up + b + (this.bounds.down - this.bounds.up - this.height - 6 * b) * Math.random(),
  531. this.moveTo(c, d);
  532. }, b.prototype.moveTo = function(a, b) {
  533. return this.x = a, this.y = b, this.$candy.style.left = "" + a + "px", this.$candy.style.top = "" + b + "px",
  534. this.score1Lock ? (this.$showScore2.style.left = "" + a + "px", this.$showScore2.style.top = "" + (b - 15) + "px",
  535. this.score1Lock = !1) : (this.$showScore1.style.left = "" + a + "px", this.$showScore1.style.top = "" + (b - 15) + "px",
  536. this.score1Lock = !0);
  537. }, b.prototype.displayScore = function() {
  538. return this.score1Lock ? (this.$showScore1.style.display = "block", setTimeout(function(a) {
  539. return function() {
  540. return a.$showScore1.style.display = "none";
  541. };
  542. }(this), 500)) : (this.$showScore2.style.display = "block", setTimeout(function(a) {
  543. return function() {
  544. return a.$showScore2.style.display = "none";
  545. };
  546. }(this), 500));
  547. }, b;
  548. }(e), b.exports = new d();
  549. }, {
  550. "../../lib/util": 5,
  551. "./common.coffee": 10,
  552. eventemitter2: 6
  553. } ],
  554. 10: [ function(a, b) {
  555. var c, d, e, f, g, h;
  556. d = document.documentElement.clientHeight, h = document.documentElement.clientWidth,
  557. e = 568, f = 360, d = d > e ? e : d, h = h > f ? f : h, navigator.userAgent.indexOf("AppleWebKit/537") > 0 && 480 === d && (d = 416),
  558. g = 16.7, c = window.navigator.userAgent, b.exports = {
  559. HEIGHT: d,
  560. WIDTH: h,
  561. RATE: g,
  562. AGENT: c
  563. };
  564. }, {} ],
  565. 11: [ function(a, b) {
  566. var c, d, e, f, g, h, i, j, k, l;
  567. k = a("../../lib/util"), l = a("./common.coffee"), e = l.HEIGHT, g = l.WIDTH, f = l.RATE,
  568. d = l.AGENT, c = k.$, j = c("#debug"), h = d.match(/AppleWebKit\/.+?\s/)[0], i = {
  569. count: 0,
  570. move: function() {
  571. var a;
  572. return a = k.fps(), 10 === ++this.count ? (this.count = 0, j.innerHTML = "<p>width: " + g + ", height: " + e + ", FPS: " + a + "</p>\n<hr>\n<p>" + h + "</p>") : void 0;
  573. }
  574. }, b.exports = i;
  575. }, {
  576. "../../lib/util": 5,
  577. "./common.coffee": 10
  578. } ],
  579. 12: [ function(a) {
  580. var b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P;
  581. i = a("../../lib/game"), n = a("./bird.coffee"), r = a("./candy.coffee"), v = a("./debug.coffee"),
  582. K = a("./states.coffee"), p = a("./bricks.coffee"), G = a("../../lib/r"), P = a("../../lib/util"),
  583. u = a("./common.coffee"), j = u.HEIGHT, l = u.WIDTH, b = P.$, x = new i(), c = b(".area"),
  584. h = b("#score"), d = b("h1.name"), g = b("div.instruction"), f = b("h2.highest-score"),
  585. e = b("#highest-score"), I = 0, u.turnCount = 0, z = 0, q = "#6b6480", m = "#e6e2f4",
  586. k = "highest-score", x.on("init", function() {
  587. return setTimeout(function() {
  588. return function() {
  589. return window.cb_finishload(), A(), C(), E(), B(), D(), H(), t(), K.change("start");
  590. };
  591. }(this), 2e3);
  592. }), A = function() {
  593. return c.style.height = "" + j + "px", c.style.width = "" + l + "px";
  594. }, B = function() {
  595. var a;
  596. return a = b(".bird"), a.className = "bird", c.appendChild(a), n.init(a, p.getBounds()),
  597. w(), o(), x.add(n);
  598. }, D = function() {
  599. return r.init(p.getBounds()), n.on("turn around", function() {
  600. var a;
  601. if (!r.isShow) return r.show(), F() ? r.moveToRandomPos() : r.moveToRandomPos(a = !0);
  602. });
  603. }, t = function() {
  604. return x.add({
  605. move: function() {
  606. var a, b;
  607. if (r.isShow) return b = r.x < n.x + n.width && n.x < r.x + r.width, a = r.y < n.y + n.height && n.y < r.y + r.height,
  608. b && a ? (I += 2, N(I), r.hide(), r.displayScore()) : void 0;
  609. }
  610. });
  611. }, s = function() {
  612. return I > 15 && 30 >= I && "#738163" !== q ? O("#738163", "#e7f2dd") : I > 30 && 50 >= I && "#627680" !== q ? O("#627680", "#deebef") : I > 50 && 70 >= I && "#00bfeb" !== q ? O("#00bfeb", "#006b83") : I > 70 && "#ffffff" !== q ? O("#ffffff", "#727272") : void 0;
  613. }, O = function(a, d) {
  614. var e, f, g, i, j, k, l, n, o, r, s, t, u, v, w, x, y;
  615. for (q = a, m = d, u = b(".angle.bottom"), g = 0, l = u.length; l > g; g++) e = u[g],
  616. e.style.borderBottomColor = a;
  617. for (v = b(".angle.top"), i = 0, n = v.length; n > i; i++) e = v[i], e.style.borderTopColor = a;
  618. for (w = b(".angle.left"), j = 0, o = w.length; o > j; j++) e = w[j], e.style.borderLeftColor = a;
  619. for (x = b(".angle.right"), k = 0, r = x.length; r > k; k++) e = x[k], e.style.borderRightColor = a;
  620. for (y = b(".ground"), t = 0, s = y.length; s > t; t++) f = y[t], f.style.backgroundColor = a;
  621. return p.leftBrick.style.borderLeftColor = a, p.rightBrick.style.borderRightColor = a,
  622. c.style.backgroundColor = d, h.style.color = d;
  623. }, o = function() {
  624. return n.on("turn around", function() {
  625. return I++, s(), u.turnCount++, N(), F() ? (p.hideRight(), p.showLeftWithRandomBricks()) : (p.hideLeft(),
  626. p.showRightWithRandomBricks());
  627. }), p.on("left bricks change", function(a) {
  628. return n.leftBricksPos = a;
  629. }), p.on("right bricks change", function(a) {
  630. return n.rightBricksPos = a;
  631. });
  632. }, F = function() {
  633. return n.vx < 0;
  634. }, C = function() {
  635. var a, b;
  636. return a = 35, b = j - 13 * a, 0 > b && (a = Math.floor(j / 13), b = 0), p.init(a, b);
  637. }, E = function() {
  638. return K.on("start", function() {
  639. return O("#6b6480", "#e6e2f4"), I = 0, u.turnCount = 0, h.style.display = "none",
  640. N(), p.hideLeft(), p.hideRight(), n.reset(), r.hide(), J();
  641. }), K.on("game", function() {
  642. return window.cb_start(), h.style.display = "block", n.revive(), y();
  643. }), n.on("die end", function() {
  644. return K.change("over", I);
  645. });
  646. }, y = function() {
  647. return d.style.display = "none", f.style.display = "none", g.style.display = "none";
  648. }, J = function() {
  649. return d.style.display = "block", f.style.display = "block", g.style.display = "block";
  650. }, w = function() {
  651. return window.addEventListener("touchstart", function() {
  652. return "game" !== K.state || n.isDie ? void 0 : n.flip();
  653. });
  654. }, N = function() {
  655. return u.score = I, L(I), h.innerHTML = I, I > z ? M() : void 0;
  656. }, M = function() {
  657. return z = I, localStorage.setItem(k, z), e.innerHTML = z;
  658. }, L = function(a) {
  659. var b;
  660. return b = Math.floor(a / 10) + 2, b > 10 && (b = 10), p.bricksCount = b;
  661. }, H = function() {
  662. return z = localStorage.getItem(k), z = z || 0, e.innerHTML = "" + z;
  663. }, document.ontouchstart = function(a) {
  664. return a.preventDefault();
  665. }, x.init();
  666. }, {
  667. "../../lib/game": 2,
  668. "../../lib/r": 4,
  669. "../../lib/util": 5,
  670. "./bird.coffee": 7,
  671. "./bricks.coffee": 8,
  672. "./candy.coffee": 9,
  673. "./common.coffee": 10,
  674. "./debug.coffee": 11,
  675. "./states.coffee": 13
  676. } ],
  677. 13: [ function(a, b) {
  678. var c, d, e, f, g, h, i, j, k, l, m = {}.hasOwnProperty, n = function(a, b) {
  679. function c() {
  680. this.constructor = a;
  681. }
  682. for (var d in b) m.call(b, d) && (a[d] = b[d]);
  683. return c.prototype = b.prototype, a.prototype = new c(), a.__super__ = b.prototype,
  684. a;
  685. }, o = [].indexOf || function(a) {
  686. for (var b = 0, c = this.length; c > b; b++) if (b in this && this[b] === a) return b;
  687. return -1;
  688. };
  689. l = a("../../lib/util"), d = a("eventemitter2").EventEmitter2, f = a("./common.coffee"),
  690. k = [ "start", "game", "over", "share" ], c = l.$, window.imgUrl = window.location.href.replace(/\w+\.html$/, "") + "assets/bird.png",
  691. window.lineLink = window.location.href, e = function(a) {
  692. function b() {
  693. b.__super__.constructor.call(this, this), window.change = this.change, window.context = this,
  694. this.$over = c("#over"), this.$share = c("#share"), this.$gameTips = c("#over .gameTips"),
  695. this.$score = c("#over .score"), this.$rank = c("#over .rank"), this.$bullShit = c("#over .bull-shit"),
  696. this.$count = c("#share .count"), this.state = "start", this.init();
  697. }
  698. return n(b, a), b.prototype.init = function() {
  699. return this.initOverState(), this.initShareState(), window.addEventListener("touchstart", function(a) {
  700. return function() {
  701. return "start" === a.state ? a.change("game") : void 0;
  702. };
  703. }(this));
  704. }, b.prototype.initOverState = function() {
  705. return c("#over div.again").addEventListener("touchstart", function(a) {
  706. return function(b) {
  707. return b.stopPropagation(), window.cb_restart(), a.change("start");
  708. };
  709. }(this)), c("#over div.show-off").addEventListener("touchstart", function(a) {
  710. return function() {
  711. return event.stopPropagation(), a.change("share");
  712. };
  713. }(this)), c("#over div.more-game").addEventListener("touchstart", function() {
  714. return function() {
  715. return event.stopPropagation(), window.cb_more();
  716. };
  717. }(this));
  718. }, b.prototype.initShareState = function() {}, b.prototype.change = function(a, b) {
  719. if (o.call(k, a) < 0) throw "" + a + " is not in states";
  720. return this.state = a, this.toggleOverState(a, b), "share" === a && this.showShare(),
  721. this.emit(a);
  722. }, b.prototype.toggleOverState = function(a, b) {
  723. return "share" !== a ? "over" === a ? (this.$score.innerHTML = b,
  724. window.myText = getGameEndTips(),this.$gameTips.innerHTML = window.myText , window.cb_gameover(b), this.$rank.innerHTML = h(b), this.$bullShit.innerHTML = g(b),
  725. this.$over.style.display = "block", 1 === window.haveShare && 0 === window.haveGamelist ? c("#over div.more-game").style.display = "none" : 1 === window.haveShare && 1 === window.haveGamelist ? c("#over div.more-game").style.display = "none" : 0 === window.haveShare && 1 === window.haveGamelist ? c("#over div.show-off").style.display = "none" : 0 === window.haveShare && 0 === window.haveGamelist && (c("#over div.show-off").style.display = "none",
  726. c("#over div.more-game").style.display = "none")) : this.$over.style.display = "none" : void 0;
  727. }, b.prototype.showShare = function() {
  728. return window.cb_share();
  729. }, b;
  730. }(d), getGameEndTips = function() {
  731. var endGameTips = [ "祝处女座生日快乐,为不创造下一个处女座努力", "纯,属虚构;乱,是佳人", "挣的是临时工的钱,操的是CEO的心", "只要你努力,世上没什么事是你搞不砸的", "为什么我做得这么差,如果没有压力,我可以更差", "最近又胖了,打电话时一笑脸蛋子就碰能到挂机键", "帅哥尽量少娶美女,因为龙凤成翔", "挤公交=散打+瑜珈+柔道+平衡木", "枯藤老树昏鸦,空调wifi西瓜,午饭有鱼有虾,你丑没事我瞎", "你骂我,因为你不了解我,等你了解我,你会动手打我", "去一次星巴克,拍365张照片,发一年朋友圈", "今天上街碰到一个臭流氓,我实在受不了了,就帮他洗了个澡", "明日复明日,明日何其多!既然这么多,不妨再拖拖", "大王叫偶来巡山,巡了南山,巡北山呐!", "多情...暂且...爆刘继芬呐!", "你不是VIP,甚至不是IP,你只是一个P", "我要成为海贼王的男人", "不以风骚惊天下,就以淫荡动世人", "问君能有几多愁,恰似一群太监上青楼", "时间过的真快,刚起床就天黑了", "放自己的屁,让别人闻去吧", "如果有人伤害了你,可以怨恨,但不要太久", "如果有人辜负了你,可以愤怒,但不要记挂", "我真想亲口管你爷爷叫声:“爸”", "我自横刀向天笑,笑完我就去睡觉", "我猜中了开始,但是没有猜中结局!", "人活着没有梦想,跟咸鱼有什么区别?", "黑丝泛滥的季节,让我们这些粗腿情何以堪?", "笑我的人,麻烦你先把牙刷白了!", "看电视说“吸烟导致猝死”,赶紧抽根烟压压惊!看电视太可怕了!", "虽然我长的不是很帅,但小时候也有人夸我左边鼻孔很偶像派。", "我是你转身就忘的路人甲,凭什么陪你蹉跎年华到天涯","“妹妹你坐船头啊,哥哥在岸上走”99%的人都是唱出来的!" ];
  732. var index = parseInt(endGameTips.length * Math.random());
  733. return endGameTips[index];
  734. }, h = function(a) {
  735. return a >= 0 && 3 >= a ? i(6) : a >= 4 && 6 >= a ? i(8) : a >= 7 && 10 >= a ? i(10) : a >= 11 && 13 >= a ? i(21) : a >= 14 && 16 >= a ? i(32) : a >= 17 && 20 >= a ? i(43) : a >= 21 && 23 >= a ? i(50) : a >= 24 && 26 >= a ? i(62) : a >= 27 && 30 >= a ? i(69) : a >= 31 && 33 >= a ? i(73) : a >= 34 && 36 >= a ? i(79) : a >= 37 && 40 >= a ? i(85) : a >= 41 && 45 >= a ? i(88) : a >= 46 && 50 >= a ? i(90) : a >= 51 && 55 >= a ? i(92) : a >= 56 && 60 >= a ? i(94) : a >= 61 && 65 >= a ? i(95) : a >= 65 && 70 >= a ? i(96) : a > 70 ? j(10, 99) : void 0;
  736. }, i = function(a) {
  737. return "打败了全国" + a + "%的人";
  738. }, j = function(a, b) {return "排在全国" + (a + Math.floor((b - a + 1) * Math.random())) + "名"}, g = function(a) {
  739. switch (true) {
  740. case a >= 200:
  741. return "我的鸟太完美!";
  742. case a >= 100:
  743. return "不是所有的鸟都可以上百分!";
  744. case a >= 80:
  745. return "我的鸟带着钉子探测仪!";
  746. case a >= 70:
  747. return "我的鸟和你的不一样!";
  748. case a >= 60:
  749. return "带你装逼带你飞!";
  750. case a >= 50:
  751. return "我的鸟翱翔于蓝天白云之上!";
  752. case a >= 40:
  753. return "我的鸟对钉子不感冒!";
  754. case a >= 30:
  755. return "我再也不想和钉子亲密接触!";
  756. case a >= 20:
  757. return "我对钉子爱的深沉!";
  758. case a > 0:
  759. return "OMG,我的鸟被扎了!";
  760. default:
  761. return "这都行,钉子是不是开挂了?";
  762. }
  763. }, b.exports = new e();
  764. }, {
  765. "../../lib/util": 5,
  766. "./common.coffee": 10,
  767. eventemitter2: 6
  768. } ]
  769. }, {}, [ 12 ]);