Advertisement
Guest User

nekonecro8

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