Advertisement
Guest User

Cursors.io hack

a guest
Feb 22nd, 2015
230,602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.21 KB | None | 0 0
  1. var A = window;
  2. var E = document;
  3.  
  4. var debugMode = false;
  5.  
  6. var posX, posY;
  7. var lastX, lastY;
  8.  
  9. var lastFrame;
  10. var currentFrame;
  11.  
  12. var initialLoad = true;
  13. var buttonIndex = 0;
  14. var maxButtons = 20;
  15. var buttons = new Array(maxButtons);
  16. for (var i = 0; i < maxButtons; i++)
  17. buttons[i] = new Array(3);
  18.  
  19. var auraEnabled = false;
  20. var auraTime = 0;
  21. var auraRadius = 10;
  22.  
  23. var markerEnabled = false;
  24.  
  25. var movementEnabled = true;
  26.  
  27. var imageScale = 1.0;
  28. var imgData = [ [17,49,17,57],
  29. [18,44,18,52],
  30. [18,55,18,59],
  31. [19,41,19,46],
  32. [19,58,19,60],
  33. [20,40,20,42],
  34. [20,60,20,62],
  35. [21,38,21,40],
  36. [21,61,21,63],
  37. [22,37,22,39],
  38. [22,62,22,64],
  39. [23,37,23,38],
  40. [23,63,23,65],
  41. [24,36,24,37],
  42. [24,64,24,65],
  43. [25,35,25,37],
  44. [25,65,25,66],
  45. [26,34,26,36],
  46. [26,65,26,67],
  47. [27,33,27,35],
  48. [27,66,27,67],
  49. [28,32,28,34],
  50. [28,67,28,68],
  51. [29,32,29,34],
  52. [29,67,29,68],
  53. [30,31,30,33],
  54. [30,67,30,69],
  55. [31,31,31,32],
  56. [31,68,31,69],
  57. [32,31,32,32],
  58. [32,68,32,69],
  59. [33,30,33,31],
  60. [33,55,33,59],
  61. [33,68,33,69],
  62. [34,30,34,31],
  63. [34,53,34,58],
  64. [34,59,34,61],
  65. [34,68,34,70],
  66. [35,29,35,31],
  67. [35,52,35,57],
  68. [35,61,35,62],
  69. [35,69,35,70],
  70. [36,29,36,30],
  71. [36,50,36,57],
  72. [36,62,36,63],
  73. [36,69,36,70],
  74. [37,29,37,30],
  75. [37,50,37,58],
  76. [37,62,37,63],
  77. [37,69,37,70],
  78. [38,28,38,30],
  79. [38,49,38,58],
  80. [38,69,38,71],
  81. [38,108,38,115],
  82. [39,28,39,29],
  83. [39,49,39,57],
  84. [39,63,39,64],
  85. [39,70,39,71],
  86. [39,107,39,110],
  87. [39,114,39,116],
  88. [40,28,40,35],
  89. [40,48,40,57],
  90. [40,63,40,64],
  91. [40,70,40,71],
  92. [40,107,40,109],
  93. [40,116,40,117],
  94. [41,27,41,32],
  95. [41,35,41,36],
  96. [41,48,41,57],
  97. [41,63,41,64],
  98. [41,70,41,71],
  99. [41,107,41,108],
  100. [41,117,41,118],
  101. [42,26,42,32],
  102. [42,36,42,37],
  103. [42,48,42,56],
  104. [42,62,42,64],
  105. [42,70,42,72],
  106. [42,107,42,108],
  107. [42,118,42,119],
  108. [43,25,43,32],
  109. [43,36,43,38],
  110. [43,41,43,42],
  111. [43,48,43,56],
  112. [43,62,43,63],
  113. [43,70,43,72],
  114. [43,107,43,108],
  115. [43,118,43,119],
  116. [44,25,44,32],
  117. [44,37,44,38],
  118. [44,40,44,41],
  119. [44,47,44,55],
  120. [44,61,44,63],
  121. [44,71,44,72],
  122. [44,107,44,108],
  123. [44,118,44,119],
  124. [45,24,45,32],
  125. [45,37,45,40],
  126. [45,48,45,50],
  127. [45,59,45,62],
  128. [45,71,45,72],
  129. [45,107,45,108],
  130. [45,118,45,119],
  131. [46,24,46,32],
  132. [46,37,46,40],
  133. [46,49,46,51],
  134. [46,58,46,60],
  135. [46,71,46,72],
  136. [46,107,46,108],
  137. [46,119,46,120],
  138. [47,23,47,32],
  139. [47,37,47,39],
  140. [47,50,47,53],
  141. [47,55,47,58],
  142. [47,71,47,73],
  143. [47,107,47,108],
  144. [47,119,47,120],
  145. [48,23,48,31],
  146. [48,36,48,39],
  147. [48,52,48,56],
  148. [48,72,48,73],
  149. [48,107,48,108],
  150. [48,119,48,120],
  151. [49,23,49,30],
  152. [49,35,49,38],
  153. [49,62,49,65],
  154. [49,72,49,73],
  155. [49,106,49,108],
  156. [49,119,49,120],
  157. [50,24,50,29],
  158. [50,34,50,38],
  159. [50,43,50,46],
  160. [50,61,50,64],
  161. [50,72,50,74],
  162. [50,106,50,108],
  163. [50,119,50,120],
  164. [51,24,51,28],
  165. [51,32,51,34],
  166. [51,36,51,37],
  167. [51,40,51,42],
  168. [51,45,51,46],
  169. [51,58,51,62],
  170. [51,72,51,74],
  171. [51,106,51,108],
  172. [51,119,51,120],
  173. [52,25,52,32],
  174. [52,36,52,37],
  175. [52,45,52,46],
  176. [52,56,52,60],
  177. [52,73,52,74],
  178. [52,106,52,108],
  179. [52,119,52,120],
  180. [53,26,53,28],
  181. [53,35,53,37],
  182. [53,44,53,46],
  183. [53,55,53,58],
  184. [53,73,53,74],
  185. [53,106,53,107],
  186. [53,119,53,120],
  187. [54,26,54,27],
  188. [54,36,54,38],
  189. [54,41,54,45],
  190. [54,52,54,56],
  191. [54,73,54,75],
  192. [54,106,54,107],
  193. [54,119,54,120],
  194. [55,26,55,27],
  195. [55,37,55,44],
  196. [55,50,55,54],
  197. [55,74,55,75],
  198. [55,106,55,107],
  199. [55,119,55,120],
  200. [56,26,56,27],
  201. [56,47,56,51],
  202. [56,74,56,75],
  203. [56,106,56,107],
  204. [56,119,56,120],
  205. [57,26,57,27],
  206. [57,45,57,49],
  207. [57,74,57,76],
  208. [57,106,57,107],
  209. [57,119,57,120],
  210. [58,26,58,27],
  211. [58,42,58,46],
  212. [58,74,58,76],
  213. [58,106,58,107],
  214. [58,115,58,116],
  215. [58,118,58,119],
  216. [59,26,59,28],
  217. [59,39,59,44],
  218. [59,75,59,76],
  219. [59,105,59,107],
  220. [59,118,59,119],
  221. [60,27,60,28],
  222. [60,37,60,41],
  223. [60,75,60,77],
  224. [60,105,60,106],
  225. [60,118,60,119],
  226. [60,124,60,125],
  227. [61,27,61,28],
  228. [61,33,61,38],
  229. [61,76,61,77],
  230. [61,105,61,106],
  231. [61,117,61,118],
  232. [61,123,61,127],
  233. [62,27,62,28],
  234. [62,30,62,35],
  235. [62,76,62,78],
  236. [62,104,62,106],
  237. [62,116,62,118],
  238. [62,122,62,124],
  239. [62,126,62,128],
  240. [63,27,63,28],
  241. [63,30,63,31],
  242. [63,77,63,78],
  243. [63,98,63,102],
  244. [63,104,63,105],
  245. [63,116,63,117],
  246. [63,121,63,123],
  247. [63,126,63,128],
  248. [64,27,64,28],
  249. [64,77,64,79],
  250. [64,95,64,105],
  251. [64,116,64,118],
  252. [64,119,64,121],
  253. [64,126,64,128],
  254. [65,27,65,29],
  255. [65,68,65,69],
  256. [65,78,65,79],
  257. [65,92,65,96],
  258. [65,103,65,105],
  259. [65,115,65,120],
  260. [65,123,65,126],
  261. [65,127,65,128],
  262. [66,28,66,29],
  263. [66,63,66,64],
  264. [66,68,66,70],
  265. [66,78,66,80],
  266. [66,91,66,93],
  267. [66,103,66,104],
  268. [66,117,66,118],
  269. [66,127,66,128],
  270. [67,28,67,29],
  271. [67,63,67,64],
  272. [67,69,67,70],
  273. [67,79,67,80],
  274. [67,89,67,91],
  275. [67,103,67,104],
  276. [67,126,67,128],
  277. [68,28,68,29],
  278. [68,64,68,65],
  279. [68,69,68,70],
  280. [68,79,68,81],
  281. [68,87,68,89],
  282. [68,102,68,104],
  283. [68,120,68,131],
  284. [69,28,69,29],
  285. [69,69,69,70],
  286. [69,80,69,82],
  287. [69,87,69,88],
  288. [69,102,69,103],
  289. [69,122,69,132],
  290. [70,29,70,30],
  291. [70,70,70,71],
  292. [70,80,70,82],
  293. [70,85,70,87],
  294. [70,101,70,113],
  295. [70,132,70,133],
  296. [71,29,71,30],
  297. [71,65,71,66],
  298. [71,70,71,71],
  299. [71,81,71,83],
  300. [71,85,71,86],
  301. [71,91,71,92],
  302. [71,99,71,116],
  303. [71,132,71,133],
  304. [72,29,72,30],
  305. [72,65,72,66],
  306. [72,70,72,71],
  307. [72,81,72,85],
  308. [72,91,72,94],
  309. [72,97,72,100],
  310. [72,115,72,118],
  311. [72,132,72,134],
  312. [73,29,73,30],
  313. [73,70,73,72],
  314. [73,81,73,85],
  315. [73,94,73,99],
  316. [73,118,73,120],
  317. [73,132,73,133],
  318. [74,29,74,30],
  319. [74,71,74,72],
  320. [74,81,74,84],
  321. [74,95,74,98],
  322. [74,119,74,120],
  323. [74,132,74,133],
  324. [75,30,75,31],
  325. [75,66,75,67],
  326. [75,71,75,72],
  327. [75,82,75,84],
  328. [75,94,75,96],
  329. [75,120,75,121],
  330. [75,128,75,129],
  331. [75,131,75,133],
  332. [76,30,76,31],
  333. [76,66,76,67],
  334. [76,71,76,72],
  335. [76,83,76,84],
  336. [76,89,76,90],
  337. [76,94,76,95],
  338. [76,121,76,122],
  339. [76,124,76,125],
  340. [76,129,76,132],
  341. [77,30,77,31],
  342. [77,72,77,73],
  343. [77,83,77,84],
  344. [77,93,77,94],
  345. [77,121,77,123],
  346. [77,129,77,132],
  347. [78,30,78,32],
  348. [78,67,78,68],
  349. [78,72,78,73],
  350. [78,84,78,85],
  351. [78,92,78,93],
  352. [78,122,78,123],
  353. [78,125,78,129],
  354. [79,30,79,32],
  355. [79,67,79,68],
  356. [79,72,79,73],
  357. [79,85,79,86],
  358. [79,91,79,93],
  359. [79,122,79,128],
  360. [80,31,80,32],
  361. [80,67,80,68],
  362. [80,72,80,74],
  363. [80,91,80,92],
  364. [80,122,80,123],
  365. [81,31,81,33],
  366. [81,73,81,74],
  367. [81,91,81,92],
  368. [81,123,81,124],
  369. [82,31,82,33],
  370. [82,68,82,69],
  371. [82,73,82,74],
  372. [82,102,82,103],
  373. [82,123,82,124],
  374. [83,32,83,33],
  375. [83,68,83,69],
  376. [83,73,83,74],
  377. [83,101,83,102],
  378. [83,123,83,124],
  379. [84,32,84,33],
  380. [84,68,84,69],
  381. [84,73,84,74],
  382. [84,123,84,124],
  383. [85,32,85,34],
  384. [85,69,85,70],
  385. [85,73,85,74],
  386. [85,123,85,124],
  387. [86,33,86,35],
  388. [86,69,86,70],
  389. [86,74,86,75],
  390. [86,123,86,124],
  391. [87,34,87,35],
  392. [87,74,87,75],
  393. [87,123,87,124],
  394. [88,34,88,36],
  395. [88,70,88,71],
  396. [88,75,88,76],
  397. [88,122,88,124],
  398. [89,35,89,36],
  399. [89,70,89,71],
  400. [89,75,89,81],
  401. [89,122,89,123],
  402. [90,35,90,37],
  403. [90,71,90,72],
  404. [90,81,90,84],
  405. [90,121,90,123],
  406. [91,36,91,37],
  407. [91,71,91,72],
  408. [91,84,91,85],
  409. [91,121,91,122],
  410. [92,36,92,38],
  411. [92,70,92,71],
  412. [92,84,92,85],
  413. [92,121,92,122],
  414. [93,37,93,39],
  415. [93,70,93,71],
  416. [93,76,93,78],
  417. [93,83,93,85],
  418. [93,120,93,122],
  419. [94,38,94,39],
  420. [94,69,94,70],
  421. [94,77,94,83],
  422. [94,120,94,121],
  423. [95,38,95,40],
  424. [95,69,95,70],
  425. [95,73,95,74],
  426. [95,77,95,78],
  427. [95,119,95,121],
  428. [96,39,96,41],
  429. [96,69,96,70],
  430. [96,73,96,74],
  431. [96,77,96,78],
  432. [96,104,96,105],
  433. [96,119,96,120],
  434. [97,40,97,41],
  435. [97,69,97,70],
  436. [97,73,97,75],
  437. [97,77,97,78],
  438. [97,118,97,120],
  439. [98,40,98,42],
  440. [98,69,98,70],
  441. [98,73,98,76],
  442. [98,78,98,79],
  443. [98,117,98,119],
  444. [99,41,99,43],
  445. [99,69,99,70],
  446. [99,73,99,74],
  447. [99,75,99,78],
  448. [99,108,99,109],
  449. [99,117,99,118],
  450. [100,42,100,44],
  451. [100,69,100,71],
  452. [100,72,100,73],
  453. [100,76,100,78],
  454. [100,116,100,118],
  455. [101,43,101,45],
  456. [101,70,101,72],
  457. [101,115,101,117],
  458. [102,43,102,45],
  459. [102,114,102,116],
  460. [103,44,103,46],
  461. [103,113,103,115],
  462. [104,45,104,47],
  463. [104,111,104,114],
  464. [105,46,105,48],
  465. [105,109,105,113],
  466. [106,47,106,48],
  467. [106,107,106,111],
  468. [107,48,107,49],
  469. [107,101,107,109],
  470. [108,48,108,51],
  471. [108,101,108,105],
  472. [109,49,109,52],
  473. [109,103,109,104],
  474. [110,51,110,54],
  475. [110,96,110,98],
  476. [110,103,110,104],
  477. [111,52,111,55],
  478. [111,94,111,98],
  479. [111,103,111,104],
  480. [112,54,112,57],
  481. [112,92,112,95],
  482. [112,97,112,98],
  483. [112,103,112,104],
  484. [113,55,113,59],
  485. [113,90,113,93],
  486. [113,97,113,99],
  487. [113,103,113,105],
  488. [114,57,114,61],
  489. [114,87,114,92],
  490. [114,98,114,99],
  491. [114,103,114,105],
  492. [115,59,115,65],
  493. [115,83,115,90],
  494. [115,98,115,99],
  495. [115,104,115,105],
  496. [116,61,116,87],
  497. [116,98,116,99],
  498. [116,104,116,105],
  499. [117,66,117,82],
  500. [117,98,117,100],
  501. [117,104,117,105],
  502. [118,70,118,71],
  503. [118,74,118,75],
  504. [118,99,118,100],
  505. [118,104,118,106],
  506. [119,70,119,71],
  507. [119,74,119,76],
  508. [119,91,119,93],
  509. [119,99,119,100],
  510. [119,105,119,106],
  511. [120,70,120,71],
  512. [120,74,120,76],
  513. [120,88,120,101],
  514. [120,105,120,106],
  515. [121,70,121,71],
  516. [121,74,121,76],
  517. [121,88,121,90],
  518. [121,98,121,101],
  519. [121,105,121,107],
  520. [122,70,122,71],
  521. [122,74,122,76],
  522. [122,89,122,91],
  523. [122,106,122,107],
  524. [123,69,123,71],
  525. [123,74,123,76],
  526. [123,90,123,92],
  527. [123,106,123,107],
  528. [124,69,124,71],
  529. [124,74,124,75],
  530. [124,91,124,94],
  531. [124,106,124,107],
  532. [125,69,125,71],
  533. [125,74,125,75],
  534. [125,92,125,95],
  535. [125,106,125,107],
  536. [126,69,126,70],
  537. [126,75,126,76],
  538. [126,94,126,97],
  539. [126,106,126,108],
  540. [127,69,127,70],
  541. [127,75,127,76],
  542. [127,96,127,99],
  543. [127,107,127,108],
  544. [128,69,128,71],
  545. [128,74,128,76],
  546. [128,98,128,103],
  547. [128,107,128,108],
  548. [129,69,129,71],
  549. [129,74,129,75],
  550. [129,101,129,108],
  551. [130,58,130,63],
  552. [130,70,130,71],
  553. [130,74,130,75],
  554. [131,57,131,59],
  555. [131,63,131,66],
  556. [131,69,131,71],
  557. [131,74,131,75],
  558. [132,58,132,59],
  559. [132,65,132,68],
  560. [132,69,132,71],
  561. [132,74,132,75],
  562. [133,58,133,60],
  563. [133,67,133,71],
  564. [133,74,133,75],
  565. [134,59,134,61],
  566. [134,68,134,70],
  567. [134,74,134,75],
  568. [135,60,135,62],
  569. [135,74,135,75],
  570. [136,61,136,63],
  571. [136,73,136,75],
  572. [137,62,137,65],
  573. [137,73,137,75],
  574. [138,64,138,66],
  575. [138,73,138,74],
  576. [139,65,139,68],
  577. [139,72,139,74],
  578. [140,67,140,74],
  579. [141,70,141,73],
  580. ];
  581.  
  582. var fontSize = 2;
  583. var letterOffset = 0;
  584. var alphabet = new Array(200);
  585. alphabet[58] = [
  586. [0,0,0,1],
  587. [2,0,2,1]
  588. ];
  589. alphabet[40] = [
  590. [0,2,1,0],
  591. [2,2,1,0]
  592. ];
  593. alphabet[41] = [
  594. [0,0,1,2],
  595. [2,0,1,2]
  596. ];
  597. alphabet[63] = [
  598. [1,0,0,0],
  599. [0,0,0,2],
  600. [0,2,1,2],
  601. [1,2,1,1],
  602. [1,1,2,1]
  603. ];
  604. alphabet[97] = [
  605. [2,0,0,0],
  606. [0,0,0,2],
  607. [0,2,2,2],
  608. [1,0,1,2]
  609. ];
  610. alphabet[98] = [
  611. [2,0,0,0],
  612. [0,0,0,2],
  613. [0,2,2,2],
  614. [2,2,2,0],
  615. [1,0,1,2]
  616. ];
  617. alphabet[99] = [
  618. [2,2,2,0],
  619. [2,0,0,0],
  620. [0,0,0,2]
  621. ];
  622. alphabet[100] = [
  623. [2,0,0,0],
  624. [0,0,0,1],
  625. [0,1,1,2],
  626. [1,2,2,1],
  627. [2,1,2,0]
  628. ];
  629. alphabet[101] = [
  630. [2,2,2,0],
  631. [2,0,0,0],
  632. [0,0,0,2],
  633. [1,0,1,2]
  634. ];
  635. alphabet[102] = [
  636. [2,0,0,0],
  637. [0,0,0,2],
  638. [1,0,1,2]
  639. ];
  640. alphabet[103] = [
  641. [1,1,1,2],
  642. [1,2,2,2],
  643. [2,2,2,0],
  644. [2,0,0,0],
  645. [0,0,0,2]
  646. ];
  647. alphabet[104] = [
  648. [0,0,2,0],
  649. [0,2,2,2],
  650. [1,0,1,2]
  651. ];
  652. alphabet[105] = [
  653. [0,0,0,2],
  654. [0,1,2,1],
  655. [2,0,2,2]
  656. ];
  657. alphabet[106] = [
  658. [0,0,0,2],
  659. [0,1,2,1],
  660. [2,0,2,1]
  661. ];
  662. alphabet[107] = [
  663. [0,0,2,0],
  664. [1,0,0,2],
  665. [1,0,2,2]
  666. ];
  667. alphabet[108] = [
  668. [0,0,2,0],
  669. [2,0,2,2]
  670. ];
  671. alphabet[109] = [
  672. [0,0,2,0],
  673. [0,0,2,1],
  674. [2,1,0,2],
  675. [0,2,2,2]
  676. ];
  677. alphabet[110] = [
  678. [0,0,2,0],
  679. [0,0,2,2],
  680. [0,2,2,2]
  681. ];
  682. alphabet[111] = [
  683. [2,0,0,0],
  684. [0,0,0,2],
  685. [0,2,2,2],
  686. [2,2,2,0]
  687. ];
  688. alphabet[112] = [
  689. [2,0,0,0],
  690. [0,0,0,2],
  691. [0,2,1,2],
  692. [1,2,1,0]
  693. ];
  694. alphabet[113] = [
  695. [2,0,0,0],
  696. [0,0,0,2],
  697. [0,2,2,2],
  698. [2,2,2,0],
  699. [1,1,2,2]
  700. ];
  701. alphabet[114] = [
  702. [2,0,0,0],
  703. [0,0,0,2],
  704. [0,2,1,2],
  705. [1,2,1,0],
  706. [1,1,2,2]
  707. ];
  708. alphabet[115] = [
  709. [0,0,0,2],
  710. [1,0,1,2],
  711. [2,0,2,2],
  712. [0,0,1,0],
  713. [1,2,2,2]
  714. ];
  715. alphabet[116] = [
  716. [0,0,0,2],
  717. [0,1,2,1]
  718. ];
  719. alphabet[117] = [
  720. [0,0,2,0],
  721. [0,2,2,2],
  722. [2,0,2,2]
  723. ];
  724. alphabet[118] = [
  725. [0,0,2,1],
  726. [0,2,2,1]
  727. ];
  728. alphabet[119] = [
  729. [0,0,2,0],
  730. [0,2,2,2],
  731. [2,0,1,1],
  732. [2,2,1,1]
  733. ];
  734. alphabet[120] = [
  735. [0,0,2,2],
  736. [2,0,0,2]
  737. ];
  738. alphabet[121] = [
  739. [0,0,1,1],
  740. [0,2,1,1],
  741. [1,1,2,1]
  742. ];
  743. alphabet[122] = [
  744. [0,0,0,2],
  745. [0,2,2,0],
  746. [2,0,2,2]
  747. ];
  748.  
  749.  
  750. function sa(f) {
  751. return f << 1
  752. }
  753.  
  754. function ta(f) {
  755. return f << 1
  756. }
  757.  
  758. function U() {
  759. //return E.pointerLockElement === y || E.mozPointerLockElement === y || E.webkitPointerLockElement === y
  760. }
  761.  
  762. function ba() {
  763. a.fillStyle = "#000000";
  764. a.font = "35px NovaSquare";
  765. a.fillText("Please do not embed our website, thank you.", 400 - a.measureText("Please do not embed our website, thank you.").width / 2, 300);
  766. a.font = "16px NovaSquare";
  767. a.fillText("Play the game on http://cursors.io/", 400 - a.measureText("Play the game on http://cursors.io/").width /
  768. 2, 330);
  769. top.location = "http://cursors.io";
  770. throw "Please do not embed our website, thank you.";
  771. }
  772.  
  773. function ua(f) {
  774. V(f)
  775. }
  776.  
  777. // Apparently unimportant
  778. function W(f, b) {
  779. J = f;
  780. K = b;
  781. k = v = f;
  782. q = w = b;
  783. B = v << 1;
  784. C = w << 1
  785. }
  786.  
  787. // Handles clicking
  788. function va(f) {
  789. if (D) return L = !1, V(f), !1;
  790. //U() ? X || (X = !0, W(k, q)) : (X = !1, D || M.checked || y.requestPointerLock && y.requestPointerLock());
  791. if (L) L = !1, Q();
  792. else if (V(f), (f.ctrlKey || f.shiftKey) && !H.checked) Y = !0, R = k, S = q;
  793. else if (100 < t - ca && v == k && w == q) {
  794. ca = t;
  795. I.push([v << 1, w << 1, t]);
  796. wa(v, w, 10);
  797. var b = [v, w];
  798. N.push(b);
  799. setTimeout(function() {
  800. N.remove(b)
  801. }, 1E3)
  802. }
  803. return !1
  804. }
  805.  
  806. // Apparently unimportant
  807. function xa(f) {
  808. Y = !1
  809. }
  810.  
  811. // Sets local storage for cursor lock and drawing
  812. function ya() {
  813. A.localStorage && M && (A.localStorage.setItem("noCursorLock", M.checked ? "1" : "0"), A.localStorage.setItem("noDrawings", H.checked ? "1" : "0"))
  814. }
  815.  
  816. // Handles mouse movement and drawing
  817. function V(f) {
  818. if (U()) {
  819. var b = f.webkitMovementX || f.mozMovementX || f.movementX || 0;
  820. f = f.webkitMovementY || f.mozMovementY || f.movementY || 0;
  821. 300 > Math.abs(b) + Math.abs(f) && (B += b, C += f, v = B >> 1, w = C >> 1)
  822. } else f.offsetX ? (B = f.offsetX, C = f.offsetY) : f.layerX && (B = f.layerX, C = f.layerY), v = B >> 1, w = C >> 1;
  823. k = v, q = w; /* Changed to allow movement through walls */
  824. lastX = posX;
  825. lastY = posY;
  826. posX = k;
  827. posY = q;
  828. if (debugMode) console.log(v + ", " + w);
  829. if (Z(), !U() || v == k && w == q || (f = b = 0, v > k && (b = 1),
  830. w > q && (f = 1), v = k, w = q, B = (v << 1) + b, C = (w << 1) + f), Y && (R != k || S != q) && 50 < t - da) {
  831. b = R;
  832. f = S;
  833. var a = k,
  834. d = q;
  835. if (!D && null != u && u.readyState == WebSocket.OPEN) {
  836. var g = new ArrayBuffer(9),
  837. e = new DataView(g);
  838.  
  839. e.setUint8(0, 3);
  840. e.setUint16(1, b, !0);
  841. e.setUint16(3, f, !0);
  842. e.setUint16(5, a, !0);
  843. e.setUint16(7, d, !0);
  844. u.send(g)
  845.  
  846. if (markerEnabled) {
  847. e.setUint8(0, 3);
  848. e.setUint16(1, b+2, !0);
  849. e.setUint16(3, f, !0);
  850. e.setUint16(5, a+2, !0);
  851. e.setUint16(7, d, !0);
  852. u.send(g)
  853. e.setUint8(0, 3);
  854. e.setUint16(1, b, !0);
  855. e.setUint16(3, f+2, !0);
  856. e.setUint16(5, a, !0);
  857. e.setUint16(7, d+2, !0);
  858. u.send(g)
  859. e.setUint8(0, 3);
  860. e.setUint16(1, b-2, !0);
  861. e.setUint16(3, f, !0);
  862. e.setUint16(5, a-2, !0);
  863. e.setUint16(7, d, !0);
  864. u.send(g)
  865. e.setUint8(0, 3);
  866. e.setUint16(1, b, !0);
  867. e.setUint16(3, f-2, !0);
  868. e.setUint16(5, a, !0);
  869. e.setUint16(7, d-2, !0);
  870. u.send(g)
  871. }
  872. }
  873. R = k;
  874. S = q;
  875. da = t
  876. }
  877. }
  878.  
  879. // Apparently not important
  880. function Z() {
  881. ea(k, q) && Q();
  882. if (z(k, q)) {
  883. var a;
  884. a: {
  885. a = k;
  886. var b = q,
  887. c = [],
  888. d = new Uint8Array(12E4);
  889. c.push([a, b]);
  890. d[a + 400 * b] = 1;
  891. do {
  892. var g = c.shift(),
  893. e = g[0],
  894. g = g[1];
  895. if (!(0 > e || 0 > g || 400 <= e || 300 <= g)) {
  896. if (!z(e, g)) {
  897. a = {
  898. x: e,
  899. y: g
  900. };
  901. break a
  902. }
  903. d[e -
  904. 1 + 400 * g] || (c.push([e - 1, g]), d[e - 1 + 400 * g] = 1);
  905. d[e + 1 + 400 * g] || (c.push([e + 1, g]), d[e + 1 + 400 * g] = 1);
  906. d[e + 400 * (g - 1)] || (c.push([e, g - 1]), d[e + 400 * (g - 1)] = 1);
  907. d[e + 400 * (g + 1)] || (c.push([e, g + 1]), d[e + 400 * (g + 1)] = 1)
  908. }
  909. } while (0 < c.length);
  910. a = {
  911. x: a,
  912. y: b
  913. }
  914. }
  915. k = a.x;
  916. q = a.y
  917. }
  918. if (k != v || q != w) a = fa(k, q, v, w), k = a.x, q = a.y;
  919. ea(k, q) && Q()
  920. }
  921.  
  922. // Cleans up map on level transition
  923. function $() {
  924. console.log("Next map");
  925. initialLoad = true;
  926. for (var i = 0; i < maxButtons; i++)
  927. buttons[i] = new Array(3);
  928. buttonIndex = 0;
  929. T.set(za);
  930. r = [];
  931. I = [];
  932. O = []
  933. }
  934.  
  935. // Enables image smoothing
  936. function ga(f) {
  937. a.imageSmoothingEnabled = f;
  938. a.mozImageSmoothingEnabled = f;
  939. a.oImageSmoothingEnabled = f;
  940. a.webkitImageSmoothingEnabled = f
  941. }
  942.  
  943. // Prints connected message
  944. function Aa() {
  945. $();
  946. console.log("Connected!")
  947. }
  948.  
  949. // Prints socket closed message
  950. function Ba(a) {
  951. $();
  952. console.log("Socket closed: " + a.reason)
  953. }
  954.  
  955. // Prints socket error message
  956. function Ca(a) {
  957. console.log("Socket error")
  958. }
  959.  
  960. // Gets strings, but without it the map won't load
  961. function Da(a, b) {
  962. for (var c = "", d = 0, g = 0; 0 != (g = a.getUint8(b)); ++b) d <<= 8, d |= g, g & 128 || (c += String.fromCharCode(d), d = 0);
  963. 0 != d && (c += String.fromCharCode(d));
  964. return [c, b + 1]
  965. }
  966.  
  967. // You get a TERRIBLE framerate if you remove the contents of this function
  968. function Ea(a, b) {
  969. setTimeout(function() {
  970. var c = a.getUint16(b, !0),
  971. d = 0;
  972. a: for (; d < c; d++) {
  973. for (var g = a.getUint16(b + 2 + 4 * d, !0), e = a.getUint16(b + 4 + 4 * d, !0), n = 0; n < N.length; n++) {
  974. var l = N[n];
  975. if (l[0] == g && l[1] == e) {
  976. N.splice(n, 1);
  977. continue a
  978. }
  979. }
  980. I.push([g << 1, e << 1, t])
  981. }
  982. }, 100);
  983. return b +
  984. 2 + 4 * a.getUint16(b, !0)
  985. }
  986.  
  987. // Apparently not important
  988. function Fa(a, b) {
  989. !H.checked && setTimeout(function() {
  990. for (var c = a.getUint16(b, !0), d = 0; d < c; d++) {
  991. var g = a.getUint16(b + 2 + 8 * d, !0),
  992. e = a.getUint16(b + 4 + 8 * d, !0),
  993. n = a.getUint16(b + 6 + 8 * d, !0),
  994. l = a.getUint16(b + 8 + 8 * d, !0);
  995. O.push([g << 1, e << 1, n << 1, l << 1, t])
  996. }
  997. }, 50);
  998. return b + 2 + 8 * a.getUint16(b, !0)
  999. }
  1000.  
  1001. // Draws the level. Or at least, without it the level doesn't show up.
  1002. function Ga(a) {
  1003. buttonIndex = 0;
  1004. initialLoad = false;
  1005. a = a.data;
  1006. var b = new DataView(a);
  1007. switch (b.getUint8(0)) {
  1008. case 0: // If this doesn't run then you see two of your cursor. One of them lags behind
  1009. ha = b.getUint32(1, !0);
  1010. break;
  1011. case 1: // Without this, doors don't show up
  1012. var c;
  1013. ia = c = b.getUint16(1, !0);
  1014. ja = 100 <= c;
  1015. var d = [],
  1016. g;
  1017. for (g in F) F.hasOwnProperty(g) && d.push(g);
  1018. for (var e =
  1019. 0; e < c; e++) {
  1020. g = b.getUint32(3 + 8 * e, !0);
  1021. var n = b.getUint16(7 + 8 * e, !0),
  1022. l = b.getUint16(9 + 8 * e, !0);
  1023. if (g != ha)
  1024. if (null != F[g]) {
  1025. for (var p = 0; p < d.length; p++)
  1026. if (d[p] == g) {
  1027. d.splice(p, 1);
  1028. break
  1029. }
  1030. g = F[g];
  1031. g.oldX = g.getX();
  1032. g.oldY = g.getY();
  1033. g.newX = n;
  1034. g.newY = l;
  1035. g.time = t
  1036. } else F[g] = new ka(n, l)
  1037. }
  1038. for (e = 0; e < d.length; e++) delete F[d[e]];
  1039. c = Ea(b, 3 + 8 * c);
  1040. g = b.getUint16(c, !0);
  1041. c += 2;
  1042. for (d = 0; d < g; d++) {
  1043. a: for (n = b.getUint32(c, !0), e = 0; e < r.length; e++)
  1044. if (r[e].id == n) {
  1045. var k = r[e];
  1046. if (1 == k.type)
  1047. for (var n = k.x | 0, l = k.y | 0, p = k.width | 0, k = k.height | 0, m = l; m < l + k; ++m)
  1048. for (var h =
  1049. n; h < n + p; ++h) --T[h + 400 * m];
  1050. r.splice(e, 1);
  1051. break a
  1052. }c += 4
  1053. }
  1054. g = b.getUint16(c, !0);
  1055. c += 2;
  1056. for (d = 0; d < g; d++) {
  1057. a: {
  1058. e = b.getUint32(c, !0);
  1059. for (n = 0; n < r.length; n++)
  1060. if (r[n].id == e) {
  1061. e = r[n];
  1062. break a
  1063. }
  1064. e = {
  1065. id: e
  1066. };
  1067. r.push(e)
  1068. }
  1069. c += 4;c = la(b, c, e)
  1070. }
  1071. c = Fa(b, c);
  1072. if (a.byteLength < c + 4) break;
  1073. aa = b.getUint32(c, !0);
  1074. break;
  1075. case 4: // Without this the level don't show
  1076. $();
  1077. W(b.getUint16(1, !0), b.getUint16(3, !0));
  1078. g = b.getUint16(5, !0);
  1079. c = 7;
  1080. for (d = 0; d < g; d++) e = {}, e.id = b.getUint32(c, !0), c += 4, c = la(b, c, e), r.push(e);
  1081. a.byteLength >= c + 4 ? G = Math.max(G, b.getUint32(c, !0)) : a.byteLength >= c + 2 && (G = Math.max(G, b.getUint16(c, !0)));
  1082. Z();
  1083. break;
  1084. case 5: // Without this things don't trigger unless you are drawing. Also, you can't click buttons.
  1085. W(b.getUint16(1, !0), b.getUint16(3, !0)), 9 <= b.byteLength ? G = Math.max(G, b.getUint32(5, !0)) : 7 <= b.byteLength && (G = Math.max(G, b.getUint16(5, !0))), Z()
  1086. }
  1087. }
  1088.  
  1089. // Without this, your position only updates if you click or draw
  1090. function Q() {
  1091. lastFrame = currentFrame;
  1092. currentFrame = new Date().getTime();
  1093.  
  1094. if (!(D || L || null == u || u.readyState != WebSocket.OPEN || k == J && q == K) && movementEnabled) {
  1095. var a = new ArrayBuffer(9);
  1096. b = new DataView(a);
  1097. b.setUint8(0, 1);
  1098. b.setUint16(1, k, !0);
  1099. b.setUint16(3, q, !0);
  1100. b.setUint32(5, G, !0);
  1101. u.send(a);
  1102. J = k;
  1103. K = q
  1104. }
  1105.  
  1106. if (auraEnabled) // Drawing cursor aura
  1107. drawAura(J, K);
  1108. }
  1109.  
  1110. // Without this clicking doesn't actually get transmitted to the server
  1111. function wa(a, b, numClicks) {
  1112. if (!D && null != u && u.readyState == WebSocket.OPEN) {
  1113. var c = new ArrayBuffer(9),
  1114. d = new DataView(c);
  1115. d.setUint8(0, 2);
  1116. d.setUint16(1, a, !0);
  1117. d.setUint16(3, b, !0);
  1118. d.setUint32(5, G, !0);
  1119. for (var i = 0; i < numClicks; i++) { u.send(c) } // Changed to click multiple times
  1120. }
  1121. }
  1122.  
  1123. function la(f, b, c) {
  1124. function d() { // Handles drawing stuff
  1125. if (c.type == 4 && initialLoad) {
  1126. c.x = f.getUint16(b, !0);
  1127. buttons[buttonIndex][0] = c.x
  1128. b += 2;
  1129. c.y = f.getUint16(b, !0);
  1130. buttons[buttonIndex][1] = c.y
  1131. b += 2;
  1132. c.width = f.getUint16(b, !0);
  1133. b += 2;
  1134. c.height = f.getUint16(b, !0);
  1135. b += 2
  1136.  
  1137. buttonIndex++;
  1138. } else {
  1139. c.x = f.getUint16(b, !0);
  1140. b += 2;
  1141. c.y = f.getUint16(b, !0);
  1142. b += 2;
  1143. c.width = f.getUint16(b, !0);
  1144. b += 2;
  1145. c.height = f.getUint16(b, !0);
  1146. b += 2
  1147. }
  1148. }
  1149. function g() { // Handles coloring stuff
  1150. for (var a = f.getUint32(b, !0).toString(16); 6 > a.length;) a = "0" + a;
  1151. b += 4;
  1152. c.color = "#" + a
  1153. }
  1154. var e = f.getUint8(b);
  1155. b += 1;
  1156. c.type = e;
  1157. switch (e) {
  1158. case 255:
  1159. break;
  1160. case 0: // Draws text
  1161. c.x = f.getUint16(b, !0);
  1162. b += 2;
  1163. c.y = f.getUint16(b, !0);
  1164. b += 2;
  1165. c.size = f.getUint8(b);
  1166. b += 1;
  1167. c.isCentered = !!f.getUint8(b);
  1168. b += 1;
  1169. e = Da(f, b);
  1170. c.text = e[0];
  1171. b = e[1];
  1172. break;
  1173. case 1: // May relate to cursor movement?
  1174. d();
  1175. var n = !c.color;
  1176. g();
  1177. var e = c.x | 0,
  1178. l = c.y | 0,
  1179. p = c.width | 0,
  1180. k = c.height | 0;
  1181. if (n)
  1182. for (n = l; n < l + k; ++n)
  1183. for (var m = e; m < e + p; ++m) ++T[m + 400 * n];
  1184. break;
  1185. case 2: // Draws exit points
  1186. d();
  1187. c.isBad = !!f.getUint8(b);
  1188. b += 1;
  1189. break;
  1190. case 3: // Handles the area triggers
  1191. d();
  1192. c.count = f.getUint16(b, !0);
  1193. b += 2;
  1194. g();
  1195. break;
  1196. case 4: // Something about buttons, but also affects doors and area triggers
  1197. d();
  1198. c.count ? c.count > f.getUint16(b, !0) && (c.lastClickAt = t) : c.lastClickAt = 0;
  1199. c.count = f.getUint16(b, !0);
  1200. if (initialLoad) buttons[buttonIndex-1][2] = 1;
  1201. b += 2;
  1202. g();
  1203. break;
  1204. case 5:
  1205. c.x = f.getUint16(b, !0);
  1206. b += 2;
  1207. c.y = f.getUint16(b, !0);
  1208. b += 2;
  1209. c.queue = [
  1210. [0, c.x, c.y]
  1211. ];
  1212. c.potentialQueue = [];
  1213. c.explored = new Uint8Array(12E4);
  1214. c.img = a.createImageData(400, 300);
  1215. e = E.createElement("canvas");
  1216. e.width = 400;
  1217. e.height = 300;
  1218. c.canvas = e;
  1219. c.ctx = c.canvas.getContext("2d");
  1220. break;
  1221. default:
  1222. throw Error("Unknown object type " + e);
  1223. }
  1224. return b
  1225. }
  1226.  
  1227. function ea(a, b) {
  1228. if (-1 != J && -1 != K) {
  1229. var c = fa(J, K, a, b);
  1230. if (c.x != a || c.y != b) return !0
  1231. }
  1232. for (c = 0; c < r.length; c++) {
  1233. var d = r[c];
  1234. if (2 == d.type && !(k < d.x || q < d.y || k >= d.x + d.width || q >= d.y + d.height)) return !0
  1235. }
  1236. return !1
  1237. }
  1238.  
  1239. function ma() {
  1240. a.clearRect(0, 0, 800, 600);
  1241. a.save();
  1242. if (null != u && u.readyState != WebSocket.OPEN || L) {
  1243. var f;
  1244. if (null == u) f = "Click to begin";
  1245. else switch (u.readyState) {
  1246. case WebSocket.CONNECTING:
  1247. f = "Connecting";
  1248. break;
  1249. case WebSocket.CLOSING:
  1250. case WebSocket.CLOSED:
  1251. f = "Lost connection to server";
  1252. break;
  1253. default:
  1254. f = "Click to begin"
  1255. }
  1256. a.font = "60px NovaSquare";
  1257. a.fillText(f, 400 - a.measureText(f).width / 2, 315);
  1258. na();
  1259. oa(!1)
  1260. } else {
  1261. a.fillStyle = "#000000";
  1262. a.save();
  1263. a.globalAlpha = 1;
  1264. Ha();
  1265. for (f = 0; f < r.length; f++) {
  1266. var b = r[f];
  1267. if (0 == b.type) {
  1268. a.font = b.size + "px NovaSquare";
  1269. var c = b.x << 1,
  1270. d = b.y << 1;
  1271. b.isCentered && (c -= a.measureText(b.text).width / 2);
  1272. a.fillStyle = "#000000";
  1273. a.fillText(b.text,
  1274. c, d)
  1275. } else if (1 == b.type) a.fillStyle = b.color, a.fillRect(b.x << 1, b.y << 1, b.width << 1, b.height << 1), a.strokeStyle = "#000000", a.globalAlpha = .2, a.lineWidth = 2, a.strokeRect((b.x << 1) + 1, (b.y << 1) + 1, (b.width << 1) - 2, (b.height << 1) - 2), a.globalAlpha = 1;
  1276. else if (2 == b.type) a.fillStyle = b.isBad ? "#FF0000" : "#00FF00", a.globalAlpha = .2, a.fillRect(b.x << 1, b.y << 1, b.width << 1, b.height << 1), a.globalAlpha = 1;
  1277. else if (3 == b.type) {
  1278. var c = b.x << 1,
  1279. d = b.y << 1,
  1280. g = b.width << 1,
  1281. e = b.height << 1;
  1282. a.fillStyle = b.color;
  1283. a.globalAlpha = .2;
  1284. a.fillRect(c, d, g, e);
  1285. a.globalAlpha =
  1286. .5;
  1287. a.fillStyle = "#000000";
  1288. 40 > b.width || 40 > b.height ? (a.font = "30px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 10)) : (a.font = "60px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 20));
  1289. a.globalAlpha = 1
  1290. } else if (4 == b.type) {
  1291. c = b.x << 1;
  1292. d = b.y << 1;
  1293. g = b.width << 1;
  1294. e = b.height << 1;
  1295. a.fillStyle = b.color;
  1296. a.strokeStyle = b.color;
  1297. a.globalAlpha = 1;
  1298. a.fillRect(c, d, g, e);
  1299. a.globalAlpha = .2;
  1300. a.fillStyle = "#000000";
  1301. a.fillRect(c, d, g, e);
  1302. a.globalAlpha = 1;
  1303. a.fillStyle = b.color;
  1304. var n = 150 > t - b.lastClickAt,
  1305. l = n ? 8 : 12;
  1306. a.fillRect(c + l, d + l, g - 2 * l, e - 2 * l);
  1307. a.strokeStyle = "#000000";
  1308. a.globalAlpha = .1;
  1309. a.beginPath();
  1310. a.moveTo(c, d);
  1311. a.lineTo(c + l, d + l);
  1312. a.moveTo(c + g, d);
  1313. a.lineTo(c + g - l, d + l);
  1314. a.moveTo(c, d + e);
  1315. a.lineTo(c + l, d + e - l);
  1316. a.moveTo(c + g, d + e);
  1317. a.lineTo(c + g - l, d + e - l);
  1318. a.moveTo(c, d);
  1319. a.rect(c, d, g, e);
  1320. a.rect(c + l, d + l, g - 2 * l, e - 2 * l);
  1321. a.stroke();
  1322. a.fillStyle = "#000000";
  1323. a.globalAlpha = .5;
  1324. 50 > b.width || 50 > b.height ? (a.font = "35px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 13)) : (a.font = "45px NovaSquare", a.fillText(b.count,
  1325. c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 16));
  1326. n && (a.fillStyle = "#000000", a.globalAlpha = .15, a.fillRect(c + l, d + l, g - 2 * l, e - 2 * l));
  1327. a.globalAlpha = 1
  1328. } else 5 == b.type && (ga(!1), a.drawImage(b.canvas, 0, 0, 400, 300, 0, 0, 800, 600), ga(!0))
  1329. }
  1330. a.restore();
  1331. D || (a.font = "12px NovaSquare", a.strokeStyle = "#000000", a.fillStyle = "#FFFFFF", a.lineWidth = 2.5, f = ja ? "Area too full, not all cursors are shown" : 30 < ia ? "Area too full, drawing is disabled" : "Use shift+click to draw", a.globalAlpha = .5, a.strokeText(f, 10, 590), a.globalAlpha = 1, a.fillText(f,
  1332. 10, 590), 0 != aa && (f = aa + " players online", b = a.measureText(f).width, a.globalAlpha = .5, a.strokeText(f, 790 - b, 590), a.globalAlpha = 1, a.fillText(f, 790 - b, 590)));
  1333. na();
  1334. if (!H.checked) {
  1335. a.save();
  1336. a.strokeStyle = "#000000";
  1337. a.lineWidth = 1;
  1338. t = +new Date;
  1339. for (f = 0; f < O.length; f++) b = O[f], c = 10 - (t - b[4]) / 1E3, 0 >= c ? (O.splice(f, 1), --f) : (1 < c && (c = 1), a.globalAlpha = .3 * c, a.beginPath(), a.moveTo(b[0] - .5, b[1] - .5), a.lineTo(b[2] - .5, b[3] - .5), a.stroke());
  1340. a.restore()
  1341. }
  1342. a.save();
  1343. for (var p in F) F.hasOwnProperty(p) && a.drawImage(P, sa(F[p].getX()) - 6, ta(F[p].getY()) -
  1344. 6);
  1345. a.restore();
  1346. oa(!0)
  1347. }
  1348. a.restore();
  1349. A.requestAnimationFrame(ma)
  1350. }
  1351.  
  1352. function na() { // draws circles when you click
  1353. a.save();
  1354. a.strokeStyle = "#000000";
  1355. t = +new Date;
  1356. for (var f = 0; f < I.length; f++) {
  1357. var b = I[f],
  1358. c = (t - b[2]) / 1E3,
  1359. d = 1 - 2 * c;
  1360. 0 >= d ? (I.splice(f, 1), --f) : (c *= 50, a.beginPath(), a.globalAlpha = .3 * d, a.arc(b[0], b[1], c, 0, 2 * Math.PI, !1), a.stroke())
  1361. }
  1362. a.restore()
  1363. }
  1364.  
  1365. function oa(f) {
  1366. if (D) a.save(), a.globalAlpha = 1, a.drawImage(P, B - 5, C - 5);
  1367. else {
  1368. var b = 0,
  1369. c = 0;
  1370. v != k || w != q ? (a.save(), f && (a.globalAlpha = .2, a.fillStyle = "#FF0000", a.beginPath(), a.arc(B + 2, C + 8, 20, 0, 2 * Math.PI, !1),
  1371. a.fill()), a.globalAlpha = .5, a.drawImage(P, B - 5, C - 5), a.restore()) : (b = B & 1, c = C & 1);
  1372. a.save();
  1373. f && (a.globalAlpha = .2, a.fillStyle = "#FFFF00", a.beginPath(), a.arc((k << 1) + b + 2, (q << 1) + c + 8, 20, 0, 2 * Math.PI, !1), a.fill());
  1374. a.globalAlpha = 1;
  1375. a.drawImage(Ia, (k << 1) + b - 5, (q << 1) + c - 5)
  1376. }
  1377. a.restore()
  1378. }
  1379.  
  1380. function ka(a, b) {
  1381. this.oldX = this.newX = a;
  1382. this.oldY = this.newY = b;
  1383. this.time = t
  1384. }
  1385.  
  1386. function pa(a) {
  1387. return a * a * (3 - 2 * a)
  1388. }
  1389.  
  1390. function fa(a, b, c, d) {
  1391. a |= 0;
  1392. b |= 0;
  1393. c |= 0;
  1394. d |= 0;
  1395. if (z(a, b)) return {
  1396. x: a,
  1397. y: b
  1398. };
  1399. if (a == c && b == d) return {
  1400. x: c,
  1401. y: d
  1402. };
  1403. var g = a,
  1404. e = b;
  1405. c = c - a | 0;
  1406. d = d - b | 0;
  1407. var n =
  1408. 0,
  1409. l = 0,
  1410. p = 0,
  1411. k = 0;
  1412. 0 > c ? n = -1 : 0 < c && (n = 1);
  1413. 0 > d ? l = -1 : 0 < d && (l = 1);
  1414. 0 > c ? p = -1 : 0 < c && (p = 1);
  1415. var m = Math.abs(c) | 0,
  1416. h = Math.abs(d) | 0;
  1417. m <= h && (m = Math.abs(d) | 0, h = Math.abs(c) | 0, 0 > d ? k = -1 : 0 < d && (k = 1), p = 0);
  1418. c = m >> 1;
  1419. for (d = 0; d <= m && !z(a, b); d++) g = a, e = b, c += h, c >= m ? (c -= m, a += n, b += l) : (a += p, b += k);
  1420. return {
  1421. x: g,
  1422. y: e
  1423. }
  1424. }
  1425.  
  1426. function z(a, b) {
  1427. return 0 > a || 400 <= a || 0 > b || 300 <= b ? !0 : T[a + 400 * b]
  1428. }
  1429.  
  1430. function Ja() {
  1431. for (var a = 0; a < r.length; a++) {
  1432. var b = r[a];
  1433. 5 == b.type && Ka(b)
  1434. }
  1435. }
  1436.  
  1437. function Ka(a) {
  1438. function b(a, b, c) {
  1439. e.push([c, a, b]);
  1440. l[a + 400 * b] = !0;
  1441. g(a, b)
  1442. }
  1443.  
  1444. function c(a, b, c) {
  1445. p.push([c,
  1446. a, b
  1447. ]);
  1448. l[a + 400 * b] = !0
  1449. }
  1450.  
  1451. function d(a, b) {
  1452. return 255 != k[4 * (a + 400 * b) + 3] && !l[a + 400 * b]
  1453. }
  1454.  
  1455. function g(a, b) {
  1456. var c = 4 * (a + 400 * b);
  1457. k[c + 0] = 255;
  1458. k[c + 1] = 153;
  1459. k[c + 2] = 153;
  1460. k[c + 3] = 255
  1461. }
  1462. for (var e = a.queue, k = a.img.data, l = a.explored, p = a.potentialQueue, r = e.length, m = 0; m < p.length; m++) z(p[m][1], p[m][2]) || (g(p[m][1], p[m][2]), e.push(p[m]), p.splice(m, 1), --m);
  1463. for (m = 0; m < r; ++m) z(e[m][1], e[m][2]) && (p.push(e[m]), e.splice(m, 1), --m, --r);
  1464. for (r = 0; 50 > r && 0 != e.length; ++r) {
  1465. for (var h = Number.POSITIVE_INFINITY, q = [e[0]], m = 1; m < e.length; ++m) {
  1466. var x = e[m][0];
  1467. .01 > Math.abs(x - h) ? q.push(e[m]) : x < h && (h = x, q = [e[m]])
  1468. }
  1469. for (m = 0; m < q.length; ++m) {
  1470. var x = q[m][0],
  1471. h = q[m][1],
  1472. s = q[m][2],
  1473. qa = e.indexOf(q[m]); - 1 != qa && e.splice(qa, 1);
  1474. 0 < h && d(h - 1, s) && (z(h - 1, s) ? c(h - 1, s, x + 1) : b(h - 1, s, x + 1));
  1475. 0 < s && d(h, s - 1) && (z(h, s - 1) ? c(h, s - 1, x + 1) : b(h, s - 1, x + 1));
  1476. 400 > h + 1 && d(h + 1, s) && (z(h + 1, s) ? c(h + 1, s, x + 1) : b(h + 1, s, x + 1));
  1477. 300 > s + 1 && d(h, s + 1) && (z(h, s + 1) ? c(h, s + 1, x + 1) : b(h, s + 1, x + 1));
  1478. 0 < h && 0 < s && d(h - 1, s - 1) && (z(h - 1, s - 1) ? c(h - 1, s - 1, x + Math.SQRT2) : b(h - 1, s - 1, x + Math.SQRT2));
  1479. 0 < h && 300 > s + 1 && d(h - 1, s + 1) && (z(h - 1, s + 1) ? c(h - 1, s + 1, x + Math.SQRT2) :
  1480. b(h - 1, s + 1, x + Math.SQRT2));
  1481. 400 > h + 1 && 0 < s && d(h + 1, s - 1) && (z(h + 1, s - 1) ? c(h + 1, s - 1, x + Math.SQRT2) : b(h + 1, s - 1, x + Math.SQRT2));
  1482. 400 > h + 1 && 300 > s + 1 && d(h + 1, s + 1) && (z(h + 1, s + 1) ? c(h + 1, s + 1, x + Math.SQRT2) : b(h + 1, s + 1, x + Math.SQRT2))
  1483. }
  1484. }
  1485. a.ctx.putImageData(a.img, 0, 0)
  1486. }
  1487. var y, a, ia = 0,
  1488. v = 0,
  1489. w = 0,
  1490. B = 0,
  1491. C = 0,
  1492. k = 0,
  1493. q = 0,
  1494. J = -1,
  1495. K = -1,
  1496. M = null,
  1497. H = null,
  1498. P = new Image;
  1499. P.src = "img/cursor.png";
  1500. var Ia = P,
  1501. D = -1 != A.location.search.indexOf("editor"),
  1502. I = [],
  1503. O = [],
  1504. t = 0,
  1505. ca = 0,
  1506. u = null,
  1507. ha = -1,
  1508. F = {},
  1509. aa = 0,
  1510. ja = !1,
  1511. Y = !1,
  1512. R = 0,
  1513. S = 0,
  1514. da = 0,
  1515. X = !1,
  1516. L = !D && !0,
  1517. T = new Uint8Array(12E4),
  1518. r = [],
  1519. N = [];
  1520. Array.prototype.remove =
  1521. function(a) {
  1522. a = this.indexOf(a);
  1523. return -1 != a ? (this.splice(a, 1), !0) : !1
  1524. };
  1525. var G = 0;
  1526. ka.prototype = {
  1527. oldX: 0,
  1528. oldY: 0,
  1529. newX: 0,
  1530. newY: 0,
  1531. time: 0,
  1532. getX: function() {
  1533. var a = this.newX - this.oldX,
  1534. b = (t - this.time) / 100,
  1535. b = pa(0 >= b ? 0 : 1 <= b ? 1 : b);
  1536. return this.oldX + b * a
  1537. },
  1538. getY: function() {
  1539. var a = this.newY - this.oldY,
  1540. b = (t - this.time) / 100,
  1541. b = pa(0 >= b ? 0 : 1 <= b ? 1 : b);
  1542. return this.oldY + b * a
  1543. }
  1544. };
  1545. var ra = function() {
  1546. function f() {
  1547. var a = 0,
  1548. b = 0,
  1549. c = v / 10,
  1550. d = w / 10;
  1551. n < c ? (c = Math.ceil(c), a = Math.floor(n)) : (c = Math.floor(c), a = Math.ceil(n));
  1552. l < d ? (d = Math.ceil(d), b = Math.floor(l)) :
  1553. (d = Math.floor(d), b = Math.ceil(l));
  1554. if (a > c) var e = c,
  1555. c = a,
  1556. a = e;
  1557. b > d && (e = d, d = b, b = e);
  1558. return {
  1559. sx: a,
  1560. sy: b,
  1561. fx: c,
  1562. fy: d
  1563. }
  1564. }
  1565.  
  1566. function b() {
  1567. e = !0;
  1568. n = v / 10;
  1569. l = w / 10
  1570. }
  1571.  
  1572. function c(a) {
  1573. return "0x" + parseInt(a.slice(1), 16).toString(16).toUpperCase()
  1574. }
  1575.  
  1576. function d(a, b, c, d, e) {
  1577. a = {
  1578. x: 10 * ~~(k / 10) - ~~(a / 2) + c,
  1579. y: 10 * ~~(q / 10) - ~~(b / 2) + d,
  1580. width: a,
  1581. height: b
  1582. };
  1583. for (var f in e) e.hasOwnProperty(f) && (a[f] = e[f]);
  1584. return a
  1585. }
  1586.  
  1587. function g(a, b) {
  1588. for (var c = null, d = Number.POSITIVE_INFINITY, e = 0; e < r.length; e++) {
  1589. var f = r[e];
  1590. if (f.hasOwnProperty("x") && f.hasOwnProperty("y") && f.hasOwnProperty("width") &&
  1591. f.hasOwnProperty("height")) {
  1592. var g = f.x + f.width / 2,
  1593. h = f.y + f.height / 2,
  1594. g = (a - g) * (a - g) + (b - h) * (b - h);
  1595. g < d && (d = g, c = f)
  1596. }
  1597. }
  1598. return c
  1599. }
  1600. var e = !1,
  1601. n = 0,
  1602. l = 0,
  1603. p = 1,
  1604. u = 200,
  1605. m = 150,
  1606. h = new Uint8Array(1200),
  1607. t = "#000000 #FF9999 #9999FF #FFFF99 #99FFFF #FF99FF #3333FF".split(" ");
  1608. E.addEventListener("mouseup", function() {
  1609. if (e) {
  1610. for (var a = f(), b = p, c = a.sy; c < a.fy; ++c)
  1611. for (var d = a.sx; d < a.fx; ++d) h[d + 40 * c] = b;
  1612. e = !1
  1613. }
  1614. });
  1615. E.addEventListener("mousemove", function() {});
  1616. A.generateCode = function() {
  1617. for (var a = "class Level? : public Level {\npublic:\n\tLevel?() : Level(" +
  1618. u + ", " + m + "){}\n\n\tvoid OnInit(){\n", a = a + ("\t\tstd::vector<LevelObject*> wallByColor[" + t.length + "];\n"), b = new Uint8Array(1200), d = [], e = 0; 30 > e; ++e)
  1619. for (var f = 0; 40 > f; ++f)
  1620. if (!b[f + 40 * e]) {
  1621. var g = h[f + 40 * e];
  1622. if (0 != g) {
  1623. for (var k = f; 40 > f && h[f + 40 * e] == g && !b[f + 40 * e];) b[f + 40 * e] = !0, ++f;
  1624. var l = f--,
  1625. p = l - k,
  1626. q = e++;
  1627. a: for (; 30 > e;) {
  1628. for (var n = k; n < l; ++n) {
  1629. if (h[n + 40 * e] != g) break a;
  1630. if (b[n + 40 * e]) break a
  1631. }
  1632. for (n = k; n < l; ++n) b[n + 40 * e] = !0;
  1633. ++e
  1634. }
  1635. l = e - q;
  1636. e = q;
  1637. d.push({
  1638. x: 10 * k,
  1639. y: 10 * q,
  1640. width: 10 * p,
  1641. height: 10 * l,
  1642. color: g - 1
  1643. })
  1644. }
  1645. }
  1646. for (b = 0; b < d.length; b++) e = d[b], 0 ==
  1647. e.color ? a += "\t\tAddObject(new ObjWall(" + e.x + ", " + e.y + ", " + e.width + ", " + e.height + ", 0x000000));\n" : (f = c(t[e.color]), a += "\t\twallByColor[" + e.color + "].push_back(AddObject(new ObjWall(" + e.x + ", " + e.y + ", " + e.width + ", " + e.height + ", " + f + ")));\n");
  1648. for (b = 0; b < r.length; b++) d = r[b], 0 != d.type && (2 == d.type ? a += "\t\tAddObject(new ObjTeleport(LevelManager::GetNextLevel(this), " + d.x + ", " + d.y + ", " + d.width + ", " + d.height + "));\n" : 3 == d.type ? (a += "\t\tAddObject(new ObjAreaCounter(wallByColor[" + d.colorCode + "], " + d.x + ", " + d.y +
  1649. ", " + d.width + ", " + d.height + ", ", a += d.count + ", " + c(d.color) + "));\n") : 4 == d.type && (a += "\t\tAddObject(new ObjClickBox(wallByColor[" + d.colorCode + "], " + d.x + ", " + d.y + ", " + d.width + ", " + d.height + ", ", a += d.count + ", 1000, " + c(d.color) + "));\n"));
  1650. return a += "\t}\n};\n"
  1651. };
  1652. E.addEventListener("keydown", function(a) {
  1653. if (a.keyCode == 8) {
  1654. a.preventDefault();
  1655. if (message.length > 0) {
  1656. message = message.substring(0, message.length - 1);
  1657. messageDisplay.innerHTML = message;
  1658. }
  1659. }
  1660. else if (a.keyCode == 9) {
  1661. a.preventDefault();
  1662. }
  1663. if (D) {
  1664. var b = a.keyCode;
  1665. 65 == b ? (--p, 0 > p && (p = t.length)) : 83 == b ? (++p, p > t.length && (p = 0)) : 66 == b ? 1 >= p || r.push(d(40, 40, 5, 5, {
  1666. type: 4,
  1667. color: t[p - 1],
  1668. colorCode: p - 1,
  1669. count: 5
  1670. })) : 90 == b ? r.pop() : 87 == b ? r.push(d(50, 50, -5, -5, {
  1671. type: 2,
  1672. isBad: !1
  1673. })) : 79 == b ? (u = k, m = q) : 78 == b ? 1 >= p || r.push(d(40, 40, 0, 0, {
  1674. type: 3,
  1675. color: t[p - 1],
  1676. colorCode: p - 1,
  1677. count: 1
  1678. })) : 37 == b ? (b = g(v, w), null != b && (a.shiftKey ? b.width -= 10 : (b.x -= 10, b.width += 10), 0 == b.width && r.splice(r.indexOf(b), 1))) : 39 == b ? (b = g(v, w), null != b && (a.shiftKey ? (b.x += 10, b.width -= 10) : b.width += 10, 0 == b.width && r.splice(r.indexOf(b), 1))) : 38 == b ? (b = g(v, w), null != b && (a.shiftKey ? b.height -= 10 : (b.y -= 10, b.height += 10), 0 == b.height && r.splice(r.indexOf(b), 1))) : 40 == b && (b = g(v, w), null != b && (a.shiftKey ? (b.y += 10, b.height -= 10) : b.height +=
  1679. 10, 0 == b.height && r.splice(r.indexOf(b), 1)))
  1680. }
  1681. });
  1682. return {
  1683. renderEditor: function() {
  1684. if (D) {
  1685. a.save();
  1686. a.fillStyle = "#FF0000";
  1687. a.strokeStyle = "#FF0000";
  1688. a.lineWidth = 1;
  1689. a.globalAlpha = .09;
  1690. a.beginPath();
  1691. for (var b = 0; 400 > b; b += 10) a.moveTo((b << 1) + .5, 0), a.lineTo((b << 1) + .5, 600);
  1692. for (var c = 0; 300 > c; c += 10) a.moveTo(0, (c << 1) + .5), a.lineTo(800, (c << 1) + .5);
  1693. a.stroke();
  1694. a.lineWidth = 2;
  1695. a.beginPath();
  1696. a.moveTo(400.5, 0);
  1697. a.lineTo(400.5, 600);
  1698. a.moveTo(0, 300.5, 0);
  1699. a.lineTo(800, 300.5);
  1700. a.stroke();
  1701. a.lineWidth = 1;
  1702. a.globalAlpha = 1;
  1703. a.fillStyle = "#000000";
  1704. for (var d = f(), c = 0; 300 > c; c += 10)
  1705. for (b = 0; 400 > b; b += 10) {
  1706. var g = b / 10 | 0,
  1707. k = c / 10 | 0,
  1708. l = h[g + 40 * k];
  1709. e && g >= d.sx && g < d.fx && k >= d.sy && k < d.fy && (l = p);
  1710. 0 != l && (a.fillStyle = t[l - 1], a.fillRect(b << 1, c << 1, 20, 20))
  1711. }
  1712. a.save();
  1713. a.globalAlpha = .09;
  1714. a.fillStyle = "#0000FF";
  1715. a.beginPath();
  1716. a.arc(u << 1, m << 1, 20, 0, 2 * Math.PI, !1);
  1717. a.fill();
  1718. a.restore();
  1719. a.save();
  1720. a.fillStyle = "#FFFFFF";
  1721. a.strokeStyle = "#000000";
  1722. a.lineWidth = 2.5;
  1723. a.font = "14px NovaSquare";
  1724. a.globalAlpha = .5;
  1725. a.strokeText("Current color: ", 10, 590);
  1726. a.globalAlpha = 1;
  1727. a.fillText("Current color: ", 10,
  1728. 590);
  1729. 0 == p ? a.fillText("ESR", 105, 590) : (a.fillStyle = "#000000", a.fillRect(104, 575, 22, 22), a.fillStyle = t[p - 1], a.fillRect(105, 576, 20, 20));
  1730. a.restore();
  1731. a.restore()
  1732. }
  1733. },
  1734. initEditor: function() {
  1735. y.addEventListener("mousedown", b)
  1736. }
  1737. }
  1738. }(),
  1739. Ha = ra.renderEditor,
  1740. La = ra.initEditor,
  1741. za = new Uint8Array(12E4);
  1742. Array.prototype.remove = function(a) {
  1743. a = this.indexOf(a);
  1744. return -1 != a ? (this.splice(a, 1), !0) : !1
  1745. };
  1746.  
  1747. function handleKeyboard(e) {
  1748. if ((e.keyCode >= 97 && e.keyCode <= 122) || e.keyCode == 32 || e.keyCode == 63 || e.keyCode == 58 || e.keyCode == 40 || e.keyCode == 41) {
  1749. message = message.concat(String.fromCharCode(e.keyCode));
  1750. messageDisplay.innerHTML = message;
  1751. return;
  1752. }
  1753. switch(e.keyCode) {
  1754. case 13:
  1755. drawWord(message, posX, posY);
  1756. message = "";
  1757. messageDisplay.innerHTML = message;
  1758. e.preventDefault();
  1759. break;
  1760. case 96: // Click all buttons
  1761. clickAllButtons();
  1762. break;
  1763. case 47:
  1764. movementEnabled = !movementEnabled
  1765. break;
  1766. case 45: // Toggle Aura
  1767. auraEnabled = !auraEnabled;
  1768. break;
  1769. case 43:
  1770. drawImage(posX, posY);
  1771. break;
  1772. case 42:
  1773. markerEnabled = !markerEnabled;
  1774. break;
  1775. default:
  1776. return;
  1777. }
  1778. }
  1779.  
  1780. function clickAllButtons() {
  1781. for (var i = 0; i < maxButtons; i++) {
  1782. if (buttons[i][0] == null) break;
  1783. wa(buttons[i][0], buttons[i][1], buttons[i][2]);
  1784. }
  1785. }
  1786.  
  1787. function drawAura(x, y) {
  1788. var dt = 360/(1000/40)/2;
  1789. if (u != null && u.readyState == WebSocket.OPEN) {
  1790. var g = new ArrayBuffer(9),
  1791. e = new DataView(g);
  1792. e.setUint8(0, 3);
  1793. e.setUint16(1, x+Math.sin(degToRad(auraTime+dt))*auraRadius, !0);
  1794. e.setUint16(3, y+Math.cos(degToRad(auraTime+dt))*auraRadius, !0);
  1795. e.setUint16(5, x+Math.sin(degToRad(auraTime))*auraRadius, !0);
  1796. e.setUint16(7, y+Math.cos(degToRad(auraTime))*auraRadius, !0);
  1797. u.send(g)
  1798. }
  1799.  
  1800. auraTime += dt;
  1801. }
  1802.  
  1803. function degToRad(deg) {
  1804. return deg * (Math.PI / 180);
  1805. }
  1806.  
  1807. function radToDeg(rad) {
  1808. return rad * (180 / Math.PI);
  1809. }
  1810.  
  1811. var drawIndex = 0;
  1812. function drawImage(x, y) {
  1813. setTimeout(function () {
  1814. var g = new ArrayBuffer(9),
  1815. e = new DataView(g);
  1816.  
  1817. e.setUint8(0, 3);
  1818. e.setUint16(1, x+imgData[drawIndex][1]*imageScale, !0);
  1819. e.setUint16(3, y+imgData[drawIndex][0]*imageScale, !0);
  1820. e.setUint16(5, x+imgData[drawIndex][3]*imageScale, !0);
  1821. e.setUint16(7, y+imgData[drawIndex][2]*imageScale, !0);
  1822. u.send(g);
  1823.  
  1824. drawIndex++;
  1825. if (drawIndex < imgData.length)
  1826. drawImage(x, y);
  1827. else
  1828. drawIndex = 0;
  1829. }, 15)
  1830. }
  1831.  
  1832. function drawLetter(a, x, y) {
  1833. var letter = alphabet[a];
  1834.  
  1835. if (letter == null)
  1836. return;
  1837.  
  1838. var g = new ArrayBuffer(9),
  1839. e = new DataView(g);
  1840.  
  1841. for (var i = 0; i < letter.length; i++) {
  1842. e.setUint8(0, 3);
  1843. e.setUint16(1, x+alphabet[a][i][1]*fontSize, !0);
  1844. e.setUint16(3, y+alphabet[a][i][0]*fontSize, !0);
  1845. e.setUint16(5, x+alphabet[a][i][3]*fontSize, !0);
  1846. e.setUint16(7, y+alphabet[a][i][2]*fontSize, !0);
  1847. for (var j = 0; j < 4; j++) { u.send(g); }
  1848. }
  1849. }
  1850.  
  1851. var messageDisplay;
  1852. var message = new String();
  1853. var wordIndex = 0;
  1854. function drawWord(s, x, y) {
  1855. setTimeout(function () {
  1856. drawLetter(s.charCodeAt(0), x, y);
  1857. wordIndex++;
  1858. if (s.length > 0)
  1859. drawWord(s.substring(1, s.length), x+fontSize*3, y);
  1860. else {
  1861. wordIndex = 0;
  1862. letterOffset = 0;
  1863. }
  1864. }, 20);
  1865. }
  1866.  
  1867. function doit() {
  1868. document.body.innerHTML += '<div id="messageDisplay"></div>';
  1869. messageDisplay = document.getElementById("messageDisplay");
  1870.  
  1871. y = E.getElementById("canvas");
  1872. a = y.getContext("2d");
  1873. try {
  1874. A.top.location.origin != A.location.origin && ba()
  1875. } catch (f) {
  1876. ba()
  1877. }
  1878. y.onmousemove = ua;
  1879. y.onmousedown = va;
  1880. y.onmouseup = xa;
  1881. M = E.getElementById("noCursorLock");
  1882. H = E.getElementById("noDrawings");
  1883. null != localStorage && (M.checked = "1" == A.localStorage.getItem("noCursorLock") ? !0 : !1, H.checked = "1" == A.localStorage.getItem("noDrawings") ? !0 : !1);
  1884. A.onbeforeunload = ya;
  1885. y.requestPointerLock = y.requestPointerLock || y.mozRequestPointerLock || y.webkitRequestPointerLock;
  1886. y.style.cursor = "none";
  1887. La();
  1888. D || null == u && (u = new WebSocket("ws://s1.cursors.io:443/"), u.binaryType = "arraybuffer", u.onopen = Aa, u.onmessage = Ga, u.onclose =
  1889. Ba, u.onerror = Ca);
  1890. setInterval(Q, 50);
  1891. setInterval(Ja, 40);
  1892. A.requestAnimationFrame(ma)
  1893.  
  1894. document.onkeypress = handleKeyboard;
  1895. }
  1896.  
  1897. doit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement