Advertisement
Guest User

Untitled

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