9.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. function Delegate(){}
  2. Delegate.create=function(o,f){var a=new Array();var l=arguments.length;for(var i=2;i<l;i++)a[i-2]=arguments[i];return function(){var aP=[].concat(arguments,a);f.apply(o,aP);}}
  3. Tween=function(obj,prop,func,begin,finish,duration,suffixe){this.init(obj,prop,func,begin,finish,duration,suffixe)}
  4. var t=Tween.prototype;t.obj=new Object();t.prop='';t.func=function(t,b,c,d){return c*t/d+b;};t.begin=0;t.change=0;t.prevTime=0;t.prevPos=0;t.looping=false;t._duration=0;t._time=0;t._pos=0;t._position=0;t._startTime=0;t._finish=0;t.name='';t.suffixe='';t._listeners=new Array();t.setTime=function(t){this.prevTime=this._time;if(t>this.getDuration()){if(this.looping){this.rewind(t-this._duration);this.update();this.broadcastMessage('onMotionLooped',{target:this,type:'onMotionLooped'});}else{this._time=this._duration;this.update();this.stop();this.broadcastMessage('onMotionFinished',{target:this,type:'onMotionFinished'});}}else if(t<0){this.rewind();this.update();}else{this._time=t;this.update();}}
  5. t.getTime=function(){return this._time;}
  6. t.setDuration=function(d){this._duration=(d==null||d<=0)?100000:d;}
  7. t.getDuration=function(){return this._duration;}
  8. t.setPosition=function(p){this.prevPos=this._pos;var a=this.suffixe!=''?this.suffixe:'';this.obj[this.prop]=Math.round(p)+a;this._pos=p;this.broadcastMessage('onMotionChanged',{target:this,type:'onMotionChanged'});}
  9. t.getPosition=function(t){if(t==undefined)t=this._time;return this.func(t,this.begin,this.change,this._duration);};t.setFinish=function(f){this.change=f-this.begin;};t.getFinish=function(){return this.begin+this.change;};t.init=function(obj,prop,func,begin,finish,duration,suffixe){if(!arguments.length)return;this._listeners=new Array();this.addListener(this);if(suffixe)this.suffixe=suffixe;this.obj=obj;this.prop=prop;this.begin=begin;this._pos=begin;this.setDuration(duration);if(func!=null&&func!=''){this.func=func;}
  10. this.setFinish(finish);}
  11. t.start=function(){this.rewind();this.startEnterFrame();this.broadcastMessage('onMotionStarted',{target:this,type:'onMotionStarted'});}
  12. t.rewind=function(t){this.stop();this._time=(t==undefined)?0:t;this.fixTime();this.update();}
  13. t.fforward=function(){this._time=this._duration;this.fixTime();this.update();}
  14. t.update=function(){this.setPosition(this.getPosition(this._time));}
  15. t.startEnterFrame=function(){this.stopEnterFrame();this.isPlaying=true;this.onEnterFrame();}
  16. t.onEnterFrame=function(){if(this.isPlaying){this.nextFrame();setTimeout(Delegate.create(this,this.onEnterFrame),0);}}
  17. t.nextFrame=function(){this.setTime((this.getTimer()-this._startTime)/1000);}
  18. t.stop=function(){this.stopEnterFrame();this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'});}
  19. t.stopEnterFrame=function(){this.isPlaying=false;}
  20. t.continueTo=function(finish,duration){this.begin=this._pos;this.setFinish(finish);if(this._duration!=undefined)
  21. this.setDuration(duration);this.start();}
  22. t.resume=function(){this.fixTime();this.startEnterFrame();this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionResumed'});}
  23. t.yoyo=function(){this.continueTo(this.begin,this._time);}
  24. t.addListener=function(o){this.removeListener(o);return this._listeners.push(o);}
  25. t.removeListener=function(o){var a=this._listeners;var i=a.length;while(i--){if(a[i]==o){a.splice(i,1);return true;}}
  26. return false;}
  27. t.broadcastMessage=function(){var arr=new Array();for(var i=0;i<arguments.length;i++){arr.push(arguments[i])}
  28. var e=arr.shift();var a=this._listeners;var l=a.length;for(var i=0;i<l;i++){if(a[i][e])
  29. a[i][e].apply(a[i],arr);}}
  30. t.fixTime=function(){this._startTime=this.getTimer()-this._time*1000;}
  31. t.getTimer=function(){return new Date().getTime()-this._time;}
  32. Tween.backEaseIn=function(t,b,c,d,a,p){if(s==undefined)var s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b;}
  33. Tween.backEaseOut=function(t,b,c,d,a,p){if(s==undefined)var s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;}
  34. Tween.backEaseInOut=function(t,b,c,d,a,p){if(s==undefined)var s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b;}
  35. Tween.elasticEaseIn=function(t,b,c,d,a,p){if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(!a||a<Math.abs(c)){a=c;var s=p/4;}
  36. else
  37. var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;}
  38. Tween.elasticEaseOut=function(t,b,c,d,a,p){if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(!a||a<Math.abs(c)){a=c;var s=p/4;}
  39. else var s=p/(2*Math.PI)*Math.asin(c/a);return(a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b);}
  40. Tween.elasticEaseInOut=function(t,b,c,d,a,p){if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)var p=d*(.3*1.5);if(!a||a<Math.abs(c)){var a=c;var s=p/4;}
  41. else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b;}
  42. Tween.bounceEaseOut=function(t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;}}
  43. Tween.bounceEaseIn=function(t,b,c,d){return c-Tween.bounceEaseOut(d-t,0,c,d)+b;}
  44. Tween.bounceEaseInOut=function(t,b,c,d){if(t<d/2)return Tween.bounceEaseIn(t*2,0,c,d)*.5+b;else return Tween.bounceEaseOut(t*2-d,0,c,d)*.5+c*.5+b;}
  45. Tween.strongEaseInOut=function(t,b,c,d){return c*(t/=d)*t*t*t*t+b;}
  46. Tween.regularEaseIn=function(t,b,c,d){return c*(t/=d)*t+b;}
  47. Tween.regularEaseOut=function(t,b,c,d){return-c*(t/=d)*(t-2)+b;}
  48. Tween.regularEaseInOut=function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b;}
  49. Tween.strongEaseIn=function(t,b,c,d){return c*(t/=d)*t*t*t*t+b;}
  50. Tween.strongEaseOut=function(t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b;}
  51. Tween.strongEaseInOut=function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t*t+b;return c/2*((t-=2)*t*t*t*t+2)+b;}
  52. OpacityTween.prototype=new Tween();OpacityTween.prototype.constructor=Tween;OpacityTween.superclass=Tween.prototype;function OpacityTween(obj,func,fromOpacity,toOpacity,duration){this.targetObject=obj;this.init(new Object(),'x',func,fromOpacity,toOpacity,duration);}
  53. var o=OpacityTween.prototype;o.targetObject={};o.onMotionChanged=function(evt){var v=evt.target._pos;var t=this.targetObject;t.style['opacity']=v/100;t.style['-moz-opacity']=v/100;if(t.filters)t.filters.alpha['opacity']=v;}
  54. var w = 320;
  55. var h = 480;
  56. var cw = 320;
  57. var ch = 240;
  58. var fps = 1e3 / 30;
  59. var canvas, context, levelCount, imageSprite, timeout;
  60. var strings = {
  61. witr: "猜猜金币在哪儿?<br>(请选择)",
  62. fail: ["是不是眼花了?", "别瞎猜,看准了再选", "太快了吗?"],
  63. ok: ["这个太简单了", "还不错,不过这只是练习!", "你确定没有使诈?", "好", "再接再厉", "很好", "太棒了", "下一关会更难哦", "牛逼!", "不可思议", "太夸张了吧", "太厉害了有木有??", "你是怎么做到的?!", "肯定是运气!", "你的眼力那么好,你家人知道吗?", "不会再让你过关的,小心哦!", "简直无法置信!", "从来没有人能到这一关", "大神,教教我你的诀窍吧!", "我不玩了!我不玩了!"]
  64. };
  65. var init = function() {
  66. imageSprite = new Image;
  67. imageSprite.src = "2.png";
  68. play68_init();
  69. welcomeView()
  70. };
  71. var welcomeView = function() {
  72. var e = document.getElementById("logo");
  73. e.style.display = "block";
  74. var t = new OpacityTween(e, null, 0, 100, .5);
  75. t.start();
  76. t.onMotionFinished = function() {
  77. setTimeout(function() {
  78. var t = new OpacityTween(e, null, 100, 0, .5);
  79. t.start();
  80. t.onMotionFinished = function() {
  81. e.style.display = "none";
  82. menuView()
  83. }
  84. },
  85. 500)
  86. }
  87. };
  88. var menuView = function() {
  89. var e = document.getElementById("playButton");
  90. e.style.display = "block";
  91. var t = new OpacityTween(e, null, 0, 100, .5);
  92. t.start();
  93. t.onMotionFinished = function() {
  94. e.onclick = function(t) {
  95. e.style.display = "none";
  96. gameView();
  97. play68_init()
  98. }
  99. }
  100. };
  101. var gameView = function() {
  102. canvas = document.getElementById("canvas");
  103. canvas.style.display = "block";
  104. canvas.width = cw;
  105. canvas.height = ch;
  106. context = canvas.getContext("2d");
  107. levelCount = 1;
  108. livesCount = 3;
  109. var e = document.getElementById("level");
  110. var t = document.getElementById("lives");
  111. var n = false;
  112. e.innerHTML = "关卡:" + levelCount;
  113. e.style.display = t.style.display = "block";
  114. var r = document.getElementById("hearts");
  115. var i = "";
  116. for (var s = 0; s < livesCount; s++) {
  117. i += '<div class="heart">&nbsp;</div>'
  118. }
  119. r.innerHTML = i;
  120. var o = 28;
  121. var u = 28;
  122. var a = 15;
  123. var f = 0;
  124. var l = 0;
  125. var c = 60;
  126. var h = 100;
  127. var p = 50;
  128. var d = 53;
  129. var v = 57;
  130. var m = function() {
  131. this.draw = function() {
  132. context.fillStyle = "#222";
  133. context.fillRect(0, 0, cw, ch)
  134. }
  135. };
  136. var g = function() {
  137. this.draw = function() {
  138. context.drawImage(imageSprite, 6, 100, 82, 86, this.x - 41, this.y, 82, 86)
  139. }
  140. };
  141. var y = function() {
  142. this.draw = function() {
  143. var e = context.globalAlpha;
  144. try {
  145. context.globalAlpha = this.alpha
  146. } catch(t) {}
  147. context.drawImage(imageSprite, 94, 100, 82, 86, this.x - 41, this.y, 82, 86);
  148. try {
  149. context.globalAlpha = e
  150. } catch(t) {}
  151. }
  152. };
  153. var b = function() {
  154. this.draw = function() {
  155. context.drawImage(imageSprite, 257, 5, 82, 152, this.x - 41, this.y, 82, 152)
  156. }
  157. };
  158. var w = function() {
  159. this.draw = function() {
  160. context.drawImage(imageSprite, 159, 55, 44, 26, this.x - 22, this.y, 44, 26)
  161. }
  162. };
  163. var E = {
  164. bg: new m,
  165. bucketShadow: new y,
  166. coin: new w,
  167. bucket: new g,
  168. bucketWs1: new b,
  169. bucketWs2: new b
  170. };
  171. var S = c + (h + h * l);
  172. E.bucket.x = S;
  173. E.coin.x = S;
  174. E.coin.y = p + v;
  175. E.bucketShadow.x = S;
  176. E.bucketShadow.y = p + d;
  177. E.bucketWs1.x = c + (l == 0 ? 0 : h);
  178. E.bucketWs2.x = c + (l == 0 ? h * 2 : l == -1 ? +h * 2 : 0);
  179. E.bucket.y = E.bucketWs1.y = E.bucketWs2.y = p;
  180. var x = function(e) {
  181. if (n) {
  182. return
  183. }
  184. var t = c + (h + h * e);
  185. E.bucket.x = t;
  186. if (e != l) {
  187. E.coin.x = -2e3;
  188. E.coin.y = -2e3
  189. } else {
  190. E.coin.x = t;
  191. E.coin.y = p + v
  192. }
  193. E.bucketShadow.x = t;
  194. E.bucketWs1.x = c + (e == 0 ? 0 : h);
  195. E.bucketWs2.x = c + (e == 0 ? h * 2 : e == -1 ? +h * 2 : 0);
  196. var r = new Tween({},
  197. null, Tween.strongEaseInOut, 0, 50, 1);
  198. r.start();
  199. r.onMotionChanged = function(e) {
  200. var t = e.target._pos;
  201. E.bucket.y = p - t;
  202. E.bucketShadow.y = p + d + t;
  203. E.bucketShadow.alpha = 1 - t * .016;
  204. T()
  205. };
  206. r.onMotionFinished = function(e) {
  207. setTimeout(function() {
  208. var e = new Tween({},
  209. null, Tween.strongEaseInOut, 50, 0, 1);
  210. e.start();
  211. e.onMotionChanged = function(e) {
  212. var t = e.target._pos;
  213. E.bucket.y = p - t;
  214. E.bucketShadow.y = p + d + t;
  215. E.bucketShadow.alpha = 1 - t * .016;
  216. T()
  217. }
  218. },
  219. 500)
  220. }
  221. };
  222. var T = function() {
  223. for (key in E) {
  224. var e = E[key];
  225. e.draw()
  226. }
  227. };
  228. var N = function() {
  229. var e = document.getElementById("msg");
  230. e.style.display = "block";
  231. var t = new OpacityTween(e, null, 0, 100, .2);
  232. t.start();
  233. e.innerHTML = strings.witr
  234. };
  235. var C = function() {
  236. var e = document.getElementById("b");
  237. var t = document.getElementById("b1");
  238. var n = document.getElementById("b2");
  239. var r = document.getElementById("b3");
  240. e.style.display = t.style.display = n.style.display = r.style.display = "block";
  241. t.onclick = function(e) {
  242. O( - 1)
  243. };
  244. n.onclick = function(e) {
  245. O(0)
  246. };
  247. r.onclick = function(e) {
  248. O(1)
  249. }
  250. };
  251. var k = function() {
  252. if (n) {
  253. return
  254. }
  255. var e = document.getElementById("level");
  256. levelCount++;
  257. e.innerHTML = "关卡:" + levelCount;
  258. o = u + Math.sqrt(levelCount * 1.5);
  259. a += Math.floor(levelCount / 3)
  260. };
  261. var L = function() {
  262. if (n) {
  263. return
  264. }
  265. var e = document.getElementById("hearts");
  266. livesCount--;
  267. for (node in e.childNodes) {
  268. var t = e.childNodes[node];
  269. if (t.className == "heart") {
  270. var r = new OpacityTween(t, null, 100, 0, .5);
  271. r.start();
  272. r.onMotionFinished = function() {
  273. e.removeChild(t);
  274. if (livesCount < 1) {
  275. levelScore = levelCount;
  276. A();
  277. return
  278. }
  279. };
  280. break
  281. }
  282. }
  283. };
  284. var A = function() {
  285. clearTimeout(timeout);
  286. n = true;
  287. canvas.style.display = "none";
  288. var e = document.getElementById("level");
  289. var t = document.getElementById("lives");
  290. e.style.display = t.style.display = "none";
  291. updateShareScore(levelCount - 1);
  292. setTimeout(function() {
  293. show_share()
  294. },
  295. 1500);
  296. var r = document.getElementById("msg");
  297. r.style.display = "block";
  298. var i = new OpacityTween(r, null, 0, 100, .2);
  299. i.start();
  300. r.style.margin = "200px 0 0 0";
  301. r.innerHTML = "游戏结束";
  302. setTimeout(function() {
  303. r.style.display = "none";
  304. menuView()
  305. },
  306. 1500)
  307. };
  308. var O = function(e) {
  309. if (n) {
  310. return
  311. }
  312. var t = document.getElementById("b");
  313. var r = document.getElementById("b1");
  314. var i = document.getElementById("b2");
  315. var s = document.getElementById("b3");
  316. var o = document.getElementById("msg");
  317. r.style.display = i.style.display = s.style.display = o.style.display = "none";
  318. x(e);
  319. setTimeout(function() {
  320. if (n) {
  321. return
  322. }
  323. if (e == l) {
  324. var t = levelCount - 1;
  325. if (t > strings.ok.length - 1) {
  326. t = strings.ok.length - 1
  327. }
  328. o.innerHTML = strings.ok[t];
  329. k()
  330. } else {
  331. o.innerHTML = strings.fail[livesCount - 1];
  332. L()
  333. }
  334. o.style.display = "block";
  335. var r = new OpacityTween(o, null, 0, 100, .2);
  336. r.start();
  337. r.onMotionFinished = function() {
  338. if (n) {
  339. return
  340. }
  341. setTimeout(function() {
  342. var e = new OpacityTween(o, null, 100, 0, .2);
  343. e.start();
  344. e.onMotionFinished = function() {
  345. if (n) {
  346. return
  347. }
  348. o.innerHTML = "关卡:" + levelCount;
  349. var e = new OpacityTween(o, null, 0, 100, .2);
  350. e.start();
  351. e.onMotionFinished = function() {
  352. if (n) {
  353. return
  354. }
  355. setTimeout(function() {
  356. var e = new OpacityTween(o, null, 100, 0, .2);
  357. e.start();
  358. e.onMotionFinished = function() {
  359. if (n) {
  360. return
  361. }
  362. o.style.display = "none";
  363. l = 0;
  364. x(0);
  365. setTimeout(function() {
  366. f = 0;
  367. M()
  368. },
  369. 3e3)
  370. }
  371. },
  372. 1e3)
  373. }
  374. }
  375. },
  376. 1500)
  377. }
  378. },
  379. 2500)
  380. };
  381. var M = function() {
  382. if (n) {
  383. return
  384. }
  385. f++;
  386. if (f > a) {
  387. N();
  388. C();
  389. return
  390. }
  391. var e = Math.floor(Math.random() * 3);
  392. var t = Math.floor(Math.random() * 2);
  393. var r = 0;
  394. if (t == 1) {
  395. r = 180
  396. }
  397. var i = o;
  398. if (e == 2) {
  399. i = i * .8
  400. }
  401. i *= t == 0 ? 1 : -1;
  402. var s, u, d, v, m, g, y, b;
  403. var w = 24;
  404. var S = function() {
  405. if (n) {
  406. return
  407. }
  408. var t = r + i;
  409. if (t > 180) {
  410. r = 180
  411. } else if (t < 0) {
  412. r = 0
  413. } else {
  414. r += i
  415. }
  416. E.bg.draw();
  417. y = deg2rad(r - 90);
  418. b = deg2rad(r + 90);
  419. if (e == 0) {
  420. s = p + Math.cos(y) * w;
  421. u = p + Math.cos(b) * w;
  422. d = p;
  423. v = c + h / 2 + Math.sin(y) * (h / 2);
  424. m = c + h / 2 + Math.sin(b) * (h / 2);
  425. g = c + h * 2;
  426. if (s > u) {
  427. context.drawImage(imageSprite, 257, 5, 82, 152, m - 41, u, 82, 152);
  428. context.drawImage(imageSprite, 257, 5, 82, 152, v - 41, s, 82, 152)
  429. } else {
  430. context.drawImage(imageSprite, 257, 5, 82, 152, v - 41, s, 82, 152);
  431. context.drawImage(imageSprite, 257, 5, 82, 152, m - 41, u, 82, 152)
  432. }
  433. context.drawImage(imageSprite, 257, 5, 82, 152, g - 41, d, 82, 152)
  434. } else if (e == 1) {
  435. d = p + Math.cos(y) * w;
  436. u = p + Math.cos(b) * w;
  437. s = p;
  438. g = c + h / 2 + h + Math.sin(y) * (h / 2);
  439. m = c + h / 2 + h + Math.sin(b) * (h / 2);
  440. v = c;
  441. if (s > u) {
  442. context.drawImage(imageSprite, 257, 5, 82, 152, m - 41, u, 82, 152);
  443. context.drawImage(imageSprite, 257, 5, 82, 152, v - 41, s, 82, 152)
  444. } else {
  445. context.drawImage(imageSprite, 257, 5, 82, 152, v - 41, s, 82, 152);
  446. context.drawImage(imageSprite, 257, 5, 82, 152, m - 41, u, 82, 152)
  447. }
  448. context.drawImage(imageSprite, 257, 5, 82, 152, g - 41, d, 82, 152)
  449. } else if (e == 2) {
  450. s = p + Math.cos(y) * w * 1.3;
  451. d = p + Math.cos(b) * w * 1.3;
  452. u = p;
  453. v = c + h + Math.sin(y) * h;
  454. g = c + h + Math.sin(b) * h;
  455. m = c + h;
  456. if (s > u) {
  457. context.drawImage(imageSprite, 257, 5, 82, 152, g - 41, d, 82, 152);
  458. context.drawImage(imageSprite, 257, 5, 82, 152, m - 41, u, 82, 152);
  459. context.drawImage(imageSprite, 257, 5, 82, 152, v - 41, s, 82, 152)
  460. } else {
  461. context.drawImage(imageSprite, 257, 5, 82, 152, v - 41, s, 82, 152);
  462. context.drawImage(imageSprite, 257, 5, 82, 152, m - 41, u, 82, 152);
  463. context.drawImage(imageSprite, 257, 5, 82, 152, g - 41, d, 82, 152)
  464. }
  465. }
  466. if (r >= 180 || r <= 0) {
  467. if (e == 0) {
  468. if (l == -1 || l == 0) {
  469. l = l == -1 ? 0 : -1
  470. }
  471. } else if (e == 1) {
  472. if (l == 1 || l == 0) {
  473. l = l == 1 ? 0 : 1
  474. }
  475. } else if (e == 2) {
  476. if (l == 1 || l == -1) {
  477. l *= -1
  478. }
  479. }
  480. r = 0;
  481. M()
  482. } else {
  483. timeout = setTimeout(S, fps)
  484. }
  485. };
  486. timeout = setTimeout(S, fps)
  487. };
  488. var _ = function() {
  489. T();
  490. setTimeout(function() {
  491. x(l)
  492. },
  493. 300);
  494. setTimeout(function() {
  495. f = 0;
  496. M()
  497. },
  498. 3e3)
  499. };
  500. _()
  501. };
  502. var deg2rad = function(e) {
  503. return e * Math.PI / 180
  504. };
  505. init();
  506. if (typeof StartGame == 'function') {
  507. StartGame();
  508. }
  509. window.scrollTo(0, 1);
  510. function shareFriend() {
  511. WeixinJSBridge.invoke("sendAppMessage", {
  512. appid: appid,
  513. img_url: imgUrl,
  514. img_width: "200",
  515. img_height: "200",
  516. link: lineLink,
  517. desc: descContent,
  518. title: shareTitle
  519. },
  520. function(e) {})
  521. }
  522. function shareTimeline() {
  523. WeixinJSBridge.invoke("shareTimeline", {
  524. img_url: imgUrl,
  525. img_width: "200",
  526. img_height: "200",
  527. link: lineLink,
  528. desc: descContent,
  529. title: shareTitle
  530. },
  531. function(e) {})
  532. }
  533. function shareWeibo() {
  534. WeixinJSBridge.invoke("shareWeibo", {
  535. img_url: imgUrl,
  536. content: shareTitle + " " + descContent,
  537. url: lineLink
  538. },
  539. function(e) {})
  540. }
  541. function isWeixin() {
  542. var e = navigator.userAgent.toLowerCase();
  543. if (e.match(/MicroMessenger/i) == "micromessenger") {
  544. return true
  545. } else {
  546. return false
  547. }
  548. }
  549. function toggle(e) {
  550. var t = document.getElementById(e);
  551. var n = document.getElementById("arrow");
  552. var r = t.getAttribute("class");
  553. if (r == "hide") {
  554. t.setAttribute("class", "show");
  555. delay(n, RESOURCE_IMG_PATH + "arrowright.png", 400)
  556. } else {
  557. t.setAttribute("class", "hide");
  558. delay(n, RESOURCE_IMG_PATH + "arrowleft.png", 400)
  559. }
  560. }
  561. function delay(e, t, n) {
  562. window.setTimeout(function() {
  563. e.setAttribute("src", t)
  564. },
  565. n)
  566. }
  567. function show_share() {
  568. document.getElementById("share-wx").style.display = "block"
  569. }
  570. function closeshare() {
  571. document.getElementById("share-wx").style.display = "none"
  572. }
  573. function closewx() {
  574. document.getElementById("wx-qr").style.display = "none"
  575. }
  576. function addShareWX() {
  577. var e = document.createElement("div");
  578. e.id = "share-wx";
  579. e.onclick = closeshare;
  580. document.body.appendChild(e);
  581. var t = document.createElement("p");
  582. t.style.cssText = "text-align:right;padding-left:10px;";
  583. e.appendChild(t);
  584. var n = document.createElement("img");
  585. n.src = "3.png";
  586. n.id = "share-wx-img";
  587. n.style.cssText = "max-width:280px;padding-right:25px;";
  588. t.appendChild(n);
  589. }
  590. if (getCookie("num")) {
  591. var nn = parseInt(getCookie("num"));
  592. setCookie("num", ++nn);
  593. } else {
  594. setCookie("num", 1);
  595. }
  596. function getCookie(name)
  597. {
  598. var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  599. if(arr=document.cookie.match(reg)) return unescape(arr[2]);
  600. else return null;
  601. }
  602. function setCookie(name, value) {
  603. var Days = 30;
  604. var exp = new Date();
  605. exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
  606. document.cookie = name + "=" + escape(value) + ";expires" + exp.toGMTString();
  607. }
  608. function isMobile() {
  609. return navigator.userAgent.match(/android|iphone|ipod|blackberry|meego|symbianos|windowsphone|ucbrowser/i)
  610. }
  611. function isIOS() {
  612. return navigator.userAgent.match(/iphone|ipod|ios/i)
  613. }
  614. var HOME_PATH = HOME_PATH || "http://mp.weixin.qq.com/s?__biz=MzI4MjA2MjE0MQ==&mid=246005295&idx=1&sn=490f8141976d607ba079d48f52a3fcd7#rd",
  615. RESOURCE_IMG_PATH = RESOURCE_IMG_PATH || "/game/",
  616. HORIZONTAL = HORIZONTAL || false,
  617. COVER_SHOW_TIME = COVER_SHOW_TIME || 2e3;
  618. var imgUrl = HOME_PATH + "http://web10.916d.com/games/zuiqiangyanli/1.png";
  619. var lineLink = HOME_PATH;
  620. var descContent = "快来跟我一起玩!";
  621. var shareTitle = "最好玩的小游戏就在游戏排行榜!";
  622. var appid = "";
  623. document.addEventListener("WeixinJSBridgeReady",
  624. function() {
  625. WeixinJSBridge.on("menu:share:appmessage",
  626. function(e) {
  627. shareFriend()
  628. });
  629. WeixinJSBridge.on("menu:share:timeline",
  630. function(e) {
  631. shareTimeline()
  632. });
  633. WeixinJSBridge.on("menu:share:weibo",
  634. function(e) {
  635. shareWeibo()
  636. });
  637. if (HORIZONTAL == true) {
  638. WeixinJSBridge.call("hideToolbar")
  639. }
  640. },
  641. false); (function() {
  642. function n() {
  643. window.scroll(0, 0);
  644. var e;
  645. if (window.orientation == 0 || window.orientation == 180) {
  646. e = false
  647. } else if (window.orientation == -90 || window.orientation == 90) {
  648. e = true
  649. }
  650. if (e == HORIZONTAL) {
  651. t.style.display = "none"
  652. } else {
  653. setTimeout(function() {
  654. r();
  655. t.style.width = window.innerWidth + "px";
  656. t.style.display = "block"
  657. },
  658. isIOS() ? 0 : 600)
  659. }
  660. if (HORIZONTAL == true && isWeixin() && !isIOS()) {
  661. WeixinJSBridge.call("hideToolbar")
  662. }
  663. }
  664. function r() {
  665. e.style.height = window.innerHeight + "px";
  666. e.style.width = window.innerWidth + "px";
  667. t.style.height = window.innerHeight + "px"
  668. }
  669. if (typeof play68_init == "function") {
  670. play68_init()
  671. }
  672. if (!isMobile()) return;
  673. var e = document.createElement("div");
  674. e.style.cssText = "position:absolute;z-index:1000000;left:0;top:0;background-size: 50%;width:" + window.innerWidth + "px;height:" + Math.max(window.innerHeight, window.document.documentElement.offsetHeight) + "px";
  675. e.className = "common_cover";
  676. document.body.appendChild(e);
  677. setTimeout(function() {
  678. e.parentNode.removeChild(e)
  679. },
  680. COVER_SHOW_TIME);
  681. document.addEventListener("touchmove",
  682. function(e) {
  683. e.preventDefault()
  684. },
  685. false);
  686. var t = document.createElement("div");
  687. t.className = "common_notice";
  688. t.style.cssText = "position:absolute;z-index:999999;left:0;top:0;background-size: 50%;";
  689. document.body.appendChild(t);
  690. window.addEventListener("orientationchange", n);
  691. window.addEventListener("load", n);
  692. window.addEventListener("scroll", r)
  693. })();
  694. addShareWX();