circle_origin.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. /*
  2. * @Author: YuMS
  3. * @Date: 2014-08-14 01:49:45
  4. * @Last Modified by: YuMS
  5. * @Last Modified time: 2014-08-17 07:20:26
  6. */
  7. var VERSION = '1.0.4';
  8. // window size
  9. var viewWidth = view.viewSize.width;
  10. var viewHeight = view.viewSize.height;
  11. var windowWidth = viewWidth;
  12. var windowHeight = viewHeight;
  13. var windowMin = Math.min(windowWidth, windowHeight);
  14. var windowMax = Math.max(windowWidth, windowHeight);
  15. // component sizes
  16. var perfectTextPosY = windowHeight / 5.5;
  17. var perfectTextFontSize = windowHeight / 15;
  18. var helpTextFontSize = windowHeight / 30;
  19. var rankTextFontSize = windowHeight / 30;
  20. var versionTextFontSize = windowHeight / 70;
  21. var menuWidth = windowMin / 1.1;
  22. var menuHeight = windowHeight / 2.5;
  23. var menuStrokeWidth = windowHeight / 100;
  24. var slideStrokeWidth = windowHeight / 200;
  25. var replayWidth = windowHeight / 25;
  26. var replayPosY = windowHeight / 2;
  27. var menuButtonWidth = windowHeight / 10;
  28. var menuButtonHeight = windowHeight / 15;
  29. var helpWidth = windowMin / 1.2;
  30. var helpHeight = windowHeight / 2;
  31. var arrowWidth = windowMin / 8;
  32. var arrowHeight = windowMin / 6;
  33. var arrowTextFontSize = windowHeight / 30;
  34. var tutorialWidth = windowMin / 2;
  35. var tutorialHeight = windowMin / 10;
  36. var tutorialStrokeWidth = windowMin / 150;
  37. var tutorialTextFontSize = windowMin / 30;
  38. var maxCircleRadius = windowMin * 0.45;
  39. var pinRadius = windowMin / 180;
  40. // div 2 sizes
  41. var windowWidth2 = windowWidth / 2;
  42. var windowHeight2 = windowHeight / 2;
  43. var viewWidth2 = viewWidth / 2;
  44. var viewHeight2 = viewHeight / 2;
  45. var pinRadius2 = pinRadius / 2;
  46. var menuWidth2 = menuWidth / 2;
  47. var menuHeight2 = menuHeight / 2;
  48. var menuStrokeWidth2 = menuStrokeWidth / 2;
  49. var menuButtonWidth2 = menuButtonWidth / 2;
  50. var menuButtonHeight2 = menuButtonHeight / 2;
  51. var helpWidth2 = helpWidth / 2;
  52. var helpHeight2 = helpHeight / 2;
  53. var arrowWidth2 = arrowWidth / 2;
  54. var arrowHeight2 = arrowHeight / 2;
  55. var tutorialWidth2 = tutorialWidth / 2;
  56. var tutorialHeight2 = tutorialHeight / 2;
  57. // size instances
  58. var windowSize = new Size(windowWidth - 1, windowHeight - 1);
  59. var menuSize = new Size(menuWidth, menuHeight);
  60. var menuButtonSize = new Size(menuButtonWidth, menuButtonHeight);
  61. var helpSize = new Size(helpWidth, helpHeight);
  62. var tutorialSize = new Size(tutorialWidth, tutorialHeight);
  63. // points
  64. var centerPoint = new Point(viewWidth2, viewHeight2);
  65. // bias
  66. var menuButtonBiasX = windowHeight / 6;
  67. var menuButtonBiasY = windowHeight / 4.8;
  68. var maxRandomBias = windowHeight / 20;
  69. var minRandomBias = windowHeight / 200;
  70. var helpBiasY = windowHeight / 3;
  71. var rankBiasY = 0;
  72. var arrowBiasX = windowMin / 20;
  73. var versionBiasX = windowMin / 5;
  74. var tutorialBiasY = windowHeight / 2.5;
  75. var rotateFactor = 200;
  76. // settings
  77. var shared = getCookie('shared').length;
  78. var isiphone = getCookie('isiphone').length;
  79. var circle_played = parseInt(getCookie('circle_played'));
  80. if (!circle_played) {
  81. circle_played = 0;
  82. }
  83. // uuid
  84. if (!getCookie('uuid')) {
  85. setCookie('uuid', uuid());
  86. }
  87. // init status
  88. var nameSubmitted = false;
  89. var percentage = '0%';
  90. var status = 0;
  91. var loadedAd = false;
  92. var circleRadius = (Math.random() + 2) / 3 * maxCircleRadius;
  93. var hintLineRotated = 0;
  94. var perfection = 1;
  95. var positionList = Array();
  96. var drawed = null;
  97. var simplified = null;
  98. var saved = false;
  99. var intersections = [];
  100. // log info
  101. // components instances
  102. try {
  103. var back_rect = new Path.Rectangle(new Point(1, 1), windowSize);
  104. back_rect.fillImage = 'games/a3/2.jpg';
  105. } catch(err) {
  106. /* $.ajax({
  107. type: 'POST',
  108. url: '/circle',
  109. data: {unsupport: 1, UA: navigator.appVersion, cookies: document.cookie}
  110. });*/
  111. alert('抱歉,本游戏暂不支持您的浏览器。');
  112. }
  113. // circle related
  114. var center = new Shape.Circle(centerPoint, pinRadius);
  115. center.fillColor = 'grey';
  116. var hintCircle = new Path.Circle(centerPoint, circleRadius);
  117. hintCircle.strokeColor = 'blue';
  118. var hintRadiusLine = new Path.Line(centerPoint, new Point(viewWidth2 - circleRadius, viewHeight2));
  119. hintRadiusLine.strokeColor = 'black';
  120. hintRadiusLine.rotate(120, centerPoint);
  121. var hintLongLine = new Path.Line(centerPoint, new Point(viewWidth2 - windowMax, viewHeight2));
  122. hintLongLine.rotate(120, centerPoint);
  123. var perfectText = new PointText({
  124. point: [viewWidth2, perfectTextPosY],
  125. justification: 'center',
  126. fillColor: 'black',
  127. fontSize: perfectTextFontSize
  128. });
  129. var versionText = new PointText({
  130. point: [viewWidth2, viewHeight - 0.5 * versionTextFontSize - slideStrokeWidth],
  131. justification: 'center',
  132. fillColor: 'black',
  133. fontSize: versionTextFontSize,
  134. content: ''
  135. });
  136. // help part
  137. var helpBox = new Shape.Rectangle({
  138. point: [-100, -100],
  139. size: helpSize,
  140. strokeJoin: 'round',
  141. strokeWidth: menuStrokeWidth,
  142. });
  143. var helpText = new PointText({
  144. point: [viewWidth2, helpBiasY - 3.5 * helpTextFontSize],
  145. justification: 'center',
  146. fillColor: 'black',
  147. fontSize: helpTextFontSize
  148. });
  149. helpText.content = '给你一个跑道\n\n依据指针画圈\n手指能否顺利跑圆全场\n\n就看你了\n\n开跑';
  150. var helpGroup = new Group(helpBox, helpText);
  151. helpBox.onMouseUp = function(event) {
  152. event.preventDefault();
  153. helpGroup.visible = false;
  154. versionText.visible = false;
  155. status = 1;
  156. };
  157. helpText.onMouseUp = function(event) {
  158. event.preventDefault();
  159. helpGroup.visible = false;
  160. versionText.visible = false;
  161. status = 1;
  162. };
  163. // menu group
  164. var menuBox = new Shape.Rectangle({
  165. point: [viewWidth2 - menuWidth2, viewHeight2 - menuHeight2],
  166. size: menuSize,
  167. strokeColor: 'black',
  168. // fillColor: 'white',
  169. strokeJoin: 'round',
  170. strokeWidth: 'menuStrokeWidth'
  171. });
  172. // menuBox.fillImage ='../../icon.png';
  173. var replayButton = new Path.Circle(new Point(viewWidth2 - menuButtonBiasX, viewHeight2 + menuButtonBiasY-20)+10, menuButtonWidth2+20);
  174. replayButton.fillColor = 'white';
  175. replayButton.opacity=0;
  176. // console.log(viewWidth2- menuButtonBiasX)
  177. // console.log(viewHeight2 + menuButtonBiasY)
  178. // replayButton.fillImage ='../../2.jpg';
  179. var replaySVG = new Path.Circle(new Point(viewWidth2 - menuButtonBiasX, viewHeight2 + menuButtonBiasY), menuButtonWidth2);
  180. // replaySVG = replaySVG.split(replaySVG.length * 0.55);
  181. // replaySVG.strokeColor = 'white';
  182. // replaySVG.strokeWidth = menuStrokeWidth;
  183. // replaySVG.strokeCap = 'round';
  184. // replaySVG.firstSegment.point -= [menuStrokeWidth, menuStrokeWidth2];
  185. // replaySVG.lastSegment.remove();
  186. // replaySVG.lastSegment.point += [menuStrokeWidth2, menuStrokeWidth2];
  187. var shareButton = new Path.Rectangle(new Point(viewWidth2 + menuButtonBiasX - menuButtonWidth2, viewHeight2 + menuButtonWidth2 - menuButtonHeight + menuButtonBiasY-30), menuButtonSize+20);
  188. shareButton.fillColor = 'white';
  189. shareButton.opacity=0;
  190. var shareSVG = new Path.Rectangle(new Point(viewWidth2 + menuButtonBiasX - menuButtonWidth2, viewHeight2 + menuButtonWidth2 - menuButtonHeight + menuButtonBiasY), menuButtonSize);
  191. // shareSVG.strokeColor = 'blue';
  192. // shareSVG.strokeWidth = menuStrokeWidth;
  193. var shareSVG1 = new Path.Line(new Point(viewWidth2 + menuButtonBiasX, viewHeight2 + menuButtonBiasY), new Point(viewWidth2 + menuButtonBiasX, viewHeight2 - menuButtonHeight + menuButtonBiasY));
  194. var shareSVG2 = new Path.Line(new Point(viewWidth2 + menuButtonBiasX, viewHeight2 - menuButtonHeight + menuButtonBiasY), new Point(viewWidth2 + menuButtonBiasX - menuButtonHeight2, viewHeight2 - menuButtonHeight2 + menuButtonBiasY));
  195. var shareSVG3 = new Path.Line(new Point(viewWidth2 + menuButtonBiasX, viewHeight2 - menuButtonHeight + menuButtonBiasY), new Point(viewWidth2 + menuButtonBiasX + menuButtonHeight2, viewHeight2 - menuButtonHeight2 + menuButtonBiasY));
  196. // shareSVG1.strokeColor = 'blue';
  197. // shareSVG1.strokeWidth = menuStrokeWidth;
  198. // shareSVG2.strokeColor = 'blue';
  199. // shareSVG2.strokeWidth = menuStrokeWidth;
  200. // shareSVG2.strokeCap = 'round';
  201. // shareSVG3.strokeColor = 'blue';
  202. // shareSVG3.strokeWidth = menuStrokeWidth;
  203. // shareSVG3.strokeCap = 'round';
  204. var rankText = new PointText({
  205. point: [viewWidth2, viewHeight2 + rankBiasY - 2 * rankTextFontSize],
  206. justification: 'center',
  207. // fillColor: 'black',
  208. fontSize: rankTextFontSize
  209. });
  210. // rankText.fillImage=
  211. // rankText.content = '../../xuanyao.png';
  212. var menuGroup = new Group(menuBox, replayButton, replaySVG, shareButton, shareSVG, shareSVG1, shareSVG2, shareSVG3, rankText);
  213. menuGroup.visible = false;
  214. // menu related events
  215. replayButton.onMouseUp = function(event) {
  216. event.preventDefault();
  217. init();
  218. };
  219. shareButton.onMouseDown = function(event) {
  220. console.log("2")
  221. event.preventDefault();
  222. HideContent('desktop-ad');
  223. // dp_share();
  224. // play68_submitScore((perfection * 100).toFixed(2));
  225. // $("body").css("background-image",'url("./share.png")');
  226. $("#share").show()
  227. // $(can).hide()
  228. if (!saved) {
  229. circleId = uuid();
  230. shareSVG2.rotate(20, [viewWidth2 + menuButtonBiasX, viewHeight2 - menuButtonHeight + menuButtonBiasY]);
  231. shareSVG3.rotate(-20, [viewWidth2 + menuButtonBiasX, viewHeight2 - menuButtonHeight + menuButtonBiasY]);
  232. /* $.ajax({
  233. type: 'POST',
  234. url: '/circle/save',
  235. data: {
  236. score: perfection,
  237. simplified: simplified.exportJSON(),
  238. window_min: windowMin,
  239. window_width: windowWidth,
  240. window_height: windowHeight,
  241. circle_id: circleId,
  242. circle_radius: circleRadius,
  243. timestamp: (new Date).getTime(),
  244. user_id: getCookie('uuid')
  245. }
  246. }).done(function() {
  247. window.location.replace('http://games.yumaoshu.com/circle/show?circleId=' + circleId);
  248. });*/
  249. saved = true;
  250. }
  251. };
  252. // tutorial group
  253. var tutorialBox = new Shape.Rectangle({
  254. // point: [viewWidth2 - tutorialWidth2, viewHeight2 - tutorialHeight2 + tutorialBiasY],
  255. // size: tutorialSize,
  256. // strokeColor: 'black',
  257. // fillColor: 'white',
  258. // strokeJoin: 'round',
  259. // strokeWidth: tutorialStrokeWidth
  260. });
  261. var tutorialText = new PointText({
  262. // point: [viewWidth2, viewHeight2 + tutorialBiasY + tutorialTextFontSize * 0.5],
  263. // justification: 'center',
  264. // fillColor: 'black',
  265. // fontSize: tutorialTextFontSize
  266. });
  267. // tutorialText.content = '更多游戏';
  268. var tutorialGroup = new Group(tutorialBox, tutorialText);
  269. tutorialGroup.visible = false;
  270. // tutorial related events
  271. tutorialBox.onMouseDown = function(event) {
  272. // dp_share();
  273. Play68.goHome();
  274. };
  275. tutorialText.onMouseDown = function(event) {
  276. Play68.goHome();
  277. };
  278. // hint part
  279. var arrowSVG = new Path(
  280. new Segment(
  281. new Point(viewWidth - arrowWidth - arrowBiasX, arrowHeight), null,
  282. new Point(0, -arrowHeight2)
  283. ),
  284. new Segment(
  285. new Point(viewWidth - arrowBiasX, 0), null, null
  286. )
  287. );
  288. arrowSVG.strokeColor = 'blue';
  289. arrowSVG.strokeWidth = menuStrokeWidth;
  290. var arrowText = new PointText({
  291. point: [viewWidth - arrowWidth - arrowBiasX, arrowHeight + arrowTextFontSize],
  292. justification: 'center',
  293. fillColor: 'black',
  294. fontSize: arrowTextFontSize
  295. });
  296. arrowText.content = '分享到朋友圈';
  297. var arrowGroup = new Group(arrowSVG, arrowText);
  298. arrowGroup.visible = false;
  299. function init() {
  300. perfection = 1;
  301. circleRadius = (Math.random() + 2) / 3 * maxCircleRadius;
  302. hintLineRotated = 0;
  303. percentage = '0%';
  304. status = 1;
  305. menuGroup.visible = false;
  306. tutorialGroup.visible = false;
  307. arrowGroup.visible = false;
  308. versionText.visible = false;
  309. HideContent('desktop-ad');
  310. hintLineRotated = 0;
  311. drawed.remove();
  312. drawed = null;
  313. intersections.forEach(function(x) {
  314. x.remove();
  315. })
  316. intersections = [];
  317. hintCircle.remove();
  318. hintCircle = new Path.Circle(centerPoint, circleRadius);
  319. hintCircle.strokeColor = 'blue';
  320. hintRadiusLine.remove();
  321. hintRadiusLine = new Path.Line(centerPoint, new Point(viewWidth2 - circleRadius, viewHeight2));
  322. hintRadiusLine.strokeColor = 'black';
  323. hintRadiusLine.rotate(120, centerPoint);
  324. hintLongLine.remove();
  325. hintLongLine = new Path.Line(centerPoint, new Point(viewWidth2 - windowMax, viewHeight2));
  326. hintLongLine.rotate(120, centerPoint);
  327. simplified.remove();
  328. simplified = null;
  329. perfectText.content = '';
  330. document.title = '我去天安门广场跑个圈';
  331. $("body").css("background-image",'url("./2.jpg")');
  332. }
  333. function uuid(len, radix) {
  334. var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''), uuid = [], i;
  335. radix = radix || chars.length;
  336. if (len) {
  337. // Compact form
  338. for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
  339. } else {
  340. // rfc4122, version 4 form
  341. var r;
  342. // rfc4122 requires these characters
  343. uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
  344. uuid[14] = '4';
  345. // Fill in random data. At i==19 set the high bits of clock sequence as
  346. // per rfc4122, sec. 4.1.5
  347. for (i = 0; i < 36; i++) {
  348. if (!uuid[i]) {
  349. r = 0 | Math.random()*16;
  350. uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
  351. }
  352. }
  353. }
  354. return uuid.join('');
  355. }
  356. function encourage(perfection) {
  357. if (perfection < 0.1) {
  358. return '画的圆,在哪儿呢?。。';
  359. } else if (perfection < 0.5) {
  360. return '你的体育是英语老师教的吧?';
  361. } else if (perfection < 0.7) {
  362. return '你的体育是英语老师教的吧?';
  363. } else if (perfection < 0.8) {
  364. return '你的体育是英语老师教的吧?';
  365. } else if (perfection < 0.9) {
  366. return '你的体育是英语老师教的吧?';
  367. } else if (perfection < 0.93) {
  368. return '手上功夫竟然比脚上还准,我惊呆了!';
  369. } else if (perfection < 0.94) {
  370. return '手上功夫竟然比脚上还准,我惊呆了!';
  371. } else if (perfection < 0.95) {
  372. return '手上功夫竟然比脚上还准,我惊呆了!';
  373. } else if (perfection < 0.96) {
  374. return '你确定,你是来比赛,不是来炫耀的?';
  375. } else if (perfection < 0.97) {
  376. return '你确定,你是来比赛,不是来炫耀的?';
  377. } else if (perfection < 0.98) {
  378. return '你确定,你是来比赛,不是来炫耀的?';
  379. } else if (perfection < 0.99) {
  380. return '窝滴神!除了膜拜,请收下窝滴膝盖!';
  381. } else {
  382. return '窝滴神!除了膜拜,请收下窝滴膝盖!';
  383. }
  384. }
  385. function fillRankText() {
  386. rankText.content = '“' + encourage(perfection) + '”\n\n';
  387. rankText.content += '你刚刚画出了一个' + (perfection * 100).toFixed(2) + '分圆!\n不满意就重跑吧!';
  388. // updateShare((perfection * 100).toFixed(2));
  389. // Play68.setRankingScoreDesc((perfection * 100).toFixed(2));
  390. window.isConfirm=true;
  391. }
  392. function onFrame(event) {
  393. if (event.delta > 0.2) {
  394. event.delta = 0.2;
  395. }
  396. if (status === 0) {
  397. if (!helpText.visible) {
  398. helpText.bringToFront();
  399. helpText.visible = true;
  400. }
  401. if (loading) {
  402. loading = false;
  403. HideContent('inputpage');
  404. }
  405. } else if (status === 1) {
  406. if (hintCircle.visible) {
  407. opacity = hintCircle.opacity - 2 * event.delta;
  408. if (opacity < 0) {
  409. opacity = 0;
  410. hintCircle.visible = false;
  411. }
  412. hintCircle.opacity = opacity;
  413. }
  414. } else if (status === 2) {
  415. if (!hintCircle.visible) {
  416. hintCircle.visible = true;
  417. }
  418. if (hintCircle.opacity < 1) {
  419. opacity = hintCircle.opacity + 2 * event.delta;
  420. if (opacity > 1) {
  421. opacity = 1;
  422. }
  423. hintCircle.opacity = opacity;
  424. } else {
  425. if (hintLineRotated < 359.9) {
  426. rotation = event.delta * rotateFactor;
  427. hintLineRotated += rotation;
  428. if (hintLineRotated > 360) {
  429. rotation = 360 - hintLineRotated + rotation;
  430. hintLineRotated = 360;
  431. }
  432. hintRadiusLine.rotate(rotation, new Point(viewWidth2, viewHeight2));
  433. hintLongLine.rotate(rotation, new Point(viewWidth2, viewHeight2));
  434. intersectionsDraw = hintLongLine.getIntersections(drawed);
  435. intersectionsCircle = hintLongLine.getIntersections(hintCircle);
  436. var inter1 = centerPoint;
  437. if (intersectionsDraw.length) {
  438. inter1 = intersectionsDraw[0].point;
  439. }
  440. var inter2 = inter1;
  441. if (intersectionsCircle.length) {
  442. inter2 = intersectionsCircle[0].point;
  443. }
  444. if (!simplified) {
  445. simplified = new Path();
  446. simplified.visible = false;
  447. }
  448. simplified.add(inter1);
  449. intersectionLine = new Path.Line(inter1, inter2);
  450. intersections.push(intersectionLine);
  451. intersectionLine.strokeWidth = 2;
  452. // intersectionLine.strokeColor = 'pink';
  453. var distance = inter1.getDistance(inter2);
  454. perfection -= distance / circleRadius * rotation / 360;
  455. if (perfection < 0) {
  456. perfection = 0;
  457. }
  458. perfectText.content = (perfection * 100).toFixed(2) + '%';
  459. } else {
  460. if (!simplified.visible) {
  461. simplified.closed = true;
  462. simplified.smooth();
  463. simplified.strokeColor = 'black';
  464. simplified.strokeWidth = 2;
  465. simplified.opacity = 0;
  466. simplified.visible = true;
  467. } else if (simplified.opacity < 0.8) {
  468. opacity = simplified.opacity + event.delta;
  469. if (opacity > 1) {
  470. opacity = 1;
  471. }
  472. simplified.opacity = opacity;
  473. drawed.opacity = 1 - opacity;
  474. } else {
  475. // console.log(simplified.exportJSON());
  476. // console.log(simplified.exportJSON().length);
  477. can=document.getElementById("canvas");
  478. console.log(can)
  479. var ctx=can.getContext("2d");
  480. // ctx.fillStyle="ffffff";
  481. // ctx.fillRect(0,0,20000,20000);
  482. // ctx.clearColor(0.2,0.2,0.2,1.0)
  483. // console.log(windowSize.width)
  484. // console.log(windowSize.height)
  485. ctx.clearRect(0,0,windowSize.width,windowSize.height);
  486. // $(can).hide();
  487. // var can_new=document.creatElement("canvas");
  488. // can_new.id="canvas_new";
  489. $("body").css("background-image",'url("./bg.jpg")');
  490. fillRankText();
  491. hintCircle.opacity = 0;
  492. intersectionLine.opacity = 0;
  493. hintRadiusLine.visible = false;
  494. hintLongLine.opacity = 0
  495. simplified.opacity = 0
  496. hintLineRotated.opacity = 0
  497. hintRadiusLine.opacity = 0
  498. hintLongLine.opacity = 0
  499. intersectionsDraw.opacity = 0
  500. intersectionsCircle.opacity = 0
  501. // $(can).show();
  502. /*$.ajax({
  503. type: 'POST',
  504. url: '/circle',
  505. data: {UA: navigator.appVersion, score: perfection, cookies: document.cookie}
  506. });*/
  507. circle_played = parseInt(getCookie('circle_played'));
  508. if (!circle_played) {
  509. circle_played = 0;
  510. }
  511. setCookie('circle_played', circle_played + 1);
  512. status = 4;
  513. }
  514. }
  515. }
  516. } else if (status === 4) {
  517. if (!loadedAd) {
  518. if (typeof(startLoadingGoogle) !== 'undefined') {
  519. startLoadingGoogle();
  520. }
  521. loadedAd = true;
  522. }
  523. if (!menuGroup.visible) {
  524. if (circle_played >= 3) {
  525. ShowContent('desktop-ad');
  526. }
  527. // console.log
  528. menuGroup.bringToFront();
  529. tutorialGroup.bringToFront();
  530. versionText.bringToFront();
  531. menuGroup.opacity = 0;
  532. menuGroup.visible = true;
  533. versionText.opacity = 0;
  534. versionText.visible = true;
  535. tutorialGroup.opacity = 0;
  536. tutorialGroup.visible = true;
  537. console.log("1")
  538. }
  539. if (menuGroup.opacity < 1) {
  540. opacity = menuGroup.opacity += 5 * event.delta;
  541. if (opacity > 1) {
  542. opacity = 1;
  543. }
  544. menuGroup.opacity = opacity;
  545. versionText.opacity = opacity;
  546. if (circle_played < 20) {
  547. tutorialGroup.opacity = opacity;
  548. }
  549. }
  550. }
  551. }
  552. function onMouseDown(event) {
  553. if (status === 1) {
  554. if (!drawed) {
  555. drawed = new Path({
  556. segments: [event.point],
  557. strokeColor: 'black',
  558. });
  559. }
  560. } else if (status === 3) {
  561. status = 4;
  562. }
  563. }
  564. function onMouseDrag(event) {
  565. if (status === 1) {
  566. drawed.add(event.point);
  567. }
  568. }
  569. function onMouseUp(event) {
  570. if (status === 1) {
  571. if (drawed) {
  572. status = 2;
  573. }
  574. }
  575. }