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