Guest User

agrario v531 clean

a guest
Jun 7th, 2015
1,322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function (MyWindow, MyJQuery) {
  2.     function GameInit() {
  3.         IsLoaded = !0;
  4.         UpdateRegionGui();
  5.         setInterval(UpdateRegionGui, 18E4);
  6.         Canvas2 = Canvas1 = document.getElementById("canvas");
  7.         Canvas2dContext = Canvas2.getContext("2d");
  8.         Canvas2.onmousedown = function (a) {
  9.             if (IsMobile) {
  10.                 var b = a.clientX - (5 + WindowWidth / 5 / 2),
  11.                     c = a.clientY - (5 + WindowWidth / 5 / 2);
  12.                 if (Math.sqrt(b * b + c * c) <= WindowWidth / 5 / 2) {
  13.                     SendDesiredWorldCoords();
  14.                     SendSinglePacket(17);
  15.                     return;
  16.                 }
  17.             }
  18.             MouseX = a.clientX;
  19.             MouseY = a.clientY;
  20.             UpdateDesiredWorldCoordinates();
  21.             SendDesiredWorldCoords()
  22.         };
  23.         Canvas2.onmousemove = function (a) {
  24.             MouseX = a.clientX;
  25.             MouseY = a.clientY;
  26.             UpdateDesiredWorldCoordinates()
  27.         };
  28.         Canvas2.onmouseup = function (a) {
  29.         };
  30.         /firefox/i.test(navigator.userAgent) ? document.addEventListener("DOMMouseScroll", OnMouseWheel, !1) : document.body.onmousewheel = OnMouseWheel;
  31.         var a = !1,
  32.             b = !1,
  33.             c = !1;
  34.         MyWindow.onkeydown = function (d) {
  35.             32 != d.keyCode || a || (SendDesiredWorldCoords(), SendSinglePacket(17), a = !0); // Space
  36.             81 != d.keyCode || b || (SendSinglePacket(18), b = !0); // Q
  37.             87 != d.keyCode || c || (SendDesiredWorldCoords(), SendSinglePacket(21), c = !0); // W
  38.             27 == d.keyCode && Aa(!0); // Escape
  39.         };
  40.         MyWindow.onkeyup = function (d) {
  41.             32 == d.keyCode && (a = !1); // Space
  42.             87 == d.keyCode && (c = !1); // W
  43.             81 == d.keyCode && b && (SendSinglePacket(19), b = !1); // Q
  44.         };
  45.         MyWindow.onblur = function () {
  46.             SendSinglePacket(19);
  47.             c = b = a = !1
  48.         };
  49.         MyWindow.onresize = UpdateWindowSize;
  50.         UpdateWindowSize();
  51.         MyWindow.requestAnimationFrame ? MyWindow.requestAnimationFrame(PresentLoop) : setInterval(Present, 1E3 / 60);
  52.         setInterval(SendDesiredWorldCoords, 40);
  53.         ServerRegion && MyJQuery("#region").val(ServerRegion);
  54.         Da();
  55.         U(MyJQuery("#region").val());
  56.         null == MySocket && ServerRegion && WaitingForConnection();
  57.         MyJQuery("#overlays").show()
  58.     }
  59.  
  60.     function OnMouseWheel(a) {
  61.         Zoom *= Math.pow(.9, a.wheelDelta / -120 || a.detail || 0);
  62.         1 > Zoom && (Zoom = 1);
  63.         Zoom > 4 / VisionSpread && (Zoom = 4 / VisionSpread)
  64.     }
  65.  
  66.     function InsertEntitiesIntoQuadTree() {
  67.         if (.35 > VisionSpread) QuadTreeInterface = null;
  68.         else {
  69.             for (var a = Number.POSITIVE_INFINITY, b = Number.POSITIVE_INFINITY, c = Number.NEGATIVE_INFINITY, d = Number.NEGATIVE_INFINITY, e = 0, q = 0; q < EntityList.length; q++) EntityList[q].shouldRender() && (e = Math.max(EntityList[q].size, e), a = Math.min(EntityList[q].x, a), b = Math.min(EntityList[q].y, b), c = Math.max(EntityList[q].x, c), d = Math.max(EntityList[q].y, d));
  70.             QuadTreeInterface = QUAD.init({
  71.                 minX: a - (e + 100),
  72.                 minY: b - (e + 100),
  73.                 maxX: c + (e + 100),
  74.                 maxY: d + (e + 100)
  75.             });
  76.             for (q = 0; q < EntityList.length; q++)
  77.                 if (a = EntityList[q], a.shouldRender())
  78.                     for (b = 0; b < a.points.length; ++b) QuadTreeInterface.insert(a.points[b])
  79.         }
  80.     }
  81.  
  82.     function UpdateDesiredWorldCoordinates() {
  83.         DesiredWorldX = (MouseX - WindowWidth / 2) / VisionSpread + LocalX;
  84.         DesiredWorldY = (MouseY - WindowHeight / 2) / VisionSpread + LocalY;
  85.     }
  86.  
  87.     function UpdateRegionGui() {
  88.         null == Y && (Y = {}, MyJQuery("#region").children().each(function () {
  89.             var a = MyJQuery(this),
  90.                 b = a.val();
  91.             b && (Y[b] = a.text())
  92.         }));
  93.         MyJQuery.get(HttpProtocol + "//m.agar.io/info", function (a) {
  94.             var b = {},
  95.                 c;
  96.             for (c in a.regions) {
  97.                 var d = c.split(":")[0];
  98.                 b[d] = b[d] || 0;
  99.                 b[d] += a.regions[c].numPlayers
  100.             }
  101.             for (c in b) MyJQuery('#region option[value="' + c + '"]').text(Y[c] + " (" + b[c] + " players)")
  102.         }, "json")
  103.     }
  104.  
  105.     function Ea() {
  106.         MyJQuery("#adsBottom").hide();
  107.         MyJQuery("#overlays").hide();
  108.         Da()
  109.     }
  110.  
  111.     function U(a) {
  112.         a && a != ServerRegion && (MyJQuery("#region").val() != a && MyJQuery("#region").val(a),
  113.             ServerRegion = MyWindow.localStorage.location = a, MyJQuery(".region-message").hide(), MyJQuery(".region-message." + a).show(), MyJQuery(".btn-needs-server").prop("disabled", !1), IsLoaded && WaitingForConnection())
  114.     }
  115.  
  116.     function Aa(a) {
  117.         LocalName = null;
  118.         MyJQuery("#overlays").fadeIn(a ? 200 : 3E3);
  119.         a || MyJQuery("#adsBottom").fadeIn(3E3)
  120.     }
  121.  
  122.     function Da() {
  123.         MyJQuery("#region").val() ? MyWindow.localStorage.location = MyJQuery("#region").val() : MyWindow.localStorage.location && MyJQuery("#region").val(MyWindow.localStorage.location);
  124.         MyJQuery("#region").val() ? MyJQuery("#locationKnown").append(MyJQuery("#region")) : MyJQuery("#locationUnknown").append(MyJQuery("#region"))
  125.     }
  126.  
  127.     function FindServer() {
  128.         console.log("Find " +
  129.         ServerRegion + GameMode);
  130.         MyJQuery.ajax(HttpProtocol + "//m.agar.io/", {
  131.             error: function () {
  132.                 setTimeout(FindServer, 1E3)
  133.             },
  134.             success: function (a) {
  135.                 a = a.split("\n");
  136.                 "45.79.222.79:443" == a[0] ? FindServer() : Connect("ws://" + a[0])
  137.             },
  138.             dataType: "text",
  139.             method: "POST",
  140.             cache: !1,
  141.             crossDomain: !0,
  142.             data: ServerRegion + GameMode || "?"
  143.         })
  144.     }
  145.  
  146.     function WaitingForConnection() {
  147.         IsLoaded && ServerRegion && (MyJQuery("#connecting").show(), FindServer())
  148.     }
  149.  
  150.     function Connect(__Ip) {
  151.         if (MySocket) {
  152.             MySocket.onopen = null;
  153.             MySocket.onmessage = null;
  154.             MySocket.onclose = null;
  155.             try {
  156.                 MySocket.close()
  157.             } catch (b) {
  158.             }
  159.             MySocket = null
  160.         }
  161.         var c = MyWindow.location.search.slice(1);
  162.         /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+$/.test(c) && (__Ip = "ws://" + c);
  163.         IsHttps && (__Ip = __Ip.split(":"), __Ip = __Ip[0] + "s://ip-" +
  164.         __Ip[1].replace(/\./g, "-").replace(/\//g, "") + ".tech.agar.io:" + (+__Ip[2] + 2E3));
  165.         E = [];
  166.         OwnEntities = [];
  167.         EntityArray = {};
  168.         EntityList = [];
  169.         DestroyedEntityList = [];
  170.         ScoreBoardPlayerArray = [];
  171.         TempCanvas = w = null;
  172.         H = 0;
  173.         console.log("Connecting to " + __Ip);
  174.         MySocket = new WebSocket(__Ip, IsHttps ? ["binary", "base64"] : []);
  175.         MySocket.binaryType = "arraybuffer";
  176.         MySocket.onopen = OnSocketOpen;
  177.         MySocket.onmessage = OnSocketMessage;
  178.         MySocket.onclose = OnSocketClose;
  179.         MySocket.onerror = function () {
  180.             console.log("socket error");
  181.         }
  182.     }
  183.  
  184.     function OnSocketOpen(a) {
  185.         TimeOutForReconnect = 500;
  186.         MyJQuery("#connecting").hide();
  187.         console.log("socket open");
  188.         a = new ArrayBuffer(5);
  189.         var b = new DataView(a);
  190.         b.setUint8(0, 254);
  191.         b.setUint32(1, 4, !0);
  192.         MySocket.send(a);
  193.         a = new ArrayBuffer(5);
  194.         b = new DataView(a);
  195.         b.setUint8(0, 255);
  196.         b.setUint32(1, 673720360, !0);
  197.         MySocket.send(a);
  198.         SendName();
  199.     }
  200.  
  201.     function OnSocketClose(a) {
  202.         console.log("socket close");
  203.         setTimeout(WaitingForConnection, TimeOutForReconnect);
  204.         TimeOutForReconnect *= 1.5
  205.     }
  206.  
  207.     function OnSocketMessage(a) {
  208.         function ReceiveString() {
  209.             for (var a = ""; ;) {
  210.                 var b = RecStream.getUint16(RecStreamIndex, !0);
  211.                 RecStreamIndex += 2;
  212.                 if (0 == b) break;
  213.                 a += String.fromCharCode(b)
  214.             }
  215.             return a
  216.         }
  217.  
  218.         var RecStreamIndex = 0,
  219.             RecStream = new DataView(a.data);
  220.         240 == RecStream.getUint8(RecStreamIndex) && (RecStreamIndex += 5);
  221.         switch (RecStream.getUint8(RecStreamIndex++)) {
  222.             case 16:
  223.                 UpdateEntities(RecStream, RecStreamIndex);
  224.                 break;
  225.             case 17:
  226.                 CameraX = RecStream.getFloat32(RecStreamIndex, !0);
  227.                 RecStreamIndex += 4;
  228.                 CameraY = RecStream.getFloat32(RecStreamIndex, !0);
  229.                 RecStreamIndex += 4;
  230.                 CameraSpread = RecStream.getFloat32(RecStreamIndex, !0);
  231.                 RecStreamIndex += 4;
  232.                 break;
  233.             case 20:
  234.                 OwnEntities = [];
  235.                 E = [];
  236.                 break;
  237.             case 21:
  238.                 oa = RecStream.getInt16(RecStreamIndex, !0);
  239.                 RecStreamIndex += 2;
  240.                 pa = RecStream.getInt16(RecStreamIndex, !0);
  241.                 RecStreamIndex += 2;
  242.                 qa || (qa = !0, $ = oa, aa = pa);
  243.                 break;
  244.             case 32:
  245.                 E.push(RecStream.getUint32(RecStreamIndex, !0));
  246.                 RecStreamIndex += 4;
  247.                 break;
  248.             case 49:
  249.                 if (null != w) break;
  250.                 a = RecStream.getUint32(RecStreamIndex, !0);
  251.                 RecStreamIndex += 4;
  252.                 ScoreBoardPlayerArray = [];
  253.                 for (var e = 0; e < a; ++e) {
  254.                     var q = RecStream.getUint32(RecStreamIndex, !0),
  255.                         c = RecStreamIndex + 4;
  256.                     ScoreBoardPlayerArray.push({
  257.                         id: q,
  258.                         name: ReceiveString()
  259.                     })
  260.                 }
  261.                 DrawScoreBoard();
  262.                 break;
  263.             case 50:
  264.                 w = [];
  265.                 a = RecStream.getUint32(RecStreamIndex, !0);
  266.                 RecStreamIndex += 4;
  267.                 for (e = 0; e < a; ++e) w.push(RecStream.getFloat32(RecStreamIndex, !0)), RecStreamIndex += 4;
  268.                 DrawScoreBoard();
  269.                 break;
  270.             case 64:
  271.                 ba = RecStream.getFloat64(RecStreamIndex, !0), RecStreamIndex += 8, ca = RecStream.getFloat64(RecStreamIndex, !0), RecStreamIndex += 8, da = RecStream.getFloat64(RecStreamIndex, !0), RecStreamIndex += 8, ea = RecStream.getFloat64(RecStreamIndex, !0), RecStreamIndex += 8, CameraX = (da + ba) / 2, CameraY = (ea + ca) / 2, CameraSpread = 1, 0 == OwnEntities.length && (LocalX = CameraX, LocalY = CameraY, VisionSpread = CameraSpread)
  272.         }
  273.     }
  274.  
  275.     function UpdateEntities(RecStream, RecStreamIndex) {
  276.         CurTimeStamp = +new Date;
  277.         var RandNum = Math.random();
  278.         ra = !1;
  279.         var d = RecStream.getUint16(RecStreamIndex, !0);
  280.         RecStreamIndex += 2;
  281.         for (var e = 0; e < d; ++e) {
  282.             var q = EntityArray[RecStream.getUint32(RecStreamIndex, !0)],
  283.                 f = EntityArray[RecStream.getUint32(RecStreamIndex + 4, !0)];
  284.             RecStreamIndex += 8;
  285.             q && f && (f.destroy(), f.ox = f.x, f.oy = f.y, f.oSize = f.size, f.nx = q.x, f.ny = q.y, f.nSize = f.size, f.updateTime = CurTimeStamp)
  286.         }
  287.         for (e = 0; ;) {
  288.             d = RecStream.getUint32(RecStreamIndex, !0);
  289.             RecStreamIndex += 4;
  290.             if (0 == d) break;
  291.             ++e;
  292.             var g, q = RecStream.getInt16(RecStreamIndex, !0);
  293.             RecStreamIndex += 2;
  294.             f = RecStream.getInt16(RecStreamIndex, !0);
  295.             RecStreamIndex += 2;
  296.             g = RecStream.getInt16(RecStreamIndex, !0);
  297.             RecStreamIndex += 2;
  298.             for (var h = RecStream.getUint8(RecStreamIndex++), m = RecStream.getUint8(RecStreamIndex++), p = RecStream.getUint8(RecStreamIndex++), h = (h << 16 | m << 8 | p).toString(16); 6 > h.length;) h = "0" + h;
  299.             var h = "#" + h,
  300.                 k = RecStream.getUint8(RecStreamIndex++),
  301.                 m = !!(k & 1),
  302.                 p = !!(k & 16);
  303.             k & 2 && (RecStreamIndex += 4);
  304.             k & 4 && (RecStreamIndex += 8);
  305.             k & 8 && (RecStreamIndex += 16);
  306.             for (var n, k = ""; ;) {
  307.                 n = RecStream.getUint16(RecStreamIndex, !0);
  308.                 RecStreamIndex += 2;
  309.                 if (0 == n) break;
  310.                 k += String.fromCharCode(n)
  311.             }
  312.             n = k;
  313.             k = null;
  314.             EntityArray.hasOwnProperty(d) ? (k = EntityArray[d], k.updatePos(), k.ox = k.x, k.oy = k.y, k.oSize = k.size, k.color = h) : (k = new Entity(d, q, f, g, h, n), k.pX = q, k.pY = f);
  315.             k.isVirus = m;
  316.             k.isAgitated = p;
  317.             k.nx = q;
  318.             k.ny = f;
  319.             k.nSize = g;
  320.             k.updateCode = RandNum;
  321.             k.updateTime = CurTimeStamp;
  322.             n && k.setName(n);
  323.             -1 != E.indexOf(d) && -1 == OwnEntities.indexOf(k) && (document.getElementById("overlays").style.display = "none", OwnEntities.push(k), 1 == OwnEntities.length && (LocalX = k.x, LocalY = k.y))
  324.         }
  325.         RandNum = RecStream.getUint32(RecStreamIndex, !0);
  326.         RecStreamIndex += 4;
  327.         for (e = 0; e < RandNum; e++) d = RecStream.getUint32(RecStreamIndex, !0), RecStreamIndex += 4, k = EntityArray[d], null != k && k.destroy();
  328.         ra && 0 == OwnEntities.length && Aa(!1)
  329.     }
  330.  
  331.     function SendDesiredWorldCoords() {
  332.         if (IsSocketReady()) {
  333.             var a = MouseX - WindowWidth / 2,
  334.                 b = MouseY - WindowHeight / 2;
  335.             64 > a * a + b * b || Ka == DesiredWorldX && La == DesiredWorldY || (Ka = DesiredWorldX, La = DesiredWorldY, a = new ArrayBuffer(21), b = new DataView(a), b.setUint8(0, 16), b.setFloat64(1, DesiredWorldX, !0), b.setFloat64(9, DesiredWorldY, !0), b.setUint32(17, 0, !0), MySocket.send(a))
  336.         }
  337.     }
  338.  
  339.     function SendName() {
  340.         if (IsSocketReady() && null != LocalName) {
  341.             var a = new ArrayBuffer(1 + 2 * LocalName.length),
  342.                 b = new DataView(a);
  343.             b.setUint8(0, 0);
  344.             for (var c = 0; c < LocalName.length; ++c) b.setUint16(1 +
  345.             2 * c, LocalName.charCodeAt(c), !0);
  346.             MySocket.send(a)
  347.         }
  348.     }
  349.  
  350.     function IsSocketReady() {
  351.         return null != MySocket && MySocket.readyState == MySocket.OPEN
  352.     }
  353.  
  354.     function SendSinglePacket(a) {
  355.         if (IsSocketReady()) {
  356.             var b = new ArrayBuffer(1);
  357.             (new DataView(b)).setUint8(0, a);
  358.             MySocket.send(b)
  359.         }
  360.     }
  361.  
  362.     function PresentLoop() {
  363.         Present();
  364.         MyWindow.requestAnimationFrame(PresentLoop)
  365.     }
  366.  
  367.     function UpdateWindowSize() {
  368.         WindowWidth = MyWindow.innerWidth;
  369.         WindowHeight = MyWindow.innerHeight;
  370.         Canvas1.width = Canvas2.width = WindowWidth;
  371.         Canvas1.height = Canvas2.height = WindowHeight;
  372.         Present();
  373.     }
  374.  
  375.     function GetFOV() {
  376.         var Temp;
  377.         Temp = 1 * Math.max(WindowHeight / 1080, WindowWidth / 1920);
  378.         return Temp *= Zoom;
  379.     }
  380.  
  381.     function UpdateVisionSpread() {
  382.         if (0 != OwnEntities.length) {
  383.             for (var a = 0, b = 0; b < OwnEntities.length; b++) a += OwnEntities[b].size;
  384.             a = Math.pow(Math.min(64 / a, 1), .4) * GetFOV();
  385.             VisionSpread = (9 * VisionSpread + a) / 10
  386.         }
  387.     }
  388.  
  389.     function Present() {
  390.         var a, b, c = +new Date;
  391.         ++Wa;
  392.         CurTimeStamp = +new Date;
  393.         if (0 < OwnEntities.length) {
  394.             UpdateVisionSpread();
  395.             for (var d = a = b = 0; d < OwnEntities.length; d++) OwnEntities[d].updatePos(), b += OwnEntities[d].x / OwnEntities.length, a += OwnEntities[d].y / OwnEntities.length;
  396.             CameraX = b;
  397.             CameraY = a;
  398.             CameraSpread = VisionSpread;
  399.             LocalX = (LocalX + b) / 2;
  400.             LocalY = (LocalY + a) / 2
  401.         } else LocalX = (29 * LocalX + CameraX) / 30, LocalY = (29 * LocalY + CameraY) / 30, VisionSpread = (9 * VisionSpread + CameraSpread * GetFOV()) / 10;
  402.         InsertEntitiesIntoQuadTree();
  403.         UpdateDesiredWorldCoordinates();
  404.         IsAcid || Canvas2dContext.clearRect(0, 0, WindowWidth, WindowHeight);
  405.         if (IsAcid) Canvas2dContext.fillStyle = UseDarkTheme ? "#111111" : "#F2FBFF", Canvas2dContext.globalAlpha = .05, Canvas2dContext.fillRect(0, 0, WindowWidth, WindowHeight), Canvas2dContext.globalAlpha = 1;
  406.         else {
  407.             Canvas2dContext.fillStyle = UseDarkTheme ? "#111111" : "#F2FBFF";
  408.             Canvas2dContext.fillRect(0, 0, WindowWidth, WindowHeight);
  409.             Canvas2dContext.save();
  410.             Canvas2dContext.strokeStyle = UseDarkTheme ? "#AAAAAA" : "#000000";
  411.             Canvas2dContext.globalAlpha = .2;
  412.             Canvas2dContext.scale(VisionSpread, VisionSpread);
  413.             b = WindowWidth / VisionSpread;
  414.             a = WindowHeight / VisionSpread;
  415.             for (d = -.5 + (-LocalX + b / 2) % 50; d < b; d += 50) Canvas2dContext.beginPath(), Canvas2dContext.moveTo(d, 0), Canvas2dContext.lineTo(d, a), Canvas2dContext.stroke();
  416.             for (d = -.5 + (-LocalY + a / 2) % 50; d < a; d += 50) Canvas2dContext.beginPath(), Canvas2dContext.moveTo(0, d), Canvas2dContext.lineTo(b, d), Canvas2dContext.stroke();
  417.             Canvas2dContext.restore()
  418.         }
  419.         EntityList.sort(function (a, b) {
  420.             return a.size == b.size ? a.id - b.id : a.size - b.size
  421.         });
  422.         Canvas2dContext.save();
  423.         Canvas2dContext.translate(WindowWidth / 2, WindowHeight / 2);
  424.         Canvas2dContext.scale(VisionSpread, VisionSpread);
  425.         Canvas2dContext.translate(-LocalX, -LocalY);
  426.         for (d = 0; d < DestroyedEntityList.length; d++) DestroyedEntityList[d].draw();
  427.         for (d = 0; d < EntityList.length; d++) EntityList[d].draw();
  428.         if (qa) {
  429.             $ = (3 * $ + oa) / 4;
  430.             aa = (3 * aa + pa) / 4;
  431.             Canvas2dContext.save();
  432.             Canvas2dContext.strokeStyle = "#FFAAAA";
  433.             Canvas2dContext.lineWidth = 10;
  434.             Canvas2dContext.lineCap = "round";
  435.             Canvas2dContext.lineJoin = "round";
  436.             Canvas2dContext.globalAlpha =
  437.                 .5;
  438.             Canvas2dContext.beginPath();
  439.             for (d = 0; d < OwnEntities.length; d++) Canvas2dContext.moveTo(OwnEntities[d].x, OwnEntities[d].y), Canvas2dContext.lineTo($, aa);
  440.             Canvas2dContext.stroke();
  441.             Canvas2dContext.restore()
  442.         }
  443.         Canvas2dContext.restore();
  444.         TempCanvas && TempCanvas.width && Canvas2dContext.drawImage(TempCanvas, WindowWidth - TempCanvas.width - 10, 10);
  445.         H = Math.max(H, GetOwnTotalSqrSize());
  446.         0 != H && (null == ga && (ga = new Style(24, "#FFFFFF")), ga.setValue("Score: " + ~~(H / 100)), a = ga.render(), b = a.width, Canvas2dContext.globalAlpha = .2, Canvas2dContext.fillStyle = "#000000", Canvas2dContext.fillRect(10, WindowHeight - 10 - 24 - 10, b + 10, 34), Canvas2dContext.globalAlpha = 1, Canvas2dContext.drawImage(a, 15, WindowHeight - 10 - 24 - 5));
  447.         DrawMobileLogo();
  448.         c = +new Date - c;
  449.         c > 1E3 / 60 ? x -= .01 : c < 1E3 / 65 && (x += .01);
  450.         .4 > x && (x = .4);
  451.         1 < x && (x = 1)
  452.     }
  453.  
  454.     function DrawMobileLogo() {
  455.         if (IsMobile && Logo.width) {
  456.             var a = WindowWidth / 5;
  457.             Canvas2dContext.drawImage(Logo, 5, 5, a, a)
  458.         }
  459.     }
  460.  
  461.     function GetOwnTotalSqrSize() {
  462.         for (var a = 0, b = 0; b < OwnEntities.length; b++) a += OwnEntities[b].nSize * OwnEntities[b].nSize;
  463.         return a
  464.     }
  465.  
  466.     function DrawScoreBoard() {
  467.         TempCanvas = null;
  468.         if (null != w || 0 != ScoreBoardPlayerArray.length)
  469.             if (null != w || ShowNames) {
  470.                 TempCanvas = document.createElement("canvas");
  471.                 var TempCanvas2dContext = TempCanvas.getContext("2d"),
  472.                     b = 60,
  473.                     b = null == w ? b + 24 * ScoreBoardPlayerArray.length : b + 180,
  474.                     c = Math.min(200, .3 * WindowWidth) / 200;
  475.                 TempCanvas.width = 200 * c;
  476.                 TempCanvas.height = b * c;
  477.                 TempCanvas2dContext.scale(c, c);
  478.                 TempCanvas2dContext.globalAlpha = .4;
  479.                 TempCanvas2dContext.fillStyle = "#000000";
  480.                 TempCanvas2dContext.fillRect(0, 0, 200, b);
  481.                 TempCanvas2dContext.globalAlpha = 1;
  482.                 TempCanvas2dContext.fillStyle = "#FFFFFF";
  483.                 c = null;
  484.                 c = "Leaderboard";
  485.                 TempCanvas2dContext.font = "30px Ubuntu";
  486.                 TempCanvas2dContext.fillText(c, 100 - TempCanvas2dContext.measureText(c).width /
  487.                 2, 40);
  488.                 if (null == w)
  489.                     for (TempCanvas2dContext.font = "20px Ubuntu", b = 0; b < ScoreBoardPlayerArray.length; ++b) c = ScoreBoardPlayerArray[b].name || "An unnamed cell", ShowNames || (c = "An unnamed cell"), -1 != E.indexOf(ScoreBoardPlayerArray[b].id) ? (OwnEntities[0].name && (c = OwnEntities[0].name), TempCanvas2dContext.fillStyle = "#FFAAAA") : TempCanvas2dContext.fillStyle = "#FFFFFF", c = b + 1 + ". " + c, TempCanvas2dContext.fillText(c, 100 - TempCanvas2dContext.measureText(c).width / 2, 70 + 24 * b);
  490.                 else
  491.                     for (b = c = 0; b < w.length; ++b) angEnd = c + w[b] * Math.PI * 2, TempCanvas2dContext.fillStyle = Za[b + 1], TempCanvas2dContext.beginPath(), TempCanvas2dContext.moveTo(100, 140), TempCanvas2dContext.arc(100, 140, 80, c, angEnd, !1), TempCanvas2dContext.fill(), c = angEnd
  492.             }
  493.     }
  494.  
  495.     function Entity(__Id, __x, __y, __Size, __Color, __Name) {
  496.         EntityList.push(this);
  497.         EntityArray[__Id] = this;
  498.         this.id = __Id;
  499.         this.ox = this.x = __x;
  500.         this.oy = this.y = __y;
  501.         this.oSize = this.size = __Size;
  502.         this.color = __Color;
  503.         this.points = [];
  504.         this.pointsAcc = [];
  505.         this.createPoints();
  506.         this.setName(__Name)
  507.     }
  508.  
  509.     function Style(__Size, __Color, __Stroke, __StrokeColor) {
  510.         __Size && (this._size = __Size);
  511.         __Color && (this._color = __Color);
  512.         this._stroke = !!__Stroke;
  513.         __StrokeColor && (this._strokeColor = __StrokeColor)
  514.     }
  515.  
  516.     var HttpProtocol = MyWindow.location.protocol,
  517.         IsHttps = "https:" == HttpProtocol;
  518.     if ("agar.io" != MyWindow.location.hostname && "localhost" != MyWindow.location.hostname && "10.10.2.13" != MyWindow.location.hostname) MyWindow.location = HttpProtocol + "//agar.io/";
  519.     else if (MyWindow.top != MyWindow) MyWindow.top.location = HttpProtocol + "//agar.io/";
  520.     else {
  521.         var Canvas1, Canvas2dContext, Canvas2, WindowWidth, WindowHeight, QuadTreeInterface = null,
  522.             MySocket = null,
  523.             LocalX = 0,
  524.             LocalY = 0,
  525.             E = [],
  526.             OwnEntities = [],
  527.             EntityArray = {},
  528.             EntityList = [],
  529.             DestroyedEntityList = [],
  530.             ScoreBoardPlayerArray = [],
  531.             MouseX = 0,
  532.             MouseY = 0,
  533.             DesiredWorldX = -1,
  534.             DesiredWorldY = -1,
  535.             Wa = 0,
  536.             CurTimeStamp = 0,
  537.             LocalName = null,
  538.             ba = 0,
  539.             ca = 0,
  540.             da = 1E4,
  541.             ea = 1E4,
  542.             VisionSpread = 1,
  543.             ServerRegion = null,
  544.             ShowSkins = !0,
  545.             ShowNames = !0,
  546.             ShowColors = !1,
  547.             ra = !1,
  548.             H = 0,
  549.             UseDarkTheme = !1,
  550.             ShowOwnMass = !1,
  551.             CameraX = LocalX = ~~((ba + da) / 2),
  552.             CameraY = LocalY = ~~((ca + ea) / 2),
  553.             CameraSpread = 1,
  554.             GameMode = "",
  555.             w = null,
  556.             IsLoaded = !1,
  557.             qa = !1,
  558.             oa = 0,
  559.             pa = 0,
  560.             $ = 0,
  561.             aa = 0,
  562.             Canvas3 = 0,
  563.             Za = ["#333333", "#FF3333", "#33FF33", "#3333FF"],
  564.             IsAcid = !1,
  565.             Zoom = 1,
  566.             IsMobile = "ontouchstart" in MyWindow && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
  567.             Logo = new Image;
  568.         Logo.src = "img/split.png";
  569.         Canvas3 = document.createElement("canvas");
  570.         if ("undefined" == typeof console || "undefined" == typeof DataView ||
  571.             "undefined" == typeof WebSocket || null == Canvas3 || null == Canvas3.getContext || null == MyWindow.localStorage) alert("You browser does not support this game, we recommend you to use Firefox to play this");
  572.         else {
  573.             var Y = null;
  574.             MyWindow.setNick = function (a) {
  575.                 Ea();
  576.                 LocalName = a;
  577.                 SendName();
  578.                 H = 0
  579.             };
  580.             MyWindow.setRegion = U;
  581.             MyWindow.setSkins = function (a) {
  582.                 ShowSkins = a
  583.             };
  584.             MyWindow.setNames = function (a) {
  585.                 ShowNames = a
  586.             };
  587.             MyWindow.setDarkTheme = function (a) {
  588.                 UseDarkTheme = a
  589.             };
  590.             MyWindow.setColors = function (a) {
  591.                 ShowColors = a
  592.             };
  593.             MyWindow.setShowMass = function (a) {
  594.                 ShowOwnMass = a
  595.             };
  596.             MyWindow.spectate = function () {
  597.                 LocalName = null;
  598.                 SendSinglePacket(1);
  599.                 Ea()
  600.             };
  601.             MyWindow.setGameMode = function (a) {
  602.                 a != GameMode && (GameMode = a, WaitingForConnection())
  603.             };
  604.             MyWindow.setAcid = function (a) {
  605.                 IsAcid = a
  606.             };
  607.             null != MyWindow.localStorage && (null == MyWindow.localStorage.AB8 && (MyWindow.localStorage.AB8 = 0 + ~~(100 * Math.random())), Canvas3 = +MyWindow.localStorage.AB8, MyWindow.ABGroup = Canvas3);
  608.             MyJQuery.get(HttpProtocol + "//gc.agar.io", function (a) {
  609.                 var b = a.split(" ");
  610.                 a = b[0];
  611.                 b = b[1] || "";
  612.                 -1 == "DE IL PL HU BR AT UA".split(" ").indexOf(a) && NameCodes1.push("nazi");
  613.                 -1 == ["UA"].indexOf(a) && NameCodes1.push("ussr"); // Check for Censor
  614.                 Countries.hasOwnProperty(a) && ("string" == typeof Countries[a] ? ServerRegion || U(Countries[a]) : Countries[a].hasOwnProperty(b) && (ServerRegion || U(Countries[a][b])))
  615.             }, "text");
  616.             setTimeout(function () {
  617.             }, 3E5);
  618.             var Countries = {
  619.                 AF: "JP-Tokyo",
  620.                 AX: "EU-London",
  621.                 AL: "EU-London",
  622.                 DZ: "EU-London",
  623.                 AS: "SG-Singapore",
  624.                 AD: "EU-London",
  625.                 AO: "EU-London",
  626.                 AI: "US-Atlanta",
  627.                 AG: "US-Atlanta",
  628.                 AR: "BR-Brazil",
  629.                 AM: "JP-Tokyo",
  630.                 AW: "US-Atlanta",
  631.                 AU: "SG-Singapore",
  632.                 AT: "EU-London",
  633.                 AZ: "JP-Tokyo",
  634.                 BS: "US-Atlanta",
  635.                 BH: "JP-Tokyo",
  636.                 BD: "JP-Tokyo",
  637.                 BB: "US-Atlanta",
  638.                 BY: "EU-London",
  639.                 BE: "EU-London",
  640.                 BZ: "US-Atlanta",
  641.                 BJ: "EU-London",
  642.                 BM: "US-Atlanta",
  643.                 BT: "JP-Tokyo",
  644.                 BO: "BR-Brazil",
  645.                 BQ: "US-Atlanta",
  646.                 BA: "EU-London",
  647.                 BW: "EU-London",
  648.                 BR: "BR-Brazil",
  649.                 IO: "JP-Tokyo",
  650.                 VG: "US-Atlanta",
  651.                 BN: "JP-Tokyo",
  652.                 BG: "EU-London",
  653.                 BF: "EU-London",
  654.                 BI: "EU-London",
  655.                 KH: "JP-Tokyo",
  656.                 CM: "EU-London",
  657.                 CA: "US-Atlanta",
  658.                 CV: "EU-London",
  659.                 KY: "US-Atlanta",
  660.                 CF: "EU-London",
  661.                 TD: "EU-London",
  662.                 CL: "BR-Brazil",
  663.                 CN: "CN-China",
  664.                 CX: "JP-Tokyo",
  665.                 CC: "JP-Tokyo",
  666.                 CO: "BR-Brazil",
  667.                 KM: "EU-London",
  668.                 CD: "EU-London",
  669.                 CG: "EU-London",
  670.                 CK: "SG-Singapore",
  671.                 CR: "US-Atlanta",
  672.                 CI: "EU-London",
  673.                 HR: "EU-London",
  674.                 CU: "US-Atlanta",
  675.                 CW: "US-Atlanta",
  676.                 CY: "JP-Tokyo",
  677.                 CZ: "EU-London",
  678.                 DK: "EU-London",
  679.                 DJ: "EU-London",
  680.                 DM: "US-Atlanta",
  681.                 DO: "US-Atlanta",
  682.                 EC: "BR-Brazil",
  683.                 EG: "EU-London",
  684.                 SV: "US-Atlanta",
  685.                 GQ: "EU-London",
  686.                 ER: "EU-London",
  687.                 EE: "EU-London",
  688.                 ET: "EU-London",
  689.                 FO: "EU-London",
  690.                 FK: "BR-Brazil",
  691.                 FJ: "SG-Singapore",
  692.                 FI: "EU-London",
  693.                 FR: "EU-London",
  694.                 GF: "BR-Brazil",
  695.                 PF: "SG-Singapore",
  696.                 GA: "EU-London",
  697.                 GM: "EU-London",
  698.                 GE: "JP-Tokyo",
  699.                 DE: "EU-London",
  700.                 GH: "EU-London",
  701.                 GI: "EU-London",
  702.                 GR: "EU-London",
  703.                 GL: "US-Atlanta",
  704.                 GD: "US-Atlanta",
  705.                 GP: "US-Atlanta",
  706.                 GU: "SG-Singapore",
  707.                 GT: "US-Atlanta",
  708.                 GG: "EU-London",
  709.                 GN: "EU-London",
  710.                 GW: "EU-London",
  711.                 GY: "BR-Brazil",
  712.                 HT: "US-Atlanta",
  713.                 VA: "EU-London",
  714.                 HN: "US-Atlanta",
  715.                 HK: "JP-Tokyo",
  716.                 HU: "EU-London",
  717.                 IS: "EU-London",
  718.                 IN: "JP-Tokyo",
  719.                 ID: "JP-Tokyo",
  720.                 IR: "JP-Tokyo",
  721.                 IQ: "JP-Tokyo",
  722.                 IE: "EU-London",
  723.                 IM: "EU-London",
  724.                 IL: "JP-Tokyo",
  725.                 IT: "EU-London",
  726.                 JM: "US-Atlanta",
  727.                 JP: "JP-Tokyo",
  728.                 JE: "EU-London",
  729.                 JO: "JP-Tokyo",
  730.                 KZ: "JP-Tokyo",
  731.                 KE: "EU-London",
  732.                 KI: "SG-Singapore",
  733.                 KP: "JP-Tokyo",
  734.                 KR: "JP-Tokyo",
  735.                 KW: "JP-Tokyo",
  736.                 KG: "JP-Tokyo",
  737.                 LA: "JP-Tokyo",
  738.                 LV: "EU-London",
  739.                 LB: "JP-Tokyo",
  740.                 LS: "EU-London",
  741.                 LR: "EU-London",
  742.                 LY: "EU-London",
  743.                 LI: "EU-London",
  744.                 LT: "EU-London",
  745.                 LU: "EU-London",
  746.                 MO: "JP-Tokyo",
  747.                 MK: "EU-London",
  748.                 MG: "EU-London",
  749.                 MW: "EU-London",
  750.                 MY: "JP-Tokyo",
  751.                 MV: "JP-Tokyo",
  752.                 ML: "EU-London",
  753.                 MT: "EU-London",
  754.                 MH: "SG-Singapore",
  755.                 MQ: "US-Atlanta",
  756.                 MR: "EU-London",
  757.                 MU: "EU-London",
  758.                 YT: "EU-London",
  759.                 MX: "US-Atlanta",
  760.                 FM: "SG-Singapore",
  761.                 MD: "EU-London",
  762.                 MC: "EU-London",
  763.                 MN: "JP-Tokyo",
  764.                 ME: "EU-London",
  765.                 MS: "US-Atlanta",
  766.                 MA: "EU-London",
  767.                 MZ: "EU-London",
  768.                 MM: "JP-Tokyo",
  769.                 NA: "EU-London",
  770.                 NR: "SG-Singapore",
  771.                 NP: "JP-Tokyo",
  772.                 NL: "EU-London",
  773.                 NC: "SG-Singapore",
  774.                 NZ: "SG-Singapore",
  775.                 NI: "US-Atlanta",
  776.                 NE: "EU-London",
  777.                 NG: "EU-London",
  778.                 NU: "SG-Singapore",
  779.                 NF: "SG-Singapore",
  780.                 MP: "SG-Singapore",
  781.                 NO: "EU-London",
  782.                 OM: "JP-Tokyo",
  783.                 PK: "JP-Tokyo",
  784.                 PW: "SG-Singapore",
  785.                 PS: "JP-Tokyo",
  786.                 PA: "US-Atlanta",
  787.                 PG: "SG-Singapore",
  788.                 PY: "BR-Brazil",
  789.                 PE: "BR-Brazil",
  790.                 PH: "JP-Tokyo",
  791.                 PN: "SG-Singapore",
  792.                 PL: "EU-London",
  793.                 PT: "EU-London",
  794.                 PR: "US-Atlanta",
  795.                 QA: "JP-Tokyo",
  796.                 RE: "EU-London",
  797.                 RO: "EU-London",
  798.                 RU: "RU-Russia",
  799.                 RW: "EU-London",
  800.                 BL: "US-Atlanta",
  801.                 SH: "EU-London",
  802.                 KN: "US-Atlanta",
  803.                 LC: "US-Atlanta",
  804.                 MF: "US-Atlanta",
  805.                 PM: "US-Atlanta",
  806.                 VC: "US-Atlanta",
  807.                 WS: "SG-Singapore",
  808.                 SM: "EU-London",
  809.                 ST: "EU-London",
  810.                 SA: "EU-London",
  811.                 SN: "EU-London",
  812.                 RS: "EU-London",
  813.                 SC: "EU-London",
  814.                 SL: "EU-London",
  815.                 SG: "JP-Tokyo",
  816.                 SX: "US-Atlanta",
  817.                 SK: "EU-London",
  818.                 SI: "EU-London",
  819.                 SB: "SG-Singapore",
  820.                 SO: "EU-London",
  821.                 ZA: "EU-London",
  822.                 SS: "EU-London",
  823.                 ES: "EU-London",
  824.                 LK: "JP-Tokyo",
  825.                 SD: "EU-London",
  826.                 SR: "BR-Brazil",
  827.                 SJ: "EU-London",
  828.                 SZ: "EU-London",
  829.                 SE: "EU-London",
  830.                 CH: "EU-London",
  831.                 SY: "EU-London",
  832.                 TW: "JP-Tokyo",
  833.                 TJ: "JP-Tokyo",
  834.                 TZ: "EU-London",
  835.                 TH: "JP-Tokyo",
  836.                 TL: "JP-Tokyo",
  837.                 TG: "EU-London",
  838.                 TK: "SG-Singapore",
  839.                 TO: "SG-Singapore",
  840.                 TT: "US-Atlanta",
  841.                 TN: "EU-London",
  842.                 TR: "TK-Turkey",
  843.                 TM: "JP-Tokyo",
  844.                 TC: "US-Atlanta",
  845.                 TV: "SG-Singapore",
  846.                 UG: "EU-London",
  847.                 UA: "EU-London",
  848.                 AE: "EU-London",
  849.                 GB: "EU-London",
  850.                 US: {
  851.                     AL: "US-Atlanta",
  852.                     AK: "US-Fremont",
  853.                     AZ: "US-Fremont",
  854.                     AR: "US-Atlanta",
  855.                     CA: "US-Fremont",
  856.                     CO: "US-Fremont",
  857.                     CT: "US-Atlanta",
  858.                     DE: "US-Atlanta",
  859.                     FL: "US-Atlanta",
  860.                     GA: "US-Atlanta",
  861.                     HI: "US-Fremont",
  862.                     ID: "US-Fremont",
  863.                     IL: "US-Atlanta",
  864.                     IN: "US-Atlanta",
  865.                     IA: "US-Atlanta",
  866.                     KS: "US-Atlanta",
  867.                     KY: "US-Atlanta",
  868.                     LA: "US-Atlanta",
  869.                     ME: "US-Atlanta",
  870.                     MD: "US-Atlanta",
  871.                     MA: "US-Atlanta",
  872.                     MI: "US-Atlanta",
  873.                     MN: "US-Fremont",
  874.                     MS: "US-Atlanta",
  875.                     MO: "US-Atlanta",
  876.                     MT: "US-Fremont",
  877.                     NE: "US-Fremont",
  878.                     NV: "US-Fremont",
  879.                     NH: "US-Atlanta",
  880.                     NJ: "US-Atlanta",
  881.                     NM: "US-Fremont",
  882.                     NY: "US-Atlanta",
  883.                     NC: "US-Atlanta",
  884.                     ND: "US-Fremont",
  885.                     OH: "US-Atlanta",
  886.                     OK: "US-Atlanta",
  887.                     OR: "US-Fremont",
  888.                     PA: "US-Atlanta",
  889.                     RI: "US-Atlanta",
  890.                     SC: "US-Atlanta",
  891.                     SD: "US-Fremont",
  892.                     TN: "US-Atlanta",
  893.                     TX: "US-Atlanta",
  894.                     UT: "US-Fremont",
  895.                     VT: "US-Atlanta",
  896.                     VA: "US-Atlanta",
  897.                     WA: "US-Fremont",
  898.                     WV: "US-Atlanta",
  899.                     WI: "US-Atlanta",
  900.                     WY: "US-Fremont",
  901.                     DC: "US-Atlanta",
  902.                     AS: "US-Atlanta",
  903.                     GU: "US-Atlanta",
  904.                     MP: "US-Atlanta",
  905.                     PR: "US-Atlanta",
  906.                     UM: "US-Atlanta",
  907.                     VI: "US-Atlanta"
  908.                 },
  909.                 UM: "SG-Singapore",
  910.                 VI: "US-Atlanta",
  911.                 UY: "BR-Brazil",
  912.                 UZ: "JP-Tokyo",
  913.                 VU: "SG-Singapore",
  914.                 VE: "BR-Brazil",
  915.                 VN: "JP-Tokyo",
  916.                 WF: "SG-Singapore",
  917.                 EH: "EU-London",
  918.                 YE: "JP-Tokyo",
  919.                 ZM: "EU-London",
  920.                 ZW: "EU-London"
  921.             };
  922.             MyWindow.connect = Connect;
  923.             var TimeOutForReconnect = 500,
  924.                 Ka = -1,
  925.                 La = -1,
  926.                 TempCanvas = null,
  927.                 x = 1,
  928.                 ga = null,
  929.                 J = {},
  930.                 NameCodes1 = "poland;usa;china;russia;canada;australia;spain;brazil;germany;ukraine;france;sweden;hitler;north korea;south korea;japan;united kingdom;earth;greece;latvia;lithuania;estonia;finland;norway;cia;maldivas;austria;nigeria;reddit;yaranaika;confederate;9gag;indiana;4chan;italy;bulgaria;tumblr;2ch.hk;hong kong;portugal;jamaica;german empire;mexico;sanik;switzerland;croatia;chile;indonesia;bangladesh;thailand;iran;iraq;peru;moon;botswana;bosnia;netherlands;european union;taiwan;pakistan;hungary;satanist;qing dynasty;matriarchy;patriarchy;feminism;ireland;texas;facepunch;prodota;cambodia;steam;piccolo;ea;india;kc;denmark;quebec;ayy lmao;sealand;bait;tsarist russia;origin;vinesauce;stalin;belgium;luxembourg;stussy;prussia;8ch;argentina;scotland;sir;romania;belarus;wojak;doge;nasa;byzantium;imperial japan;french kingdom;somalia;turkey;mars;pokerface;8;irs;receita federal".split(";"),
  931.                 NameCodes2 = ["8", "nasa"],
  932.                 ab = ["m'blob"];
  933.             Entity.prototype = {
  934.                 id: 0,
  935.                 points: null,
  936.                 pointsAcc: null,
  937.                 name: null,
  938.                 nameCache: null,
  939.                 sizeCache: null,
  940.                 x: 0, // Cur x/y
  941.                 y: 0,
  942.                 size: 0,
  943.                 ox: 0, // Last x/y
  944.                 oy: 0,
  945.                 oSize: 0,
  946.                 nx: 0, // Server x/y (integer)
  947.                 ny: 0,
  948.                 nSize: 0,
  949.                 updateTime: 0,
  950.                 updateCode: 0,
  951.                 drawTime: 0,
  952.                 destroyed: !1,
  953.                 isVirus: !1,
  954.                 isAgitated: !1,
  955.                 wasSimpleDrawing: !0,
  956.                 destroy: function () {
  957.                     var a;
  958.                     for (a = 0; a < EntityList.length; a++)
  959.                         if (EntityList[a] == this) {
  960.                             EntityList.splice(a, 1);
  961.                             break
  962.                         }
  963.                     delete EntityArray[this.id];
  964.                     a = OwnEntities.indexOf(this);
  965.                     -1 != a && (ra = !0, OwnEntities.splice(a, 1));
  966.                     a = E.indexOf(this.id);
  967.                     -1 != a && E.splice(a, 1);
  968.                     this.destroyed = !0;
  969.                     DestroyedEntityList.push(this)
  970.                 },
  971.                 getNameSize: function () {
  972.                     return Math.max(~~(.3 * this.size), 24)
  973.                 },
  974.                 setName: function (a) {
  975.                     if (this.name = a) null == this.nameCache ? this.nameCache = new Style(this.getNameSize(), "#FFFFFF", !0, "#000000") : this.nameCache.setSize(this.getNameSize()), this.nameCache.setValue(this.name)
  976.                 },
  977.                 createPoints: function () {
  978.                     for (var a = this.getNumPoints(); this.points.length > a;) {
  979.                         var b = ~~(Math.random() * this.points.length);
  980.                         this.points.splice(b, 1);
  981.                         this.pointsAcc.splice(b, 1)
  982.                     }
  983.                     0 == this.points.length && 0 < a && (this.points.push({
  984.                         c: this,
  985.                         v: this.size,
  986.                         x: this.x,
  987.                         y: this.y
  988.                     }), this.pointsAcc.push(Math.random() - .5));
  989.                     for (; this.points.length < a;) {
  990.                         var b = ~~(Math.random() * this.points.length),
  991.                             c = this.points[b];
  992.                         this.points.splice(b, 0, {
  993.                             c: this,
  994.                             v: c.v,
  995.                             x: c.x,
  996.                             y: c.y
  997.                         });
  998.                         this.pointsAcc.splice(b, 0, this.pointsAcc[b])
  999.                     }
  1000.                 },
  1001.                 getNumPoints: function () {
  1002.                     var a = 10;
  1003.                     20 > this.size && (a = 5);
  1004.                     this.isVirus && (a = 30);
  1005.                     var b = this.size;
  1006.                     this.isVirus || (b *= VisionSpread);
  1007.                     b *= x;
  1008.                     return ~~Math.max(b, a)
  1009.                 },
  1010.                 movePoints: function () {
  1011.                     this.createPoints();
  1012.                     for (var a = this.points, b = this.pointsAcc, c = a.length, d = 0; d < c; ++d) {
  1013.                         var e = b[(d - 1 + c) % c],
  1014.                             f = b[(d + 1) % c];
  1015.                         b[d] += (Math.random() - .5) * (this.isAgitated ? 3 : 1);
  1016.                         b[d] *= .7;
  1017.                         10 < b[d] && (b[d] = 10);
  1018.                         -10 > b[d] && (b[d] = -10);
  1019.                         b[d] = (e + f + 8 * b[d]) / 10
  1020.                     }
  1021.                     for (var h = this, d = 0; d < c; ++d) {
  1022.                         var g = a[d].v,
  1023.                             e = a[(d - 1 + c) % c].v,
  1024.                             f = a[(d + 1) % c].v;
  1025.                         if (15 < this.size && null != QuadTreeInterface) {
  1026.                             var l = !1,
  1027.                                 m = a[d].x,
  1028.                                 n = a[d].y;
  1029.                             QuadTreeInterface.retrieve2(m - 5, n - 5, 10, 10, function (a) {
  1030.                                 a.c != h && 25 > (m - a.x) * (m - a.x) + (n - a.y) * (n - a.y) && (l = !0)
  1031.                             });
  1032.                             !l && (a[d].x < ba || a[d].y < ca || a[d].x > da || a[d].y > ea) && (l = !0);
  1033.                             l && (0 < b[d] && (b[d] = 0), b[d] -= 1)
  1034.                         }
  1035.                         g += b[d];
  1036.                         0 > g && (g = 0);
  1037.                         g = this.isAgitated ? (19 * g + this.size) / 20 : (12 * g + this.size) / 13;
  1038.                         a[d].v = (e + f + 8 * g) / 10;
  1039.                         e = 2 * Math.PI / c;
  1040.                         f = this.points[d].v;
  1041.                         this.isVirus && 0 == d % 2 && (f += 5);
  1042.                         a[d].x = this.x + Math.cos(e * d) * f;
  1043.                         a[d].y = this.y + Math.sin(e * d) * f
  1044.                     }
  1045.                 },
  1046.                 updatePos: function () {
  1047.                     var a;
  1048.                     a = (CurTimeStamp - this.updateTime) / 120;
  1049.                     a = 0 > a ? 0 : 1 < a ? 1 : a;
  1050.                     var b = 0 > a ? 0 : 1 < a ? 1 : a;
  1051.                     this.getNameSize();
  1052.                     if (this.destroyed && 1 <= b) {
  1053.                         var c = DestroyedEntityList.indexOf(this);
  1054.                         -1 != c && DestroyedEntityList.splice(c, 1)
  1055.                     }
  1056.                     this.x = a * (this.nx - this.ox) + this.ox;
  1057.                     this.y = a * (this.ny - this.oy) + this.oy;
  1058.                     this.size = b * (this.nSize - this.oSize) + this.oSize;
  1059.                     return b
  1060.                 },
  1061.                 shouldRender: function () {
  1062.                     return this.x + this.size + 40 < LocalX - WindowWidth / 2 / VisionSpread || this.y + this.size + 40 < LocalY - WindowHeight / 2 / VisionSpread || this.x - this.size - 40 > LocalX + WindowWidth / 2 / VisionSpread || this.y - this.size - 40 > LocalY + WindowHeight / 2 / VisionSpread ? !1 : !0
  1063.                 },
  1064.                 draw: function () {
  1065.                     if (this.shouldRender()) {
  1066.                         var a = !this.isVirus && !this.isAgitated && .35 > VisionSpread;
  1067.                         if (this.wasSimpleDrawing && !a)
  1068.                             for (var b = 0; b < this.points.length; b++) this.points[b].v = this.size;
  1069.                         this.wasSimpleDrawing = a;
  1070.                         Canvas2dContext.save();
  1071.                         this.drawTime = CurTimeStamp;
  1072.                         b = this.updatePos();
  1073.                         this.destroyed && (Canvas2dContext.globalAlpha *= 1 - b);
  1074.                         Canvas2dContext.lineWidth = 10;
  1075.                         Canvas2dContext.lineCap = "round";
  1076.                         Canvas2dContext.lineJoin = this.isVirus ? "mitter" : "round";
  1077.                         ShowColors ? (Canvas2dContext.fillStyle = "#FFFFFF", Canvas2dContext.strokeStyle = "#AAAAAA") : (Canvas2dContext.fillStyle = this.color, Canvas2dContext.strokeStyle = this.color);
  1078.                         if (a) Canvas2dContext.beginPath(), Canvas2dContext.arc(this.x, this.y, this.size, 0, 2 * Math.PI, !1);
  1079.                         else {
  1080.                             this.movePoints();
  1081.                             Canvas2dContext.beginPath();
  1082.                             var c = this.getNumPoints();
  1083.                             Canvas2dContext.moveTo(this.points[0].x, this.points[0].y);
  1084.                             for (b = 1; b <= c; ++b) {
  1085.                                 var d = b % c;
  1086.                                 Canvas2dContext.lineTo(this.points[d].x, this.points[d].y)
  1087.                             }
  1088.                         }
  1089.                         Canvas2dContext.closePath();
  1090.                         c = this.name.toLowerCase();
  1091.                         !this.isAgitated && ShowSkins && "" == GameMode ? -1 != NameCodes1.indexOf(c) ? (J.hasOwnProperty(c) || (J[c] = new Image, J[c].src = "skins/" + c + ".png"), b = 0 != J[c].width && J[c].complete ? J[c] : null) : b = null : b = null;
  1092.                         b = (d = b) ? -1 != ab.indexOf(c) : !1;
  1093.                         a || Canvas2dContext.stroke();
  1094.                         Canvas2dContext.fill();
  1095.                         null == d || b || (Canvas2dContext.save(), Canvas2dContext.clip(), Canvas2dContext.drawImage(d, this.x - this.size, this.y - this.size, 2 * this.size, 2 * this.size), Canvas2dContext.restore());
  1096.                         (ShowColors || 15 < this.size) && !a && (Canvas2dContext.strokeStyle = "#000000", Canvas2dContext.globalAlpha *= .1, Canvas2dContext.stroke());
  1097.                         Canvas2dContext.globalAlpha = 1;
  1098.                         null != d && b && Canvas2dContext.drawImage(d, this.x - 2 * this.size, this.y - 2 * this.size, 4 * this.size, 4 * this.size);
  1099.                         b = -1 != OwnEntities.indexOf(this);
  1100.                         a = ~~this.y;
  1101.                         if ((ShowNames || b) && this.name && this.nameCache && (null == d || -1 == NameCodes2.indexOf(c))) {
  1102.                             d = this.nameCache;
  1103.                             d.setValue(this.name);
  1104.                             d.setSize(this.getNameSize());
  1105.                             c = Math.ceil(10 * VisionSpread) / 10;
  1106.                             d.setScale(c);
  1107.                             var d = d.render(),
  1108.                                 f = ~~(d.width / c),
  1109.                                 g = ~~(d.height / c);
  1110.                             Canvas2dContext.drawImage(d, ~~this.x - ~~(f / 2), a - ~~(g / 2), f, g);
  1111.                             a += d.height / 2 / c + 4
  1112.                         }
  1113.                         ShowOwnMass && (b || 0 == OwnEntities.length && (!this.isVirus || this.isAgitated) && 20 < this.size) && (null == this.sizeCache && (this.sizeCache = new Style(this.getNameSize() / 2, "#FFFFFF", !0, "#000000")), b = this.sizeCache, b.setSize(this.getNameSize() / 2), b.setValue(~~(this.size * this.size / 100)), c = Math.ceil(10 * VisionSpread) / 10, b.setScale(c), d = b.render(), f = ~~(d.width / c), g = ~~(d.height / c), Canvas2dContext.drawImage(d, ~~this.x - ~~(f / 2), a - ~~(g / 2), f, g));
  1114.                         Canvas2dContext.restore()
  1115.                     }
  1116.                 }
  1117.             };
  1118.             Style.prototype = {
  1119.                 _value: "",
  1120.                 _color: "#000000",
  1121.                 _stroke: !1,
  1122.                 _strokeColor: "#000000",
  1123.                 _size: 16,
  1124.                 _canvas: null,
  1125.                 _ctx: null,
  1126.                 _dirty: !1,
  1127.                 _scale: 1,
  1128.                 setSize: function (a) {
  1129.                     this._size != a && (this._size = a, this._dirty = !0)
  1130.                 },
  1131.                 setScale: function (a) {
  1132.                     this._scale != a && (this._scale = a, this._dirty = !0)
  1133.                 },
  1134.                 setColor: function (a) {
  1135.                     this._color != a && (this._color = a, this._dirty = !0)
  1136.                 },
  1137.                 setStroke: function (a) {
  1138.                     this._stroke != a && (this._stroke = a, this._dirty = !0)
  1139.                 },
  1140.                 setStrokeColor: function (a) {
  1141.                     this._strokeColor != a && (this._strokeColor = a, this._dirty = !0)
  1142.                 },
  1143.                 setValue: function (a) {
  1144.                     a != this._value && (this._value = a, this._dirty = !0)
  1145.                 },
  1146.                 render: function () {
  1147.                     null == this._canvas && (this._canvas = document.createElement("canvas"), this._ctx = this._canvas.getContext("2d"));
  1148.                     if (this._dirty) {
  1149.                         this._dirty = !1;
  1150.                         var a = this._canvas,
  1151.                             b = this._ctx,
  1152.                             c = this._value,
  1153.                             d = this._scale,
  1154.                             e = this._size,
  1155.                             f = e + "px Ubuntu";
  1156.                         b.font = f;
  1157.                         var g = b.measureText(c).width,
  1158.                             h = ~~(.2 * e);
  1159.                         a.width = (g + 6) * d;
  1160.                         a.height = (e + h) * d;
  1161.                         b.font = f;
  1162.                         b.scale(d, d);
  1163.                         b.globalAlpha = 1;
  1164.                         b.lineWidth = 3;
  1165.                         b.strokeStyle = this._strokeColor;
  1166.                         b.fillStyle = this._color;
  1167.                         this._stroke && b.strokeText(c, 3, e - h / 2);
  1168.                         b.fillText(c, 3, e - h / 2)
  1169.                     }
  1170.                     return this._canvas
  1171.                 }
  1172.             };
  1173.             MyWindow.onload = GameInit
  1174.         }
  1175.     }
  1176. })(window, jQuery);
Add Comment
Please, Sign In to add comment