JasontheFuzz

Cursor Jesus v2.0

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