Guest User

Cursors.io Hack modified V1.03

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