BulleGames

Cursor.io Hack Fix 07.06.2017

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