Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ___ _ _ _ __ ___ ___ _ __ ___ _ ___
- / __| | | | `__/ __|/ _ \| `__/ __| | |/ _ \
- | (__| |_| | | \__ \ (_) | | \__ \_| | (_) |
- \___|\__,_|_| |___/\___/|_| |___(_)_|\___/
- script for texting and drawing in CURSORS.IO
- //done, no pathfinder
- */
- /* How to use:
- 1. Go to cursors.io, open console (ctrl + shift + j or F12)
- and paste this entire script into the console, then hit enter.
- 2. To type: type message and hit enter (shift+enter for new row)
- 3. To move your cursor only when clicking: press numpad .
- Use it to pass red walls levels ;)
- To move your cursor normally: press numpad . again
- 4. To draw a circle: press numpad 0
- To stop drawing a circle: press numpad 0 again
- 5. To draw arrows, use the arrow keys
- 6. To draw different images press numpad 1 - numpad 9 keys
- 7. To make drawings bigger/smaller use numpad + and -
- 8. Reset drawing size with numpad *
- 9. To show/hide cursors ids: press F8
- 10. Change ids position with: F9
- 11. To show this help: press F4
- */
- var A = window;
- var E = document;
- var posX, posY;
- var lastX, lastY;
- var serverPosX, serverPosY;
- var initialLoad = true;
- var clicksCount = 3;
- var auraEnabled = false;
- var auraTime = 0;
- var auraRadius = 10;
- var movementEnabled = true;
- var showcursorsid = false;
- var fontSize = 2;
- var kerning = 3;
- var alphabet = {
- 33:[ [0,1,2,1],[2.5,1,3,1] ],
- 34:[[0,0.5,1,0.5],[0,1.25,1,1.25]],
- 35:[ [0.5,-0.25,0.5,2.3], [1.5,-0.25,1.5,2.3], [-0.25,0.5,2.3,0.5], [-0.25,1.5,2.3,1.5] ],
- 39:[[0,0.5,1,0.5]], // '
- 40:[[0,2,0.5,1],[0.5,1,1.5,1],[1.5,1,2,2]],
- 41:[[0,0,0.5,1],[0.5,1,1.5,1],[1.5,1,2,0]],
- 43:[ [0,1,2,1],[1,0,1,2] ],
- 44:[[2.5,0,3.5,0]],
- 45:[ [0.6,0.3,0.6,1.7] ],
- 46:[[2,0,1.5,0]],
- 47:[ [2,0.4,0,1.6] ],
- 48:[[2,0,0,0],[0,0,0,2],[0,2,2,2],[2,2,2,0]],
- 49:[[0,1,2,1],[1,0,0,1],[2,0,2,2]],
- 50:[[0,0,0,2],[0,2,1,2],[1,2,1,0],[1,0,2,0],[2,0,2,2]],
- 51:[[0,0,0,2],[0,2,2,2],[2,2,2,0],[1,0,1,2]],
- 52:[[0,0,1,0],[1,0,1,2],[0,2,2,2]],
- 53:[[0,2,0,0],[0,0,1,0],[1,0,1,2],[1,2,2,2],[2,2,2,0]],
- 54:[[0,2,0,0],[0,0,2,0],[2,0,2,2],[2,2,1,2],[1,2,1,0]],
- 55:[[0,0,0,2],[0,2,2,0]],
- 56:[[0,0,0,2],[0,2,2,2],[2,2,2,0],[2,0,0,0],[1,0,1,2]],
- 57:[[0,0,1,0],[1,0,1,2],[0,2,2,2],[0,0,0,2],[2,0,2,2]],
- 58:[ [0.5,0,1,0],[1.5,0,2,0] ],
- 59:[ [0.5,0,1,0],[2.2,0,3.5,0] ],
- 61:[ [0.5,0,0.5,2], [1.5,0,1.5,2] ],
- 63:[[1,0,0,0],[0,0,0,2],[0,2,1,2],[1,2,1,1],[1,1,2,1],[2.5,1,3,1] ],
- 92:[ [0,0.4,2,1.6] ],
- 95:[ [2,0,2,2] ],
- 96:[[0,0.5,1,0.5]], // ` display same as 39
- 97:[[2,0,0,0],[0,2,0,0],[0,2,2,2],[1,0,1,2]],
- 98:[[2,0,0,0],[0,0,0,2],[0,2,2,2],[2,2,2,0],[1,0,1,2]],
- 99:[[2,2,2,0],[2,0,0,0],[0,0,0,2]],
- 100:[[2,0,0,0],[0,0,0,1],[0,1,1,2],[1,2,2,1],[2,1,2,0]],
- 101:[[2,2,2,0],[2,0,0,0],[0,0,0,2],[1,0,1,2]],
- 102:[[2,0,0,0],[0,0,0,2],[1,0,1,2]],
- 103:[[1,1,1,2],[1,2,2,2],[2,2,2,0],[2,0,0,0],[0,0,0,2]],
- 104:[[0,0,2,0],[0,2,2,2],[1,0,1,2]],
- 105:[[0,0,0,2],[0,1,2,1],[2,0,2,2]],
- 106:[[0,0,0,2],[0,1,2,1],[2,0,2,1]],
- 107:[[0,0,2,0],[1,0,0,2],[1,0,2,2]],
- 108:[[0,0,2,0],[2,0,2,2]],
- 109:[[0,0,2,0],[0,0,2,1],[2,1,0,2],[0,2,2,2]],
- 110:[[0,0,2,0],[0,0,2,2],[0,2,2,2]],
- 111:[[2,0,0,0],[0,0,0,2],[0,2,2,2],[2,2,2,0]],
- 112:[[2,0,0,0],[0,0,0,2],[0,2,1,2],[1,2,1,0]],
- 113:[[2,0,0,0],[0,0,0,2],[0,2,2,2],[2,2,2,0],[1,1,2,2]],
- 114:[[2,0,0,0],[0,0,0,2],[0,2,1,2],[1,2,1,0],[1,1,2,2]],
- 115:[[0,0,0,2],[1,0,1,2],[2,0,2,2],[0,0,1,0],[1,2,2,2]],
- 116:[[0,0,0,2],[0,1,2,1]],
- 117:[[0,0,2,0],[0,2,2,2],[2,0,2,2]],
- 118:[[0,0,2,1],[0,2,2,1]],
- 119:[[0,0,2,0],[0,2,2,2],[2,0,1,1],[2,2,1,1]],
- 120:[[0,0,2,2],[2,0,0,2]],
- 121:[[0,0,1,1],[0,2,1,1],[2,1,1,1]],
- 122:[[0,0,0,2],[0,2,2,0],[2,0,2,2]],
- };
- var imageScale = 1.0;
- var imgData = [
- /* arrow left */
- [[0,0,0,9],[0,0,-3,3],[0,0,3,3]],
- /* arrow up */
- [[0,0,9,0],[0,0,3,-3],[0,0,3,3]],
- /* arrow right */
- [[0,0,0,-9],[0,0,-3,-3],[0,0,3,-3]],
- /* arrow down */
- [[0,0,-9,0],[0,0,-3,-3],[0,0,-3,3]],
- /*star 5*/
- [[8,0,8,24],[8,24,24,4],[24,4,0,12],[0,12,24,20],[24,20,8,0]],
- /* reversed star */
- [[0,4,24,12],[24,12,0,20],[0,20,16,0],[16,0,16,24],[16,24,0,4]],
- /*tictactoe*/
- [[72,24,0,24],[0,48,72,48],[24,0,24,72],[48,0,48,72],[0,0,0,72],[0,72,72,72],[72,72,72,0],[72,0,0,0]],
- /*pentashot*/
- [[50,16,66,17],[66,17,65,32],[51,26,72,36],[65,32,65,33],[72,36,64,52],[49,35,69,58],[69,58,54,71],[54,71,35,48],[49,65,33,70],[33,70,25,49],[16,46,16,63],[16,63,30,63],[50,16,51,19],[51,19,51,26],[51,26,49,35],[49,35,46,40],[46,40,43,43],[43,43,38,47],[38,47,32,49],[32,49,27,49],[27,49,24,49],[24,49,21,48],[21,48,16,46],[16,46,13,44],[13,44,10,41],[10,41,8,38],[8,38,5,32],[5,32,4,24],[4,24,5,18],[5,18,8,11],[8,11,12,7],[12,7,16,4],[16,4,21,2],[21,2,25,1],[25,1,31,1],[31,1,35,2],[35,2,40,4],[40,4,45,8],[45,8,48,13],[48,13,50,16]],
- /*triforce*/
- [[20,0,0,10],[0,10,20,20],[20,20,20,0],[10,5,10,15],[10,15,20,10],[20,10,10,5],[2,9,2,11],[3,9,3,11],[4,8,4,12],[5,8,5,12],[6,7,6,13],[7,7,7,13],[8,6,8,14],[9,6,9,14],[12,4,12,6],[12,14,12,16],[13,4,13,6],[13,14,13,16],[14,3,14,7],[14,13,14,17],[15,3,15,7],[15,13,15,17],[16,2,16,8],[16,12,16,18],[17,2,17,8],[17,12,17,18],[18,1,18,9],[18,11,18,19],[19,1,19,9],[19,11,19,19]],
- /*heart*/
- [[9,5,4,0],[4,0,2,0],[2,0,1,1],[4,10,9,5],[1,1,1,3],[1,3,3,5],[3,5,1,7],[1,7,1,9],[1,9,2,10],[2,10,4,10]],
- /*dickboob*/
- [[78,21,53,17],[53,17,47,13],[47,13,42,14],[42,14,33,20],[33,20,12,30],[12,30,2,43],[2,43,1,61],[1,61,11,74],[11,74,27,81],[27,81,61,89],[61,89,79,98],[79,98,70,110],[70,110,67,120],[67,120,67,128],[67,128,32,132],[32,132,30,140],[30,140,35,148],[35,148,53,151],[53,151,68,147],[68,147,68,151],[68,151,61,156],[61,156,67,161],[67,161,70,156],[70,156,72,163],[72,163,74,156],[74,156,75,168],[75,168,82,169],[82,169,91,164],[91,164,92,157],[92,157,111,154],[111,154,128,142],[128,142,132,130],[132,130,136,129],[136,129,163,133],[163,133,165,130],[165,130,159,114],[159,114,152,105],[152,105,148,105],[148,105,148,119],[148,119,138,117],[138,117,145,103],[145,103,147,89],[147,89,181,85],[181,85,178,73],[178,73,166,61],[166,61,163,62],[163,62,161,68],[161,68,167,77],[167,77,146,79],[146,79,145,68],[145,68,137,53],[137,53,117,36],[80,110,82,117],[82,117,76,127],[76,127,65,128],[81,118,91,111],[75,126,78,142],[78,142,84,152],[84,152,92,157],[86,106,86,109],[55,144,57,142],[62,143,61,145],[95,125,99,124],[109,125,110,123],[113,130,116,127],[118,135,120,132],[54,18,49,24],[49,24,41,28],[41,28,35,26],[35,26,30,22],[33,25,37,34],[37,34,42,36],[42,36,50,34],[50,34,53,26],[53,26,54,18],[37,41,42,36],[50,34,56,33],[56,33,57,39],[57,39,54,46],[54,46,49,45],[49,45,50,39],[23,62,29,51],[29,51,40,48],[40,48,45,51],[45,51,48,57],[48,57,46,65],[46,65,39,72],[39,72,30,71],[30,71,25,67],[25,67,23,61],[27,63,33,64],[33,64,39,61],[39,61,42,54],[42,54,45,55],[45,55,44,61],[44,61,39,69],[39,69,29,69],[29,69,27,63],[68,20,48,73],[71,72,107,81],[107,81,114,79],[114,79,120,79],[120,79,121,84],[121,84,113,84],[113,84,120,88],[120,88,117,91],[117,91,110,90],[110,90,111,100],[111,100,107,100],[107,100,105,89],[105,89,70,78],[76,21,80,21],[80,21,87,8],[87,8,98,3],[98,3,105,3],[105,3,107,1],[107,1,108,1],[108,1,109,4],[109,4,116,10],[116,10,118,17],[118,17,115,35],[115,35,117,36],[115,35,105,33],[105,33,93,35],[93,35,80,39],[115,35,120,44],[120,44,120,59],[120,59,115,66],[115,66,108,72],[108,72,99,74],[99,74,93,73],[112,7,107,8],[107,8,102,7],[102,7,101,3],[102,48,105,44],[105,44,109,45],[109,45,112,49],[112,49,108,56],[108,56,104,55],[104,55,102,48],[105,49,106,48],[106,48,107,49],[107,49,106,50],[106,50,105,49]],
- ];
- function sa(f) {
- return f << 1;
- }
- function ta(f) {
- return f << 1;
- }
- function U() {
- return E.pointerLockElement === y || E.mozPointerLockElement === y || E.webkitPointerLockElement === y;
- }
- function ba() {
- a.fillStyle = "#000000";
- a.font = "35px NovaSquare";
- a.fillText("Please do not embed our website, thank you.", 400 - a.measureText("Please do not embed our website, thank you.").width / 2, 300);
- a.font = "16px NovaSquare";
- a.fillText("Play http://cursors.io/", 400 - a.measureText("Play http://cursors.io/").width /
- 2, 330);
- top.location = "http://cursors.io";
- throw "Please do not embed our website, thank you.";
- }
- function ua(f) {
- V(f);
- }
- function W(f, b) {
- J = f;
- K = b;
- k = v = f;
- q = w = b;
- B = v << 1;
- C = w << 1;
- }
- function Ma() {
- //var eng = document.body.childNodes[1].getElementsByTagName("a")[0];
- //eng.outerHTML = "<label style='float:right;'>Press F4 for help</label>";
- var eng = document.querySelectorAll("a[href='https://m28.studio/']");
- eng[0].outerHTML = "<label style='float:right;'>Press F4 for help</label>";
- /*eng.href = "http://cursors.io/";
- eng.target = "_blank";
- eng.innerHTML = "More levels!";
- eng.style.visibility = "hidden";*/
- }
- function va(f) {
- if (D) return L = !1, V(f), !1;
- U() ? X || (X = !0, W(k, q)) : (X = !1, D || M.checked || y.requestPointerLock && y.requestPointerLock());
- if (L) L = !1, Q();
- else if (V(f), (f.ctrlKey || f.shiftKey) && !H.checked) Y = !0, R = k, S = q;
- else if (100 < t - ca && v == k && w == q) {
- ca = t;
- I.push([v << 1, w << 1, t]);
- wa(v, w, clicksCount);
- var b = [v, w];
- N.push(b);
- setTimeout(function() {
- N.remove(b);
- }, 1E3);
- }
- return !1;
- }
- function xa(f) {
- Y = !1;
- }
- function ya() {
- A.localStorage && M && (A.localStorage.setItem("noCursorLock", M.checked ? "1" : "0"), A.localStorage.setItem("noDrawings", H.checked ? "1" : "0"));
- }
- function V(f) {
- if (U()) {
- var b = f.webkitMovementX || f.mozMovementX || f.movementX || 0;
- f = f.webkitMovementY || f.mozMovementY || f.movementY || 0;
- 300 > Math.abs(b) + Math.abs(f) && (B += b, C += f, v = B >> 1, w = C >> 1);
- } else f.offsetX ? (B = f.offsetX, C = f.offsetY) : f.layerX && (B = f.layerX, C = f.layerY), v = B >> 1, w = C >> 1;
- lastX = posX;
- lastY = posY;
- posX = k;
- posY = q;
- if (Z(), !U() || v == k && w == q || (f = b = 0, v > k && (b = 1),
- w > q && (f = 1), v = k, w = q, B = (v << 1) + b, C = (w << 1) + f), Y && (R != k || S != q) && 50 < t - da) {
- b = R;
- f = S;
- var a = k,
- d = q;
- if (!D && null != u && u.readyState == WebSocket.OPEN) {
- var g = new ArrayBuffer(9),
- e = new DataView(g);
- e.setUint8(0, 3);
- e.setUint16(1, b, !0);
- e.setUint16(3, f, !0);
- e.setUint16(5, a, !0);
- e.setUint16(7, d, !0);
- u.Send(g);
- }
- R = k;
- S = q;
- da = t;
- }
- }
- function Z() {
- ea(k, q) && Q();
- if (z(k, q)) {
- var a;
- a: {
- a = k;
- var b = q,
- c = [],
- d = new Uint8Array(12E4);
- c.push([a, b]);
- d[a + 400 * b] = 1;
- do {
- var g = c.shift(),
- e = g[0],
- g = g[1];
- if (!(0 > e || 0 > g || 400 <= e || 300 <= g)) {
- if (!z(e, g)) {
- a = {
- x: e,
- y: g
- };
- break a;
- }
- d[e - 1 + 400 * g] || (c.push([e - 1, g]), d[e - 1 + 400 * g] = 1);
- d[e + 1 + 400 * g] || (c.push([e + 1, g]), d[e + 1 + 400 * g] = 1);
- d[e + 400 * (g - 1)] || (c.push([e, g - 1]), d[e + 400 * (g - 1)] = 1);
- d[e + 400 * (g + 1)] || (c.push([e, g + 1]), d[e + 400 * (g + 1)] = 1);
- }
- } while (0 < c.length);
- a = {
- x: a,
- y: b
- };
- }
- k = a.x;
- q = a.y;
- }
- if (k != v || q != w) a = fa(k, q, v, w), k = a.x, q = a.y;
- ea(k, q) && Q();
- }
- function next() {
- console.log("Next map");
- initialLoad = true;
- T.set(za);
- r = [];
- I = [];
- O = [];
- }
- function ga(f) {
- a.imageSmoothingEnabled = f;
- a.mozImageSmoothingEnabled = f;
- a.oImageSmoothingEnabled = f;
- a.webkitImageSmoothingEnabled = f;
- }
- function Aa() {
- next();
- console.log("Connected!");
- }
- function Ba(a) {
- next();
- console.log("Socket closed: " + a.reason);
- }
- function Ca(a) {
- console.log("Socket error");
- }
- function Da(a, b) {
- for (var c = "", d = 0, g = 0; 0 != (g = a.getUint8(b)); ++b) d <<= 8, d |= g, g & 128 || (c += String.fromCharCode(d), d = 0);
- 0 != d && (c += String.fromCharCode(d));
- return [c, b + 1];
- }
- function Ea(a, b) {
- setTimeout(function() {
- var c = a.getUint16(b, !0),
- d = 0;
- a: for (; d < c; d++) {
- for (var g = a.getUint16(b + 2 + 4 * d, !0), e = a.getUint16(b + 4 + 4 * d, !0), n = 0; n < N.length; n++) {
- var l = N[n];
- if (l[0] == g && l[1] == e) {
- N.splice(n, 1);
- continue a;
- }
- }
- I.push([g << 1, e << 1, t]);
- }
- }, 100);
- return b + 2 + 4 * a.getUint16(b, !0);
- }
- function Fa(a, b) {
- !H.checked && setTimeout(function() {
- for (var c = a.getUint16(b, !0), d = 0; d < c; d++) {
- var g = a.getUint16(b + 2 + 8 * d, !0),
- e = a.getUint16(b + 4 + 8 * d, !0),
- n = a.getUint16(b + 6 + 8 * d, !0),
- l = a.getUint16(b + 8 + 8 * d, !0);
- O.push([g << 1, e << 1, n << 1, l << 1, t]);
- }
- }, 50);
- return b + 2 + 8 * a.getUint16(b, !0);
- }
- function Ga(a) {
- buttonIndex = 0;
- initialLoad = false;
- a = a.data;
- var b = new DataView(a);
- switch (b.getUint8(0)) {
- case 0:
- ha = b.getUint32(1, !0);
- break;
- case 1:
- var c;
- ia = c = b.getUint16(1, !0);
- ja = 100 <= c;
- var d = [],
- g;
- for (g in F) F.hasOwnProperty(g) && d.push(g);
- for (var e =
- 0; e < c; e++) {
- g = b.getUint32(3 + 8 * e, !0);
- var n = b.getUint16(7 + 8 * e, !0),
- l = b.getUint16(9 + 8 * e, !0);
- if (g != ha) {
- if (null != F[g]) {
- for (var p = 0; p < d.length; p++)
- if (d[p] == g) {
- d.splice(p, 1);
- break;
- }
- g = F[g];
- g.oldX = g.getX();
- g.oldY = g.getY();
- g.newX = n;
- g.newY = l;
- g.time = t;
- } else F[g] = new ka(n, l);
- } else {
- serverPosX = n;
- serverPosY = l;
- }
- }
- for (e = 0; e < d.length; e++) delete F[d[e]];
- c = Ea(b, 3 + 8 * c);
- g = b.getUint16(c, !0);
- c += 2;
- for (d = 0; d < g; d++) {
- a: for (n = b.getUint32(c, !0), e = 0; e < r.length; e++)
- if (r[e].id == n) {
- var k = r[e];
- if (1 == k.type)
- for (var n = k.x | 0, l = k.y | 0, p = k.width | 0, k = k.height | 0, m = l; m < l + k; ++m)
- for (var h =
- n; h < n + p; ++h) --T[h + 400 * m];
- r.splice(e, 1);
- break a;
- }c += 4;
- }
- g = b.getUint16(c, !0);
- c += 2;
- for (d = 0; d < g; d++) {
- a: {
- e = b.getUint32(c, !0);
- for (n = 0; n < r.length; n++)
- if (r[n].id == e) {
- e = r[n];
- break a;
- }
- e = {
- id: e
- };
- r.push(e);
- }
- c += 4;c = la(b, c, e);
- }
- c = Fa(b, c);
- if (a.byteLength < c + 4) break;
- aa = b.getUint32(c, !0);
- break;
- case 4:
- next();
- W(b.getUint16(1, !0), b.getUint16(3, !0));
- g = b.getUint16(5, !0);
- c = 7;
- for (d = 0; d < g; d++) e = {}, e.id = b.getUint32(c, !0), c += 4, c = la(b, c, e), r.push(e);
- a.byteLength >= c + 4 ? G = Math.max(G, b.getUint32(c, !0)) : a.byteLength >= c + 2 && (G = Math.max(G, b.getUint16(c, !0)));
- Z();
- break;
- case 5:
- W(b.getUint16(1, !0), b.getUint16(3, !0)), 9 <= b.byteLength ? G = Math.max(G, b.getUint32(5, !0)) : 7 <= b.byteLength && (G = Math.max(G, b.getUint16(5, !0))), Z();
- }
- }
- function Q() {
- if (!(D || L || null == u || u.readyState != WebSocket.OPEN || k == J && q == K) && movementEnabled) {
- var a = new ArrayBuffer(9);
- b = new DataView(a);
- b.setUint8(0, 1);
- b.setUint16(1, k, !0);
- b.setUint16(3, q, !0);
- b.setUint32(5, G, !0);
- u.send(a);
- J = k;
- K = q;
- }
- }
- function Au() {
- Throttler.sendOut();
- if (auraEnabled) drawAura(J, K);
- }
- function wa(a, b, numClicks) {
- if (!D && null != u && u.readyState == WebSocket.OPEN) {
- var c = new ArrayBuffer(9),
- d = new DataView(c);
- d.setUint8(0, 2);
- d.setUint16(1, a, !0);
- d.setUint16(3, b, !0);
- d.setUint32(5, G, !0);
- for (var i = 0; i < numClicks; i++) { u.Send(c); }
- }
- }
- function la(f, b, c) {
- function d() {
- c.x = f.getUint16(b, !0);
- b += 2;
- c.y = f.getUint16(b, !0);
- b += 2;
- c.width = f.getUint16(b, !0);
- b += 2;
- c.height = f.getUint16(b, !0);
- b += 2;
- }
- function g() {
- for (var a = f.getUint32(b, !0).toString(16); 6 > a.length;) a = "0" + a;
- b += 4;
- c.color = "#" + a;
- }
- var e = f.getUint8(b);
- b += 1;
- c.type = e;
- switch (e) {
- case 255:
- break;
- case 0:
- c.x = f.getUint16(b, !0);
- b += 2;
- c.y = f.getUint16(b, !0);
- b += 2;
- c.size = f.getUint8(b);
- b += 1;
- c.isCentered = !!f.getUint8(b);
- b += 1;
- e = Da(f, b);
- c.text = e[0];
- b = e[1];
- break;
- case 1:
- d();
- var n = !c.color;
- g();
- var e = c.x | 0,
- l = c.y | 0,
- p = c.width | 0,
- k = c.height | 0;
- if (n)
- for (n = l; n < l + k; ++n)
- for (var m = e; m < e + p; ++m) ++T[m + 400 * n];
- break;
- case 2:
- d();
- c.isBad = !!f.getUint8(b);
- b += 1;
- break;
- case 3:
- d();
- c.count = f.getUint16(b, !0);
- b += 2;
- g();
- break;
- case 4:
- d();
- c.count ? c.count > f.getUint16(b, !0) && (c.lastClickAt = t) : c.lastClickAt = 0;
- c.count = f.getUint16(b, !0);
- b += 2;
- g();
- break;
- case 5:
- c.x = f.getUint16(b, !0);
- b += 2;
- c.y = f.getUint16(b, !0);
- b += 2;
- c.queue = [ [0, c.x, c.y]];
- c.potentialQueue = [];
- c.explored = new Uint8Array(12E4);
- c.img = a.createImageData(400, 300);
- e = E.createElement("canvas");
- e.width = 400;
- e.height = 300;
- c.canvas = e;
- c.ctx = c.canvas.getContext("2d");
- break;
- default:
- throw Error("Unknown object type " + e);
- }
- return b;
- }
- function ea(a, b) {
- if (-1 != J && -1 != K) {
- var c = fa(J, K, a, b);
- if (c.x != a || c.y != b) return !0;
- }
- for (c = 0; c < r.length; c++) {
- var d = r[c];
- if (2 == d.type && !(k < d.x || q < d.y || k >= d.x + d.width || q >= d.y + d.height)) return !0;
- }
- return !1;
- }
- var showHelp = false;
- function ma() {
- a.clearRect(0, 0, a.canvas.width, a.canvas.height);
- a.save();
- if (null != u && u.readyState != WebSocket.OPEN || L) {
- var f;
- if (null == u) f = "Click to begin";
- else switch (u.readyState) {
- case WebSocket.CONNECTING:
- f = "Connecting";
- break;
- case WebSocket.CLOSING:
- case WebSocket.CLOSED:
- f = "Lost connection to server";
- break;
- default:
- f = "Click to begin";
- }
- a.font = 60 + "px NovaSquare";
- a.fillText(f, 400 - a.measureText(f).width / 2, 300);
- a.font = 20 + "px NovaSquare";
- f = "-> Texting and drawing script <-";
- a.fillText(f, 400 - a.measureText(f).width / 2, 345);
- na();
- oa(!1);
- } else {
- a.fillStyle = "#000000";
- a.save();
- a.globalAlpha = 1;
- var typeZeroCount = 0;
- var typeOneCount = 0;
- var typeTwoCount = 0;
- var typeThreeCount = 0;
- var typeFourCount = 0;
- for (f = 0; f < r.length; f++) {
- var b = r[f];
- if (0 == b.type) {
- a.font = b.size + "px NovaSquare";
- var c = b.x << 1,
- d = b.y << 1;
- b.isCentered && (c -= a.measureText(b.text).width / 2);
- a.fillStyle = "#000000";
- a.fillText(b.text, c, d);
- typeZeroCount++;
- } else if (1 == b.type) {
- a.fillStyle = b.color, a.fillRect(b.x << 1, b.y << 1, b.width << 1, b.height << 1);
- a.strokeStyle = "#000000", a.globalAlpha = .2, a.lineWidth = 2;
- a.strokeRect((b.x << 1) + 1, (b.y << 1) + 1, (b.width << 1) - 2, (b.height << 1) - 2);
- a.globalAlpha = 1;
- typeOneCount++;
- } else if (2 == b.type) {
- a.fillStyle = b.isBad ? "#FF0000" : "#00FF00", a.globalAlpha = .2;
- a.fillRect(b.x << 1, b.y << 1, b.width << 1, b.height << 1);
- a.globalAlpha = 1;
- typeTwoCount++;
- } else if (3 == b.type) {
- var c = b.x << 1,
- d = b.y << 1,
- g = b.width << 1,
- e = b.height << 1;
- a.fillStyle = b.color;
- a.globalAlpha = .2;
- a.fillRect(c, d, g, e);
- a.globalAlpha = .5;
- a.fillStyle = "#000000";
- if (40 > b.width || 40 > b.height) {
- a.font = 30 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 10);
- } else {
- a.font = 60 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 20);
- };
- a.globalAlpha = 1;
- typeThreeCount++;
- } else if (4 == b.type) {
- c = b.x << 1;
- d = b.y << 1;
- g = b.width << 1;
- e = b.height << 1;
- a.fillStyle = b.color;
- a.strokeStyle = b.color;
- a.globalAlpha = 1;
- a.fillRect(c, d, g, e);
- a.globalAlpha = .2;
- a.fillStyle = "#000000";
- a.fillRect(c, d, g, e);
- a.globalAlpha = 1;
- a.fillStyle = b.color;
- var n = 150 > t - b.lastClickAt, l = n ? 8 : 12;
- a.fillRect(c + l, d + l, g - 2 * l, e - 2 * l);
- a.strokeStyle = "#000000";
- a.globalAlpha = .1;
- a.beginPath();
- a.moveTo(c, d);
- a.lineTo(c + l, d + l);
- a.moveTo(c + g, d);
- a.lineTo(c + g - l, d + l);
- a.moveTo(c, d + e);
- a.lineTo(c + l, d + e - l);
- a.moveTo(c + g, d + e);
- a.lineTo(c + g - l, d + e - l);
- a.moveTo(c, d);
- a.rect(c, d, g, e);
- a.rect(c + l, d + l, g - 2 * l, e - 2 * l);
- a.stroke();
- a.fillStyle = "#000000";
- a.globalAlpha = .5;
- if (50 > b.width || 50 > b.height) {
- a.font = 35 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 13);
- } else {
- a.font = 45 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 16);
- }
- n && (a.fillStyle = "#000000", a.globalAlpha = .15, a.fillRect(c + l, d + l, g - 2 * l, e - 2 * l));
- a.globalAlpha = 1;
- typeFourCount++;
- } else 5 == b.type && (ga(!1), a.drawImage(b.canvas, 0, 0, 400, 300, 0, 0, 800, 600, ga(!0)));
- }
- if (r.length == 8 && typeZeroCount == 4 && typeOneCount == 3 && typeTwoCount == 1 && typeThreeCount == 0 && typeFourCount == 0) {
- a.globalAlpha = 1;
- f = "(Or just play cursors.io)", a.font = 15 + "px NovaSquare", a.fillStyle = "#000000";
- a.fillText(f, 400 - a.measureText(f).width / 2, 408);
- }
- a.restore();
- if (!D) {
- a.font = 12 + "px NovaSquare", a.strokeStyle = "#000000", a.fillStyle = "#FFFFFF", a.lineWidth = 2.5;
- f = ja ? "Area too full, not all cursors are shown" : 30 < ia ? "Area too full, drawing is disabled" : "Use shift+click to draw";
- a.globalAlpha = .5, a.strokeText(f, 10, 590), a.globalAlpha = 1;
- a.fillText(f, 10, 590);
- if (aa != 0) {
- f = aa + " players online", b = a.measureText(f).width, a.globalAlpha = .5, a.strokeText(f, 790 - b, 590), a.globalAlpha = 1;
- a.fillText(f, 790 - b, 590);
- };
- if (!movementEnabled) {
- f = "movement disabled";
- a.globalAlpha = .5, a.strokeText(f, 10, 15), a.globalAlpha = 1;
- a.fillText(f, 10, 15);
- f = "press numpad . to enable";
- a.globalAlpha = .5, a.strokeText(f, 10, 30), a.globalAlpha = 1;
- a.fillText(f, 10, 30);
- }
- }
- na();
- if (!H.checked) {
- a.save();
- a.strokeStyle = "#000000";
- a.lineWidth = 1;
- t = +new Date;
- a.beginPath();
- for (f = 0; f < O.length; f++) {
- b = O[f];
- c = 10 - (t - b[4]) / 1E3;
- if (c <= 0) {
- O.splice(f, 1),
- --f;
- } else {
- 1 < c && (c = 1), a.globalAlpha = .3 * c;
- a.moveTo(b[0] - .5, b[1] - .5);
- a.lineTo(b[2] - .5, b[3] - .5);
- }
- }
- a.stroke();
- a.restore();
- }
- a.save();
- //for (var p in F) F.hasOwnProperty(p) && a.drawImage(P, scale(sa(F[p].getX()) - 6), scale(ta(F[p].getY()) - 6), scale(P.width), scale(P.height));
- for (var p in F) {
- F.hasOwnProperty(p) && a.drawImage(P, sa(F[p].getX()) - 6, ta(F[p].getY()) - 6);
- // show ids?
- if (showcursorsid) {
- if(cursorIDPos==2){
- cp=a.measureText(p).width;
- a.globalAlpha = .5; a.strokeText( p, sa(F[p].getX()) - cp + cursorIDX, ta(F[p].getY()) + cursorIDY );
- a.globalAlpha= 1; a.fillText( p, sa(F[p].getX()) - cp + cursorIDX, ta(F[p].getY()) + cursorIDY );
- }
- else{
- a.globalAlpha = .5; a.strokeText( p, sa(F[p].getX()) + cursorIDX, ta(F[p].getY()) + cursorIDY );
- a.globalAlpha= 1; a.fillText( p, sa(F[p].getX()) + cursorIDX, ta(F[p].getY()) + cursorIDY );
- }
- }
- }
- if (showcursorsid) {
- if(cursorIDPos==2){
- cp=a.measureText(ha).width;
- a.globalAlpha = .5; a.strokeText( ha, sa(k) - cp + cursorIDX, ta(q) + cursorIDY ) ;
- a.globalAlpha= 1; a.fillText( ha, sa(k) - cp + cursorIDX, ta(q) + cursorIDY ) ;
- }
- else{
- a.globalAlpha = .5; a.strokeText( ha, sa(k) + cursorIDX, ta(q) + cursorIDY ) ;
- a.globalAlpha= 1; a.fillText( ha, sa(k) + cursorIDX, ta(q) + cursorIDY ) ;
- }
- }
- a.restore();
- oa(!0);
- if (!D) {
- a.font = 15 + "px NovaSquare", a.strokeStyle = "#000000", a.fillStyle = "#FFFFFF", a.lineWidth = 2.5;
- if (message.length>0){
- b = a.measureText(message).width/2;
- a.globalAlpha = .5, a.strokeText(message, 400 - b, 580), a.globalAlpha = 1;
- a.fillText(message, 400 - b, 580);
- }
- for (var i=0; i < messages.length; i++){
- b = a.measureText(messages[i]).width/2;
- a.globalAlpha = .5, a.strokeText(messages[i], 400 - b, 580 - messages.length*15 + i*15 ), a.globalAlpha = 1;
- a.fillText(messages[i], 400 - b, 580 - messages.length*15 + i*15);
- }
- if (showHelp) {
- a.font = 12 + "px NovaSquare";
- f = "How to use (press F4 to hide):", a.globalAlpha = .5, a.strokeText(f, 10, 30), a.globalAlpha = 1, a.fillText(f, 10, 30);
- f = "-> To type: type message and hit enter (shift+enter for new row)", a.globalAlpha = .5, a.strokeText(f, 10, 45), a.globalAlpha = 1, a.fillText(f, 10, 45);
- f = "-> To enable or disable movement: press numpad .", a.globalAlpha = .5, a.strokeText(f, 10, 60), a.globalAlpha = 1, a.fillText(f, 10, 60);
- f = "-> To start/stop drawing circle: press numpad 0", a.globalAlpha = .5, a.strokeText(f, 10, 75), a.globalAlpha = 1, a.fillText(f, 10, 75);
- f = "-> To draw arrows, use the arrow keys", a.globalAlpha = .5, a.strokeText(f, 10, 90), a.globalAlpha = 1, a.fillText(f, 10, 90);
- f = "-> To draw images: press numpad 1 - numpad 9", a.globalAlpha = .5, a.strokeText(f, 10, 105), a.globalAlpha = 1, a.fillText(f, 10, 105);
- f = "-> To make images bigger/smaller use numpad + and -", a.globalAlpha = .5, a.strokeText(f, 10, 120), a.globalAlpha = 1, a.fillText(f, 10, 120);
- f = "-> To reset image size press *", a.globalAlpha = .5, a.strokeText(f, 10, 135), a.globalAlpha = 1, a.fillText(f, 10, 135);
- f = "-> To show/hide cursors ids: press F8", a.globalAlpha = .5, a.strokeText(f, 10, 150), a.globalAlpha = 1, a.fillText(f, 10, 150);
- f = "-> Change ids position: press F9", a.globalAlpha = .5, a.strokeText(f, 10, 165), a.globalAlpha = 1, a.fillText(f, 10, 165);
- }
- }
- }
- a.restore();
- A.requestAnimationFrame(ma)
- }
- function scale(z) {
- return Math.round(z/600*a.canvas.height);
- }
- function na() {
- a.save();
- a.strokeStyle = "#000000";
- t = +new Date;
- for (var f = 0; f < I.length; f++) {
- var b = I[f],
- c = (t - b[2]) / 1E3,
- d = 1 - 2 * c;
- 0 >= d ? (I.splice(f, 1), --f) : (c *= 50, a.beginPath(), a.globalAlpha = .3 * d, a.arc(b[0], b[1], c, 0, 2 * Math.PI, !1), a.stroke());
- }
- a.restore()
- }
- function oa(f) {
- if (D) a.save(), a.globalAlpha = 1, a.drawImage(P, B - 5, C - 5, P.width, P.height);
- else {
- var b = 0,
- c = 0;
- if (v != k || w != q) {
- a.save();
- if (f) {
- a.globalAlpha = .2, a.fillStyle = "#FF0000", a.beginPath();
- a.arc(B + 2, C + 8, 20, 0, 2 * Math.PI, !1);
- a.fill();
- }
- a.globalAlpha = .5;
- a.drawImage(P, B - 5, C - 5, P.width, P.height);
- a.restore();
- } else {
- b = B & 1, c = C & 1;
- }
- a.save();
- if (f) {
- a.globalAlpha = .2, a.fillStyle = "#FFFF00", a.beginPath();
- a.arc((k << 1) + b + 2, (q << 1) + c + 8, 20, 0, 2 * Math.PI, !1);
- a.fill();
- }
- a.globalAlpha = 1;
- a.drawImage(Ia, (k << 1) + b - 5, (q << 1) + c - 5, Ia.width, Ia.height);
- if (!movementEnabled) {
- a.strokeStyle = "#DD4444", a.lineWidth = 1;
- a.beginPath();
- a.arc(serverPosX << 1, serverPosY << 1, 4, 0, 2*Math.PI);
- a.stroke();
- }
- }
- a.restore();
- }
- function ka(a, b) {
- this.oldX = this.newX = a;
- this.oldY = this.newY = b;
- this.time = t
- }
- function pa(a) {
- return a * a * (3 - 2 * a)
- }
- function fa(a, b, c, d) {
- a |= 0;
- b |= 0;
- c |= 0;
- d |= 0;
- if (z(a, b)) return {
- x: a,
- y: b
- };
- if (a == c && b == d) return {
- x: c,
- y: d
- };
- var g = a,
- e = b;
- c = c - a | 0;
- d = d - b | 0;
- var n =
- 0,
- l = 0,
- p = 0,
- k = 0;
- 0 > c ? n = -1 : 0 < c && (n = 1);
- 0 > d ? l = -1 : 0 < d && (l = 1);
- 0 > c ? p = -1 : 0 < c && (p = 1);
- var m = Math.abs(c) | 0,
- h = Math.abs(d) | 0;
- m <= h && (m = Math.abs(d) | 0, h = Math.abs(c) | 0, 0 > d ? k = -1 : 0 < d && (k = 1), p = 0);
- c = m >> 1;
- 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);
- return {
- x: g,
- y: e
- }
- }
- function z(a, b) {
- return 0 > a || 400 <= a || 0 > b || 300 <= b ? !0 : T[a + 400 * b]
- }
- function Ja() {
- for (var a = 0; a < r.length; a++) {
- var b = r[a];
- 5 == b.type && Ka(b)
- }
- }
- function Ka(a) {
- function b(a, b, c) {
- e.push([c, a, b]);
- l[a + 400 * b] = !0;
- g(a, b)
- }
- function c(a, b, c) {
- p.push([c,
- a, b
- ]);
- l[a + 400 * b] = !0
- }
- function d(a, b) {
- return 255 != k[4 * (a + 400 * b) + 3] && !l[a + 400 * b]
- }
- function g(a, b) {
- var c = 4 * (a + 400 * b);
- k[c + 0] = 255;
- k[c + 1] = 153;
- k[c + 2] = 153;
- k[c + 3] = 255
- }
- 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);
- for (m = 0; m < r; ++m) z(e[m][1], e[m][2]) && (p.push(e[m]), e.splice(m, 1), --m, --r);
- for (r = 0; 50 > r && 0 != e.length; ++r) {
- for (var h = Number.POSITIVE_INFINITY, q = [e[0]], m = 1; m < e.length; ++m) {
- var x = e[m][0];
- .01 > Math.abs(x - h) ? q.push(e[m]) : x < h && (h = x, q = [e[m]])
- }
- for (m = 0; m < q.length; ++m) {
- var x = q[m][0],
- h = q[m][1],
- s = q[m][2],
- qa = e.indexOf(q[m]); - 1 != qa && e.splice(qa, 1);
- 0 < h && d(h - 1, s) && (z(h - 1, s) ? c(h - 1, s, x + 1) : b(h - 1, s, x + 1));
- 0 < s && d(h, s - 1) && (z(h, s - 1) ? c(h, s - 1, x + 1) : b(h, s - 1, x + 1));
- 400 > h + 1 && d(h + 1, s) && (z(h + 1, s) ? c(h + 1, s, x + 1) : b(h + 1, s, x + 1));
- 300 > s + 1 && d(h, s + 1) && (z(h, s + 1) ? c(h, s + 1, x + 1) : b(h, s + 1, x + 1));
- 0 < h && 0 < s && d(h - 1, s - 1) && (z(h - 1, s - 1) ? c(h - 1, s - 1, x + Math.SQRT2) : b(h - 1, s - 1, x + Math.SQRT2));
- 0 < h && 300 > s + 1 && d(h - 1, s + 1) && (z(h - 1, s + 1) ? c(h - 1, s + 1, x + Math.SQRT2) :
- b(h - 1, s + 1, x + Math.SQRT2));
- 400 > h + 1 && 0 < s && d(h + 1, s - 1) && (z(h + 1, s - 1) ? c(h + 1, s - 1, x + Math.SQRT2) : b(h + 1, s - 1, x + Math.SQRT2));
- 400 > h + 1 && 300 > s + 1 && d(h + 1, s + 1) && (z(h + 1, s + 1) ? c(h + 1, s + 1, x + Math.SQRT2) : b(h + 1, s + 1, x + Math.SQRT2))
- }
- }
- a.ctx.putImageData(a.img, 0, 0)
- }
- var y, a, ia = 0,
- Rat = A.devicePixelRatio;
- cp = 0,
- v = 0,
- w = 0,
- B = 0,
- C = 0,
- k = 0,
- q = 0,
- J = -1,
- K = -1,
- M = null,
- H = null,
- P = new Image;
- P.src = "img/cursor.png";
- var Ia = P,
- D = -1 != A.location.search.indexOf("editor"),
- I = [],
- O = [],
- t = 0,
- ca = 0,
- u = null,
- ha = -1,
- F = {},
- aa = 0,
- ja = !1,
- Y = !1,
- R = 0,
- S = 0,
- da = 0,
- X = !1,
- L = !D && !0,
- T = new Uint8Array(12E4),
- r = [],
- N = [];
- Array.prototype.remove =
- function(a) {
- a = this.indexOf(a);
- return -1 != a ? (this.splice(a, 1), !0) : !1
- };
- var G = 0;
- ka.prototype = {
- oldX: 0,
- oldY: 0,
- newX: 0,
- newY: 0,
- time: 0,
- getX: function() {
- var a = this.newX - this.oldX,
- b = (t - this.time) / 100,
- b = pa(0 >= b ? 0 : 1 <= b ? 1 : b);
- return this.oldX + b * a
- },
- getY: function() {
- var a = this.newY - this.oldY,
- b = (t - this.time) / 100,
- b = pa(0 >= b ? 0 : 1 <= b ? 1 : b);
- return this.oldY + b * a
- }
- };
- var za = new Uint8Array(12E4);
- Array.prototype.remove = function(a) {
- a = this.indexOf(a);
- return -1 != a ? (this.splice(a, 1), !0) : !1
- };
- var imgSc = 1.0;
- var message = new String();
- var messages = new Array();
- function drawM(m,d,x,y){
- setTimeout(function () {
- drawWord(m, x, y );
- }, d);
- }
- function handleKeypress(e) {
- if ((e.which >= 39 && e.which <= 41) ||
- e.which == 43 || e.which == 92 ||
- (e.which >= 44 && e.which <= 47) ||
- (e.which >= 48 && e.which <= 59) ||
- (e.which >= 65 && e.which <= 90) ||
- (e.which >= 95 && e.which <= 122) ||
- (e.which >= 32 && e.which <= 35) ||
- e.which == 61 || e.which == 63 ) {
- e.preventDefault();
- message = message.concat(String.fromCharCode(e.which));
- return;
- }
- switch(e.which) {
- case 13:
- e.preventDefault();
- if (e.shiftKey) { //add new row
- messages.push(message);
- message = "";
- }
- else { //print all rows
- messages.push(message);
- for(var i=0; i < messages.length; i++){
- if (i>0) var del = messages[i-1].length*i*50;
- else var del=0;
- drawM(messages[i],del,k,q+i*kerning*fontSize);//not ideal printing, but better than printing as columns
- }
- message = "";
- messages = [];
- }
- break;
- default:
- return;
- }
- }
- function handleKeydown(e) {
- if (e.keyCode == 8 || e.keyCode == 9 || (e.keyCode >=37 && e.keyCode <= 40)
- || (e.keyCode >= 96 && e.keyCode <= 122)
- //|| e.keyCode == 12 || e.keyCode == 45 || (e.keyCode >= 33 && e.keyCode <= 36)
- ) {
- e.preventDefault();
- }
- if (e.keyCode == 8) {
- if (message.length > 0) {
- message = message.substring(0, message.length - 1);
- }
- else if (messages.length > 0) {
- message = messages.pop();
- }
- }
- switch(e.keyCode) {
- case 37: // left arrow
- imgSc=imageScale; imageScale=1.0;
- drawImage(0, posX, posY); // draw arrow pointing left
- imageScale=imgSc;
- break;
- case 38: // up arrow
- imgSc=imageScale; imageScale=1.0;
- drawImage(1, posX, posY); // draw arrow pointing up
- imageScale=imgSc;
- break;
- case 39: // right arrow
- imgSc=imageScale; imageScale=1.0;
- drawImage(2, posX, posY); // draw arrow right
- imageScale=imgSc;
- break;
- case 40: // down arrow
- imgSc=imageScale; imageScale=1.0;
- drawImage(3, posX, posY); // draw arrow down
- imageScale=imgSc;
- break;
- case 106: //numpad *
- imageScale = 1.0; // reset drawings size
- break;
- case 107: //numpad +
- imageScale += 0.1; // make drawings bigger
- break;
- case 109: //numpad -
- if(imageScale > 0.29)
- imageScale -= 0.1; // make drawings smaller
- break;
- case 46: case 110: // numpad .
- movementEnabled = !movementEnabled; // disable/enable movement by click
- break;
- case 45: case 96: // numpad 0
- auraEnabled = !auraEnabled; // start/stop drawing circle
- break;
- case 97: //case 35: // numpad 1
- drawImage(4, posX, posY); // star
- break;
- case 98: //case 40: // numpad 2
- drawImage(5, posX, posY); // reversed star
- break;
- case 99: //case 34: // numpad 3
- drawImage(6, posX, posY); // tictactoe
- break;
- case 100: //case 37: // numpad 4
- drawImage(7, posX, posY); // cannon - pentashot
- break;
- case 101: //case 12: // numpad 5
- drawImage(8, posX, posY); // triforce
- break;
- case 102: //case 39: // numpad 6
- drawImage(9, posX,posY); // heart
- break;
- case 103: //case 36: // numpad 7
- imageScale/=2.8;
- drawImage(10, posX, posY); // dickboob
- imageScale*=2.8;
- break;
- case 104: //case 38: // numpad 8
- break;
- case 105: //case 33: // numpad 9
- drawWord(" trololo", posX, posY);
- break;
- case 115: // F4
- showHelp = !showHelp; // show/hide help
- break;
- case 119: // F8
- showcursorsid = !showcursorsid; // show/hide cursors ids
- break;
- case 120: // F9
- cursorIDPos+=1;
- changeCursorIDpos(cursorIDPos);
- break;
- default:
- return;
- }
- }
- var cursorIDPos=1;
- var cursorIDX=-2;
- var cursorIDY=24;
- function changeCursorIDpos(c) {
- switch(c){
- case 1: cursorIDX=-2; cursorIDY=24; break;
- case 2: cursorIDX=-3; cursorIDY=14; break;
- case 3: cursorIDX=-2; cursorIDY=-3; break;
- case 4: cursorIDX=10; cursorIDY=14; break;
- default: cursorIDX=-2; cursorIDY=24; cursorIDPos=1;
- }
- }
- function drawAura(x, y) {
- var dt = 360/(1000/40)/2;
- if (u != null && u.readyState == WebSocket.OPEN) {
- var g = new ArrayBuffer(9),
- e = new DataView(g);
- e.setUint8(0, 3);
- e.setUint16(1, x+Math.sin(degToRad(auraTime+dt))*auraRadius, !0);
- e.setUint16(3, y+Math.cos(degToRad(auraTime+dt))*auraRadius, !0);
- e.setUint16(5, x+Math.sin(degToRad(auraTime))*auraRadius, !0);
- e.setUint16(7, y+Math.cos(degToRad(auraTime))*auraRadius, !0);
- u.Send(g)
- }
- auraTime += dt;
- }
- function drawImage(ind, x, y) {
- if (!imgData[ind]) return;
- for (var i = 0; i < imgData[ind].length; i++) {
- var g = new ArrayBuffer(9),
- e = new DataView(g);
- e.setUint8(0, 3);
- e.setUint16(1, x+imgData[ind][i][1]*imageScale, !0);
- e.setUint16(3, y+imgData[ind][i][0]*imageScale, !0);
- e.setUint16(5, x+imgData[ind][i][3]*imageScale, !0);
- e.setUint16(7, y+imgData[ind][i][2]*imageScale, !0);
- u.Send(g);
- }
- }
- function degToRad(deg) {
- return deg * (Math.PI / 180);
- }
- function radToDeg(rad) {
- return rad * (180 / Math.PI);
- }
- function drawLetter(a, x, y) {
- var letter;
- var capital = 1;
- var shift = 0;
- if (alphabet.hasOwnProperty(a)) {
- letter = alphabet[a];
- } else if (a + 32 >= 97 && a + 32 <= 122) {
- capital = 1.5;
- shift = -2;
- letter = alphabet[a + 32];
- } else return;
- for (var i = 0; i < letter.length; i++) {
- var g = new ArrayBuffer(9),
- e = new DataView(g);
- e.setUint8(0, 3);
- e.setUint16(1, x+letter[i][1]*fontSize, !0);
- e.setUint16(3, y+letter[i][0]*fontSize*capital + shift, !0);
- e.setUint16(5, x+letter[i][3]*fontSize, !0);
- e.setUint16(7, y+letter[i][2]*fontSize*capital + shift, !0);
- u.Send(g);
- }
- }
- function drawWord(s, x, y) {
- if (s == null) return;
- setTimeout(function () {
- if (!z(Math.round(x+fontSize*kerning), Math.round(y))) {
- drawLetter(s.charCodeAt(0), x, y);
- if (s.length > 0) drawWord(s.substring(1, s.length), x+fontSize*kerning, y);
- }
- }, 1);
- }
- WebSocket.prototype.Send = function(frm) {
- if (u != null && u.readyState == WebSocket.OPEN) {
- if (Throttler.check(frm)) this.send(frm);
- }
- };
- var Throttler = {
- rate: 3,
- per: 150,
- storage: [],
- allowed: 3,
- lastFrameAt: 0,
- sendOut: function() {
- if (this.storage.length != 0) {
- u.Send(this.storage.shift());
- }
- },
- check: function(frm) {
- var now = Date.now();
- var allowance = this.allowed;
- var timeDiff = now - this.lastFrameAt;
- this.lastFrameAt = now;
- allowance += timeDiff*(this.rate/this.per);
- if (allowance > this.rate) allowance = this.rate;
- this.allowed = allowance;
- if (this.allowed < 1) {
- if (this.storage.length < 400) {
- var dv = new DataView(frm);
- if (dv.getUint8(0) == 3) this.storage.push(frm);
- }
- return false;
- }
- this.allowed -= 1;
- return true;
- }
- };
- function connect() {
- if (m28n.findServerPreference) {
- if (!u) m28n.findServerPreference("cursors", function(e,a){
- if (e||0 == a.length) {
- setTimeout(self.connect, 1E3);
- } else {
- var ipv4 = a[0].ipv4;
- var ipv6 = a[0].ipv6;
- var port = a[0].port;
- port = 2828;
- u = new WebSocket("ws://" + (ipv4 || "[" + ipv6 + "]") + ":" + port);
- setHandlers();
- }
- });
- } else {
- if (!u) u = new WebSocket("ws://s1.cursors.io:443/");
- setHandlers();
- }
- function setHandlers() {
- u.binaryType = "arraybuffer";
- u.onopen = Aa, u.onmessage = Ga, u.onclose = Ba, u.onerror = Ca;
- }
- }
- var messageDisplay;
- function doit() {
- document.body.innerHTML += '<div id="messageDisplay"></div>';
- messageDisplay = document.getElementById("messageDisplay");
- y = E.getElementById("canvas");
- a = y.getContext("2d");
- try {
- A.top.location.origin != A.location.origin && ba()
- } catch (f) {
- ba()
- }
- y.width = 800 * Rat;
- y.height = 600 * Rat;
- a.scale(Rat, Rat);
- y.onmousemove = ua;
- y.onmousedown = va;
- y.onmouseup = xa;
- M = E.getElementById("noCursorLock");
- H = E.getElementById("noDrawings");
- null != localStorage && (Ma(), M.checked = "1" == A.localStorage.getItem("noCursorLock") ? !0 : !1, H.checked = "1" == A.localStorage.getItem("noDrawings") ? !0 : !1);
- A.onbeforeunload = ya;
- y.requestPointerLock = y.requestPointerLock || y.mozRequestPointerLock || y.webkitRequestPointerLock;
- y.style.cursor = "none";
- D || connect();
- setInterval(Q, 20);
- //setInterval(Ja, 40);
- setInterval(Au, 50);
- A.requestAnimationFrame(ma)
- document.onkeypress = handleKeypress;
- document.onkeydown = handleKeydown;
- }
- doit();
- /*
- ___ _ _ _ __ ___ ___ _ __ ___ _ ___
- / __| | | | `__/ __|/ _ \| `__/ __| | |/ _ \
- | (__| |_| | | \__ \ (_) | | \__ \_| | (_) |
- \___|\__,_|_| |___/\___/|_| |___(_)_|\___/
- script for texting and drawing in CURSORS.IO
- How to use:
- -> To type: type message and hit enter; shift+enter for new row;
- -> To move your cursor only when clicking: press numpad .
- Use it to pass red walls levels ;)
- -> To move your cursor normally: press numpad . again
- -> To draw a circle: press numpad 0
- -> To stop drawing a circle: press numpad 0 again
- -> To draw arrows, use the arrow keys
- -> To draw different images: press numpad 1 - numpad 9 keys
- -> To make drawings bigger/smaller use numpad + and -
- -> Reset drawing size with numpad *
- -> To show/hide cursors ids: press F8
- -> Change ids position with: F9
- -> To show this help: press F4
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement