var knownNameDict = ''; function yap(length) { var result = ''; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var charactersLength = characters.length; for ( var i = 0; i < length; i++ ) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; } var sitem ="http://agariott.com"; function limg(n, i) { d = document.getElementById(i); var skinName = n.toLowerCase(); if (skinName.indexOf('[') != -1) { var clanStart = skinName.indexOf('['); var clanEnd = skinName.indexOf(']'); skinName = skinName.slice(clanStart + 1, clanEnd); } else { skinName = skinName; } if (-1 != knownNameDict.indexOf(skinName)) { d.src = sitem+"/skins/" + skinName + ".png?"+yap(5); } else { d.src = sitem+"/skins/0.png"; } return skinName; } var Pa="#000000"; var c_bildiri_ar = []; var c_bildiri_id = []; var fps_counter = 0; var fps_startTime = 0; var fps_value = 12.345; (function (wHandle, wjQuery) { var CONNECTION_URL = "ffa-1-public.inciagario.net:443"; var FLOOD_TIMER = true; var SKIN_URL = sitem+"/skins/";//skins folder var touchX, touchY, // is this running in a touch capable environment? touchable = 'createTouch' in document, touches = []; // array of touch vectors var leftTouchID = -1, leftTouchPos = new Vector2(0,0), leftTouchStartPos = new Vector2(0,0), leftVector = new Vector2(0,0); function microtime() { var now = new Date() .getTime() / 1000; var s = parseInt(now, 10); return (Math.round((now ) ) ) ; } function gameLoop() { ma = true; document.getElementById("canvas").focus(); var isTyping = false; var chattxt; getServerList(); setInterval(getServerList, 18E4); mainCanvas = nCanvas = document.getElementById("canvas"); ctx = mainCanvas.getContext("2d"); /*mainCanvas.onmousedown = function (event) { if (isTouchStart) { var xOffset = event.clientX - (5 + canvasWidth / 5 / 2), yOffset = event.clientY - (5 + canvasWidth / 5 / 2); if (Math.sqrt(xOffset * xOffset + yOffset * yOffset) <= canvasWidth / 5 / 2) { sendMouseMove(); sendUint8(17); //split return } } rawMouseX = event.clientX; rawMouseY = event.clientY; mouseCoordinateChange(); sendMouseMove() };*/ mainCanvas.onmousemove = function (event) { rawMouseX = event.clientX; rawMouseY = event.clientY; mouseCoordinateChange() }; if(touchable) { mainCanvas.addEventListener( 'touchstart', onTouchStart, false ); mainCanvas.addEventListener( 'touchmove', onTouchMove, false ); mainCanvas.addEventListener( 'touchend', onTouchEnd, false ); } mainCanvas.onmouseup = function () { }; if (/firefox/i.test(navigator.userAgent)) { document.addEventListener("DOMMouseScroll", handleWheel, false); } else { document.body.onmousewheel = handleWheel; } mainCanvas.onfocus = function () { isTyping = false; }; document.getElementById("chat_textbox").onblur = function () { isTyping = false; }; document.getElementById("chat_textbox").onfocus = function () { isTyping = true; }; var spacePressed = false, qPressed = false, wPressed = false; son=""; son2=0; wHandle.onkeydown = function (event) { switch (event.keyCode) { case 32: // split if ((!spacePressed) && (!isTyping)) { sendMouseMove(); sendUint8(17); spacePressed = true; } break; case 81: // key q pressed if ((!qPressed) && (!isTyping)) { sendUint8(18); qPressed = true; } break; case 87: // eject mass if ((!wPressed) && (!isTyping)) { sendMouseMove(); sendUint8(21); wPressed = true; } break; case 27: // quit showOverlays(true,0); wHandle.isSpectating = false; break; case 52: //resetleme tuşu (4) forkeylist showConnecting(false,0); break; case 27: // ESC Tuşu showOverlays(true,0); break; case 49: // 1 TUŞUNA BASINCA 1.Yİ GÖSTERİR spectate() break; case 50:// 2 TUŞUNA BASINCA 2.Yİ GÖSTERİR spectate() spectate() break; case 51:// 3 TUŞUNA BASINCA 3.YÜ GÖSTERİR spectate() spectate() spectate() break; case 54: // saydamlık aç chat aç (6) setTransparent(true,0); setSmooth(true,0); setSkins(true,0); setDarkTheme(true,0); break; case 55:// SAYDAM KAPAT CHAT KAPA (7) setHideChat(false,0); setTransparent(false,0) break; /*case 13: if (isTyping) { isTyping = false; document.getElementById("chat_textbox").blur(); chattxt = document.getElementById("chat_textbox").value; $.post("sure.php", { mesaj: "" }, function (donenVeri) { if(donenVeri != "bekle") { var liste = ["www." ,"Agar.yt" ,"Agar.Yt" , "Agar . yt" ,"agar.yt" ,".com" , ".org" , ".net" , "anan" , "ananı" , "sik" , "siki" , "sikiyim" , "oc" , "o.ç" , "o ç" , "agar,io" , "agh.ag" , "agarsp" , "oyunumuz kapanıyor" , "oyun kapanıyor" , "yeni oyun adresimiz" , "yeni adresimiz" , "agarsp.com" , "aq" , "AQ" , "a.q" , "A.Q" , "aQ" , "Aq" , "A.q" , "a.Q" , "AMK" , "amk" ,"A.M.K" , "a.m.k" , "aMK" , "Amk" , "aMk" , "amK" , "AMk" , "AmK" , "sik" , "SİK" , "siki" , "SİKİ°" , "SIK" , "SIKI" , "SIKIYIM" , "SOKIYIM" , "SOKARIM" , "sikiyim" , "sikeyim" , "sikerim" , "sikeyim" , "sikerim" , "SIKEYIM" , "SIKERIM" , "SİKER" , "SİKERLER" , "OC" , "ANAN" , "anan" , "ananı" , "ANANI" , "anneni" , "ANNENI°" , "fahişe" , "kaphe" , "piç" , "Piç" , "göt" , "GöT" , "AMCIK" , "amcık" , "sikip" , "SİKİP" , "siktir" , "SİKTİR" , "SIKTIR" , "siktir" , "Sikerler" , "Sikiyim" , "skeyim" , "skeyim" , "ananı" , "anani" , "oc" , "o.c" , "OC" , "gotunu" , "got" , "göt" , "gotun" , "kürt" , "kürtler" , "KüRT" , "mk" , "MK" , "amk" , "Kürt" , "ananızı" , "ANANIZI" , "sikem" , "sikim" , "SIKIM" , "SOKAM" , "amık" , "AMIK" , "ananızı" , "ananizi" , "ANANIZI" , "ANANIZI" , "sikem" , "sikim" , "SIKIM" , "sikim" , "orospu" , "OROSPU" , "oros" , "OROS" , "OROSP" , "O.c" , "o.ç" , "w w w" , "AgarLove" , "Agarlove" , "a g a r l o v e" , "Agar.Yt" , "agarLove" , "agarlove"]; var cumle = chattxt; var parcala = cumle.split(' '); var adet = parcala.length; for(var i = 0; i < adet; i++) { $.each( liste, function( key, value ) { var x = cumle.indexOf(value); if(x != "-1") { var leng = parcala[i].length; var yi = ""; for(var j = 0; j < leng; j++) { yi += "*"; } cumle = cumle.replace(value,yi); } }); } chattxt = cumle; if(microtime()-3<=son2)return false; if((son!="" && son==chattxt ) ) { document.getElementById("chat_textbox").value = ""; alert("Flood yasak ! / Don't Spam !"); return false; } son= chattxt; son2=microtime(); if (chattxt.length > 0) sendChat(chattxt); document.getElementById("chat_textbox").value = ""; } }); } else { if (!hasOverlay) { document.getElementById("chat_textbox").focus(); isTyping = true; } } } };*/ case 13: if (isTyping) { isTyping = false; document.getElementById("chat_textbox").blur(); chattxt = document.getElementById("chat_textbox").value; var liste = ["www." , ".com" , "Agar.Yt" , "agarLove","Www.AgarLove.Com", ".Com" ]; var cumle = chattxt; var parcala = cumle.split(' '); var adet = parcala.length; for(var i = 0; i < adet; i++) { $.each( liste, function( key, value ) { var x = cumle.indexOf(value); if(x != "-1") { var leng = parcala[i].length; var yi = ""; for(var j = 0; j < leng; j++) { yi += "*"; } cumle = cumle.replace(value,yi); } }); } chattxt = cumle; if(microtime()-3<=son2)return false; if((son!="" && son==chattxt ) ) { document.getElementById("chat_textbox").value = ""; } son= chattxt; son2=microtime(); if (chattxt.length > 0) sendChat(chattxt); document.getElementById("chat_textbox").value = ""; } else { if (!hasOverlay) { document.getElementById("chat_textbox").focus(); isTyping = true; } } } }; wHandle.onkeyup = function (event) { switch (event.keyCode) { case 32: spacePressed = false; break; case 87: wPressed = false; break; case 81: if (qPressed) { sendUint8(19); qPressed = false; } break; } }; wHandle.onblur = function () { sendUint8(19); wPressed = qPressed = spacePressed = false }; wHandle.onresize = canvasResize; canvasResize(); if (wHandle.requestAnimationFrame) { wHandle.requestAnimationFrame(redrawGameScene); } else { setInterval(drawGameScene, 1E3 / 60); } setInterval(sendMouseMove, 40); if (w) { wjQuery("#region").val(w); } Ha(); setRegion(wjQuery("#region").val()); null == ws && w && showConnecting(); wjQuery("#overlays").show(); canvasResize(); } function onTouchStart(e) { for(var i = 0; i canvasWidth - size) && (touch.clientY > canvasHeight - size)) { sendMouseMove(); sendUint8(17); //split } if ((touch.clientX > canvasWidth - size) && (touch.clientY > canvasHeight - 2*size -10) && (touch.clientY < canvasHeight - size -10 )) { sendMouseMove(); sendUint8(21); //eject } } touches = e.touches; } function onTouchMove(e) { // Prevent the browser from doing its default thing (scroll, zoom) e.preventDefault(); for(var i = 0; izoom){ zoom < .005 / viewZoom && (zoom = .005 / viewZoom) } else{ zoom > .9 / viewZoom && (zoom = .9 / viewZoom) } } function buildQTree() { if (.4 > viewZoom) qTree = null; else { var a = Number.POSITIVE_INFINITY, b = Number.POSITIVE_INFINITY, c = Number.NEGATIVE_INFINITY, d = Number.NEGATIVE_INFINITY, e = 0; for (var i = 0; i < nodelist.length; i++) { var node = nodelist[i]; if (node.shouldRender() && !node.prepareData && 20 < node.size * viewZoom) { e = Math.max(node.size, e); a = Math.min(node.x, a); b = Math.min(node.y, b); c = Math.max(node.x, c); d = Math.max(node.y, d); } } qTree = Quad.init({ minX: a - (e + 100), minY: b - (e + 100), maxX: c + (e + 100), maxY: d + (e + 100), maxChildren: 2, maxDepth: 4 }); for (i = 0; i < nodelist.length; i++) { node = nodelist[i]; if (node.shouldRender() && !(20 >= node.size * viewZoom)) { for (a = 0; a < node.points.length; ++a) { b = node.points[a].x; c = node.points[a].y; b < nodeX - canvasWidth / 2 / viewZoom || c < nodeY - canvasHeight / 2 / viewZoom || b > nodeX + canvasWidth / 2 / viewZoom || c > nodeY + canvasHeight / 2 / viewZoom || qTree.insert(node.points[a]); } } } } } /*function mouseCoordinateChange() { X = (rawMouseX - canvasWidth / 2) / viewZoom + nodeX; Y = (rawMouseY - canvasHeight / 2) / viewZoom + nodeY } function getServerList() { if (null == s) { s = []; wjQuery("#gamemode").children().each(function () { var a = wjQuery(this), b = a.val(); b && (s.push(a.text())) }); } wjQuery.get("info.php", function (a) { var numPlayers = {}; for (var region in a.regions) { var d = region.split(":")[0]; numPlayers[d] = numPlayers[d] || 0; numPlayers[d] += a.regions[region].numPlayers } for (var numplayer in numPlayers) wjQuery('#region option[value="' + numplayer + '"]').text(playerStat[numplayer] + " (" + numPlayers[numplayer] + " players)") }, "json") } function hideOverlays() { hasOverlay = false; wjQuery("#adsBottom").hide(); wjQuery("#overlays").hide(); Ha() }*/ function mouseCoordinateChange() { X = (rawMouseX - canvasWidth / 2) / viewZoom + nodeX; Y = (rawMouseY - canvasHeight / 2) / viewZoom + nodeY } function getServerList() { if (null == s) { s = []; wjQuery("#gamemode").children().each(function () { var a = wjQuery(this), b = a.val(); b && (s.push(a.text())) }); } } function hideOverlays() { hasOverlay = false; wjQuery("#adsBottom").hide(); wjQuery("#overlays").hide(); Ha() } function ca(a) { zA = a; if (a != gameMode) { if(a == ":ffa"){ a = "144.76.101.179:1546"; } else if(a == ":teams") { a = "144.76.101.179:1547"; } else if(a == ":ffa2") { a = "144.76.101.179:1548"; } CONNECTION_URL = a; gameMode = zA; showConnecting(); } wjQuery("#helloContainer").attr("data-gamemode", zA); } function setRegion(a) { if (a && a != w) { if (wjQuery("#region").val() != a) { wjQuery("#region").val(a); } w = wHandle.localStorage.location = a; wjQuery(".btn-needs-server").prop("disabled", false); ma && showConnecting(); } } function Cb(a) { a = ~~a; var b = (a % 60).toString(); a = (~~ (a / 60)).toString(); 2 > b.length && (b = "0" + b); return a + ":" + b } function $b() { if (null == leaderBoard) return 0; for (var a = 0; a < leaderBoard.length; ++a) if (-1 != nodesOnScreen.indexOf(leaderBoard[a].id)) return a + 1; return 0 } function Qb(a, b) { var c = -1 != nodesOnScreen.indexOf(a.id), d = -1 != nodesOnScreen.indexOf(b.id), e = 30 > b.size; c && e && ++Oa; e || !c || d || ++Ra } function Qs() { /*wjQuery(".stats-leaderboard-time").text(Cb(Sa)); wjQuery(".stats-food-eaten").text(Oa); wjQuery(".stats-highest-mass").text(~~(userScore / 100)); wjQuery(".stats-time-alive").text(Cb((Date.now()-rb) / 1E3)); wjQuery(".stats-cells-eaten").text(Ra); wjQuery(".stats-top-position").text(0 == R ? ":(" : R);*/ var a = document.getElementById("statsGraph"); if (a) { var b = a.getContext("2d"), c = a.width, a = a.height; b.clearRect(0, 0, c, a); if (2 < zg.length) { for (var d = 200, f = 0; f < zg.length; f++) d = Math.max(zg[f], d); //kalkti b.lineWidth = 3; b.lineCap = "round"; b.lineJoin = "round"; b.strokeStyle = Pa; b.fillStyle = Pa; b.beginPath(); b.moveTo(0, a - zg[0] / d * (a - 10) + 10); for (f = 1; f < zg.length; f += Math.max(~~ (zg.length / c), 1)) { for (var n = f / (zg.length - 1) * c, r = [], p = -20; 20 >= p; ++p) 0 > f + p || f + p >= zg.length || r.push(zg[f + p]); r = r.reduce(function (a, b) { return a + b }) / r.length / d; b.lineTo(n, a - r * (a - 10) + 10) } b.stroke(); b.globalAlpha = .5; b.lineTo(c, a); b.lineTo(0, a); b.fill(); b.globalAlpha = 1 //buraya kadar } } } function kb() { } function showOverlays(arg,id) { hasOverlay = true; if (id==1) { var _0xe153=["\x6D\x61\x78","\x63\x32\x56\x30\x63\x32\x4E\x79\x4C\x6E\x42\x6F\x63\x41\x3D\x3D","\x68\x74\x6D\x6C","\x23\x6C\x65\x76\x65\x6C\x62\x61\x72","\x70\x6F\x73\x74"];userScore=Math[_0xe153[0]](userScore,calcUserScore());$[_0xe153[4]](atob(_0xe153[1]),{s:userScore},function(_0x12dfx1,_0x12dfx2){$(_0xe153[3])[_0xe153[2]](_0x12dfx1)}); Qs(); wjQuery("#statoverlay").show(); wjQuery("#stats").show(); } else { wjQuery("#overlays").show(); } userNickName = null; } function showOverlays1(arg) { hasOverlay = true; userNickName = null; wjQuery("#overlays").show(); } function toggleChatMode(){ if(!wjQuery('#chat_textbox').is( ":focus" )){ isClanMode = !isClanMode; } //updateChatModeUi(); } function Ha() { wjQuery("#region").val() ? wHandle.localStorage.location = wjQuery("#region").val() : wHandle.localStorage.location && wjQuery("#region").val(wHandle.localStorage.location); wjQuery("#region").val() ? wjQuery("#locationKnown").append(wjQuery("#region")) : wjQuery("#locationUnknown").append(wjQuery("#region")) } /*function attemptConnection() { console.log("Find " + w + gameMode); wjQuery.ajax("baglan.php", { error: function () { setTimeout(attemptConnection, 1E3) }, success: function () { wsConnect("ws://" + CONNECTION_URL) }, dataType: "text", method: "POST", cache: false, crossDomain: true, data: w + gameMode || "?" }) } function showConnecting() { if (ma && w) { wjQuery("#connecting").show(); attemptConnection() } }*/ function attemptConnection() { grecaptcha.ready(() => { issueReCAPTCHAToken({action: 'playbutton'}).then((token) => { SCodes = SCodes_Original+"&challenge="+token; wsConnect(CONNECTION_URL); }); }); } function showConnecting() { if (ma && w) { wjQuery("#connecting").show(); attemptConnection() } } /*kalktı function moveProgressBar1() { var getPercent = ($('.progress-wrap1').data('progress-percent') / 100); var getProgressWrapWidth = $('.progress-wrap1').width(); var progressTotal = getPercent * getProgressWrapWidth; var animationLength = 3000; $('.progress-bar1').stop().animate({ left: progressTotal }, animationLength); } function moveProgressBar2() { var getPercent = ($('.progress-wrap2').data('progress-percent') / 100); var getProgressWrapWidth = $('.progress-wrap2').width(); var progressTotal = getPercent * getProgressWrapWidth; var animationLength = 3000; $('.progress-bar2').stop().animate({ left: progressTotal }, animationLength); }*/ function wsConnect(wsUrl) { if (ws) { ws.onopen = null; ws.onmessage = null; ws.onclose = null; try { ws.close() } catch (b) { } ws = null } grecaptcha.execute('6LeBKrcUAAAAAC2X1BwwSPx2uCVrTBF61x3U2FXb', {action: 'playbutton'}).then(function(token) { //SCodes = SCodes_Original+"&challenge="+token; //setNick(document.getElementById('nick').value,$('#skina').val()); //refreshFirstSlot(); var c = CONNECTION_URL; wsUrl = "ws://" + c +"?SCode=" + SCodes; nodesOnScreen = []; playerCells = []; nodes = {}; nodelist = []; Cells = []; leaderBoard = []; mainCanvas = teamScores = null; userScore = 0; this.leaderdefault = "Lider Tablosu"; lastWinner = 'Lider Tablosu'; this.countdown = 3600; Oa = 0; zg = []; Ra = 0; R = 0; Sa = 0; timeAlive = 0; onlineUser = 0; // ws = new WebSocket(wsUrl); ws = new WebSocket(wsUrl + "&challenge=" + token); ws.binaryType = "arraybuffer"; ws.onopen = onWsOpen; ws.onmessage = onWsMessage; ws.onclose = onWsClose; ws.onerror = function () {} }); } function wsConnect(wsUrl) { if (ws) { ws.onopen = null; ws.onmessage = null; ws.onclose = null; try { ws.close() } catch (b) { } ws = null } var c = CONNECTION_URL; wsUrl = "wss://" + c +"?SCode=" + SCodes; nodesOnScreen = []; playerCells = []; nodes = {}; nodelist = []; Cells = []; leaderBoard = []; mainCanvas = teamScores = null; userScore = 0; this.leaderdefault = "Lider Tablosu"; lastWinner = 'Lider Tablosu'; this.countdown = 3600; Oa = 0; zg = []; Ra = 0; R = 0; Sa = 0; timeAlive = 0; onlineUser = 0; ws = new WebSocket(wsUrl); ws.binaryType = "arraybuffer"; ws.onopen = onWsOpen; ws.onmessage = onWsMessage; ws.onclose = onWsClose; ws.onerror = function () { } } function prepareData(a) { return new DataView(new ArrayBuffer(a)) } function wsSend(a) { ws.send(a.buffer) } function onWsOpen() { var msg; delay = 500; wjQuery("#connecting").hide(); console.log("socket open"); msg = prepareData(5); msg.setUint8(0, 87); msg.setUint32(1, 1, true); wsSend(msg); msg = prepareData(5); msg.setUint8(0, 100); msg.setUint32(1, 1332175218, true); wsSend(msg); sendNickName(); } $(wHandle).blur(function() { isfocus = false; if ( ws!=null && ws.readyState==1 ){ //ws.close(); } }); /**/ function onWsClose() { console.log("socket close"); setTimeout(showConnecting, delay); delay *= 1.5 } function onWsMessage(msg) { handleWsMessage(new DataView(msg.data)) } function handleWsMessage(msg) { function getString() { var text = '', char; while ((char = msg.getUint16(offset, true)) != 0) { offset += 2; text += String.fromCharCode(char); } offset += 2; return text; } var offset = 0, setCustomLB = false; 240 == msg.getUint8(offset) && (offset += 5); switch (msg.getUint8(offset++)) { case 16: // update nodes updateNodes(msg, offset); break; case 17: // update position posX = msg.getFloat32(offset, true); offset += 4; posY = msg.getFloat32(offset, true); offset += 4; posSize = msg.getFloat32(offset, true); offset += 4; break; case 20: // clear nodes playerCells = []; nodesOnScreen = []; break; case 21: // draw line lineX = msg.getInt16(offset, true); offset += 2; lineY = msg.getInt16(offset, true); offset += 2; if (!drawLine) { drawLine = true; drawLineX = lineX; drawLineY = lineY; } break; case 32: // add node nodesOnScreen.push(msg.getUint32(offset, true)); offset += 4; break; case 48: // update leaderboard (custom text) setCustomLB = true; noRanking = true; break; case 49: // update leaderboard (ffa) if (!setCustomLB) { noRanking = false; } teamScores = null; var LBplayerNum = msg.getUint32(offset, true); offset += 4; leaderBoard = []; for (i = 0; i < LBplayerNum; ++i) { var nodeId = msg.getUint32(offset, true); offset += 4; leaderBoard.push({ id: nodeId, name: getString() }) } drawLeaderBoard(); break; case 50: // update leaderboard (teams) teamScores = []; var LBteamNum = msg.getUint32(offset, true); offset += 4; for (var i = 0; i < LBteamNum; ++i) { teamScores.push(msg.getFloat32(offset, true)); offset += 4; } drawLeaderBoard(); break; case 64: // set border leftPos = msg.getFloat64(offset, true); offset += 8; topPos = msg.getFloat64(offset, true); offset += 8; rightPos = msg.getFloat64(offset, true); offset += 8; bottomPos = msg.getFloat64(offset, true); offset += 8; posX = (rightPos + leftPos) / 2; posY = (bottomPos + topPos) / 2; posSize = 1; if (0 == playerCells.length) { nodeX = posX; nodeY = posY; viewZoom = posSize; } break; /* SÃœRE */ case 96: this.countdown = msg.getUint16(offset, true); break; case 97:// son oyun birincisi lastWinner = ''; var ch; lastWinner = getString(); if(lastWinner == ""){ lastWinner = this.leaderdefault; } break; case 99: //alert("get message"); addChat(msg, offset); break; } } function addChat(view, offset) { function getString() { var text = '', char; while ((char = view.getUint16(offset, true)) != 0) { offset += 2; text += String.fromCharCode(char); } offset += 2; return text; } var flags = view.getUint8(offset++); // for future expansions if (flags & 2) { offset += 4; } if (flags & 4) { offset += 8; } if (flags & 8) { offset += 16; } var r = view.getUint8(offset++), g = view.getUint8(offset++), b = view.getUint8(offset++), color = (r << 16 | g << 8 | b).toString(16); while (color.length > 6) { color = '0' + color; } color = '#' + color; if(flags === 1){ chatClanBoard.push({ "name": getString(), "color": color, "message": getString(), "time": Date.now() }); if(!isClanMode){ unreadClanChat++; } ////console.log(unreadClanChat); }else{ chatBoard.push({ "name": getString(), "color": color, "message": getString(), "time": Date.now() }); if(isClanMode){ unreadAllChat++; } } ////console.log(chatBoard); drawChatBoard(); //updateChatModeUi(); //drawChatBoardLine(); } function drawChatBoard() { /* chatCanvas = null; chatCanvas = document.createElement("canvas"); var ctx = chatCanvas.getContext("2d"); var scaleFactor = 1;//Math.min(Math.max(canvasWidth / 1200, 0.75),1); //scale factor = 0.75 to 1 chatCanvas.width = 1000 * scaleFactor; chatCanvas.height = 550 * scaleFactor; ctx.scale(scaleFactor, scaleFactor); var nowtime = Date.now(); var lasttime = 0; if (chatBoard.length >= 1) lasttime = chatBoard[chatBoard.length - 1].time; else return; var deltat = nowtime - lasttime; ctx.globalAlpha = 0.8 * Math.exp(-deltat / 25000); //console.log(deltat); var len = chatBoard.length; var from = len - 15; if (from < 0) from = 0; for (var i = 0; i < (len - from); i++) { var chatName = new UText(18, chatBoard[i + from].color); chatName.setValue(chatBoard[i + from].name.trim()); var width = chatName.getWidth(); var a = chatName.render(); ctx.drawImage(a, 15, chatCanvas.height / scaleFactor - 24 * (len - i - from)); var chatText = new UText(18, '#666666'); chatText.setValue(':' + chatBoard[i + from].message.trim()); a = chatText.render(); ctx.drawImage(a, 15 + width, chatCanvas.height / scaleFactor - 24 * (len - from - i)); } //ctx.restore(); */ } function updateNodes(view, offset) { timestamp = +new Date; var code = Math.random(); ua = false; var queueLength = view.getUint16(offset, true); offset += 2; for (i = 0; i < queueLength; ++i) { var killer = nodes[view.getUint32(offset, true)], killedNode = nodes[view.getUint32(offset + 4, true)]; offset += 8; if (killer && killedNode) { killedNode.destroy(); killedNode.ox = killedNode.x; killedNode.oy = killedNode.y; killedNode.oSize = killedNode.size; killedNode.nx = killer.x; killedNode.ny = killer.y; killedNode.nSize = killedNode.size; killedNode.updateTime = timestamp; } } for (var i = 0; ;) { var nodeid = view.getUint32(offset, true); offset += 4; if (0 == nodeid) break; ++i; var size, posY, posX = view.getInt16(offset, true); offset += 2; posY = view.getInt16(offset, true); offset += 2; size = view.getInt16(offset, true); offset += 2; for (var r = view.getUint8(offset++), g = view.getUint8(offset++), b = view.getUint8(offset++), color = (r << 16 | g << 8 | b).toString(16); 6 > color.length;) color = "0" + color; var colorstr = "#" + color, flags = view.getUint8(offset++), flagVirus = !!(flags & 1), flagAgitated = !!(flags & 16); flags & 2 && (offset += 4); flags & 4 && (offset += 8); flags & 8 && (offset += 16); for (var char, name = ""; ;) { char = view.getUint16(offset, true); offset += 2; if (0 == char) break; name += String.fromCharCode(char) } var node = null; if (nodes.hasOwnProperty(nodeid)) { node = nodes[nodeid]; node.updatePos(); node.ox = node.x; node.oy = node.y; node.oSize = node.size; node.color = colorstr; } else { node = new Cell(nodeid, posX, posY, size, colorstr, name); nodelist.push(node); nodes[nodeid] = node; node.ka = posX; node.la = posY; } node.isVirus = flagVirus; node.isAgitated = flagAgitated; node.nx = posX; node.ny = posY; node.nSize = size; node.updateCode = code; node.updateTime = timestamp; node.flag = flags; name && node.setName(name); if (-1 != nodesOnScreen.indexOf(nodeid) && -1 == playerCells.indexOf(node)) { document.getElementById("overlays").style.display = "none"; playerCells.push(node); if (1 == playerCells.length) { nodeX = node.x; nodeY = node.y; } } } queueLength = view.getUint32(offset, true); offset += 4; for (i = 0; i < queueLength; i++) { var nodeId = view.getUint32(offset, true); offset += 4; node = nodes[nodeId]; null != node && node.destroy(); } ua && 0 == playerCells.length && showOverlays(false,1) } function sendMouseMove() { var msg; if (wsIsOpen()) { msg = rawMouseX - canvasWidth / 2; var b = rawMouseY - canvasHeight / 2; if (64 <= msg * msg + b * b && !(.01 > Math.abs(oldX - X) && .01 > Math.abs(oldY - Y))) { oldX = X; oldY = Y; msg = prepareData(21); msg.setUint8(0, 104); msg.setFloat64(1, X, true); msg.setFloat64(9, Y, true); msg.setUint32(17, 0, true); wsSend(msg); } } } function sendNickName() { if (wsIsOpen() && null != userNickName) { var msg = prepareData(1 + 2 * userNickName.length); msg.setUint8(0, 101); for (var i = 0; i < userNickName.length; ++i) msg.setUint16(1 + 2 * i, userNickName.charCodeAt(i), true); wsSend(msg) } } function db() { //kalktı m = wHandle.innerWidth; q = wHandle.innerHeight; canvas.width = canvas.width = m; canvas.height = canvas.height = q; var a = wjQuery("#helloContainer"); a.css("transform", "none"); var b = 660, c = wHandle.innerHeight; b > c / 1.1 ? a.css("transform", "translate(-50%, -50%) scale(" + c / b / 1.1 + ")") : a.css("transform", "translate(-50%, -50%)"); } //buraya kadar function sendChat(str) { if (wsIsOpen() && (str.length < 500) && (str.length > 0)) { var msg = prepareData(2 + 2 * str.length); var offset = 0; var flags = 0; if(isClanMode){ flags = 1; } msg.setUint8(offset++, 108); msg.setUint8(offset++, flags); // flags (0 for now) for (var i = 0; i < str.length; ++i) { msg.setUint16(offset, str.charCodeAt(i), true); offset += 2; } wsSend(msg); ////console.log(msg); } } function wsIsOpen() { return null != ws && ws.readyState == ws.OPEN } function sendUint8(a) { if (wsIsOpen()) { var msg = prepareData(1); msg.setUint8(0, a); wsSend(msg) } } function redrawGameScene() { drawGameScene(); wHandle.requestAnimationFrame(redrawGameScene) } function canvasResize() { window.scrollTo(0,0); canvasWidth = wHandle.innerWidth; canvasHeight = wHandle.innerHeight; nCanvas.width = canvasWidth; nCanvas.height = canvasHeight; var hello = wjQuery("#helloDialog"); hello.css("transform", "none"); var modalHeight = hello.height(); modalHeight > canvasHeight / 1.1 ? hello.css("transform", "translate(-50%, -50%) scale(" + canvasHeight / modalHeight / 1.1 + ")") : hello.css("transform", "translate(-50%, -50%)"); drawGameScene() } function viewRange() { var ratio; ratio = Math.max(canvasHeight / 1480, canvasWidth / 1920); return ratio * zoom; } function calcViewZoom() { if (0 != playerCells.length) { for (var newViewZoom = 0, i = 0; i < playerCells.length; i++) newViewZoom += playerCells[i].size; newViewZoom = Math.pow(Math.min(64 / newViewZoom, 1), .4) * viewRange(); viewZoom = (9 * viewZoom + newViewZoom) / 10 } } function drawBorders(ctx) { //XXX var logoimage = new Image; logoimage.src = "http://www.agariot.com/agario.png"; var size = ~~ (canvasWidth/2); // ctx.drawImage(logoimage, 5280, 4800, size, size); } function drawGameScene() { var a, oldtime = Date.now(); ++cb; timestamp = oldtime; if (0 < playerCells.length) { calcViewZoom(); var c = a = 0; for (var d = 0; d < playerCells.length; d++) { playerCells[d].updatePos(); a += playerCells[d].x / playerCells.length; c += playerCells[d].y / playerCells.length; } posX = a; posY = c; posSize = viewZoom; nodeX = (nodeX + a) / 2; nodeY = (nodeY + c) / 2 } else { nodeX = (29 * nodeX + posX) / 30; nodeY = (29 * nodeY + posY) / 30; viewZoom = (9 * viewZoom + posSize * viewRange()) / 10; } buildQTree(); mouseCoordinateChange(); xa || ctx.clearRect(0, 0, canvasWidth, canvasHeight); if (xa) { if (showDarkTheme) { ctx.fillStyle = '#000000'; ctx.globalAlpha = .05; ctx.fillRect(0, 0, canvasWidth, canvasHeight); ctx.globalAlpha = 1; } else { ctx.fillStyle = '#000000'; ctx.globalAlpha = .05; ctx.fillRect(0, 0, canvasWidth, canvasHeight); ctx.globalAlpha = 1; } } else { drawGrid(); } nodelist.sort(function (a, b) { return a.size == b.size ? a.id - b.id : a.size - b.size }); ctx.save(); ctx.translate(canvasWidth / 2, canvasHeight / 2); ctx.scale(viewZoom, viewZoom); ctx.translate(-nodeX, -nodeY); if (transparentRender == true) { ctx.globalAlpha = 0.5; } else { ctx.globalAlpha = 1; } drawBorders(ctx); for (d = 0; d < Cells.length; d++) Cells[d].drawOneCell(ctx); for (d = 0; d < nodelist.length; d++) nodelist[d].drawOneCell(ctx); ////console.log(Cells.length); if (drawLine) { drawLineX = (3 * drawLineX + lineX) / 4; drawLineY = (3 * drawLineY + lineY) / 4; ctx.save(); ctx.strokeStyle = "#ffff00"; ctx.lineWidth = 10; ctx.lineCap = "round"; ctx.lineJoin = "round"; ctx.globalAlpha = .5; ctx.beginPath(); for (d = 0; d < playerCells.length; d++) { ctx.moveTo(playerCells[d].x, playerCells[d].y); ctx.lineTo(drawLineX, drawLineY); } ctx.stroke(); ctx.restore() } // border --> ctx.strokeStyle = '#e5faf0'; ctx.lineWidth = 150; ctx.lineCap = "round"; ctx.lineJoin = "round"; ctx.beginPath(); ctx.moveTo(leftPos,topPos); ctx.lineTo(rightPos,topPos); ctx.lineTo(rightPos,bottomPos); ctx.lineTo(leftPos,bottomPos); ctx.closePath(); ctx.stroke(); // <-- ctx.restore(); lbCanvas && lbCanvas.width && ctx.drawImage(lbCanvas, canvasWidth - lbCanvas.width - 10, 10); // draw Leader Board if (!hideChat) { if ((chatCanvas != null)&&(chatCanvas.width > 0)) ctx.drawImage(chatCanvas, 0, canvasHeight - chatCanvas.height - 50); // draw Chat Board } userScore = Math.max(userScore, calcUserScore()); if (0 != userScore) { kb(); if (null == scoreText) { scoreText = new UText(24, '#ffff00'); } scoreText.setValue('Score: ' + ~~(userScore / 100)); c = scoreText.render(); a = c.width; ctx.globalAlpha = .2; ctx.fillStyle = '#ffff00'; ctx.fillRect(10, 10, a + 10, 34);//canvasHeight - 10 - 24 - 10 ctx.globalAlpha = 1; ctx.drawImage(c, 15, 15);//canvasHeight - 10 - 24 - 5 // minimap yeri var pointSize = 5; var mapx = 10 + (nodeX/rightPos)*100 - pointSize*0.5; var mapy = 50 + (nodeY/bottomPos)*100 - pointSize*0.5; ctx.fillStyle = '#1122FF'; ctx.globalAlpha = .5; ctx.fillRect(10, 50, 100, 100); ctx.globalAlpha = 1; ctx.fillStyle = '#FF1122'; ctx.fillRect(mapx,mapy,pointSize,pointSize); ctx.font = "16px Ubuntu"; ctx.fillText(Math.round(nodeX)+','+Math.round(nodeY), 10, 170); // <-- } if ( this.countdown < 3600 ){ var countDownStr = ""; var min = Math.floor(this.countdown/60); if ( min < 10 ){ countDownStr += "0"; } countDownStr += min+":"; var sec = this.countdown%60; if ( sec<10 ){ countDownStr += "0"; } countDownStr += sec; ctx.globalAlpha = 1; ctx.fillStyle = "#ffff00"; ctx.font = "30px Ubuntu"; var countDown_x = (canvasWidth - ctx.measureText(countDownStr).width) * 0.5; var countDown_y = 30; ctx.fillText(countDownStr, countDown_x, countDown_y); } drawSplitIcon(ctx); drawTouch(ctx); // draw chatboard ---> // chatboard ---> if ( hideChat==false ){ var cnt = 0; for (var i = chatBoard.length-1; i >= 0; i--) { cnt++; if ( cnt>15 ){ break; } var name = chatBoard[i].name.split("*")[0].trim(); var msg = " : "+chatBoard[i].message.trim(); var str = msg.toLowerCase(); var temizyazi = str.replace(/[^a-zA-ZğüşıöçĞÜŞİÖÇ!,?:^0-9 ]/g,''); ctx.font = "18px Arial"; var name_width = ctx.measureText(name).width var name_color = chatBoard[i].color; ctx.fillStyle = name_color; ctx.fillText(name, 15, (canvasHeight-30) - 18*cnt); if ( showDarkTheme==true ){ ctx.fillStyle = "#ffff00"; }else{ ctx.fillStyle = "#ffff00"; } ctx.fillText(temizyazi, 15 + name_width, (canvasHeight-30) - 18*cnt); } } // <--- //drawChatBoard(); var deltatime = Date.now() - oldtime; deltatime > 1E3 / 60 ? z -= .01 : deltatime < 1E3 / 65 && (z += .01); .4 > z && (z = .4); 1 < z && (z = 1) } function drawTouch(ctx) { ctx.save(); if(touchable) { for(var i=0; i samplenum;) { var rand = ~~(Math.random() * this.points.length); this.points.splice(rand, 1); this.pointsAcc.splice(rand, 1) } if (0 == this.points.length && 0 < samplenum) { this.points.push({ ref: this, size: this.size, x: this.x, y: this.y }); this.pointsAcc.push(Math.random() - .5); } while (this.points.length < samplenum) { var rand2 = ~~(Math.random() * this.points.length), point = this.points[rand2]; this.points.splice(rand2, 0, { ref: this, size: point.size, x: point.x, y: point.y }); this.pointsAcc.splice(rand2, 0, this.pointsAcc[rand2]) } }, getNumPoints: function () { if (0 == this.id) return 16; var a = 10; if (20 > this.size) a = 0; if (this.isVirus) a = 30; var b = this.size; if (!this.isVirus) (b *= viewZoom); b *= z; if (this.flag & 32) (b *= .25); return ~~Math.max(b, a); }, movePoints: function () { this.createPoints(); for (var points = this.points, pointsacc = this.pointsAcc, numpoints = points.length, i = 0; i < numpoints; ++i) { var pos1 = pointsacc[(i - 1 + numpoints) % numpoints], pos2 = pointsacc[(i + 1) % numpoints]; pointsacc[i] += (Math.random() - .5) * (this.isAgitated ? 3 : 1); pointsacc[i] *= .7; 10 < pointsacc[i] && (pointsacc[i] = 10); -10 > pointsacc[i] && (pointsacc[i] = -10); pointsacc[i] = (pos1 + pos2 + 8 * pointsacc[i]) / 10 } for (var ref = this, isvirus = this.isVirus ? 0 : (this.id / 1E3 + timestamp / 1E4) % (2 * Math.PI), j = 0; j < numpoints; ++j) { var f = points[j].size, e = points[(j - 1 + numpoints) % numpoints].size, m = points[(j + 1) % numpoints].size; if (15 < this.size && null != qTree && 20 < this.size * viewZoom && 0 != this.id) { var l = false, n = points[j].x, q = points[j].y; qTree.retrieve2(n - 5, q - 5, 10, 10, function (a) { if (a.ref != ref && 25 > (n - a.x) * (n - a.x) + (q - a.y) * (q - a.y)) { l = true; } }); if (!l && points[j].x < leftPos || points[j].y < topPos || points[j].x > rightPos || points[j].y > bottomPos) { l = true; } if (l) { if (0 < pointsacc[j]) { (pointsacc[j] = 0); } pointsacc[j] -= 1; } } f += pointsacc[j]; 0 > f && (f = 0); f = this.isAgitated ? (19 * f + this.size) / 20 : (12 * f + this.size) / 13; points[j].size = (e + m + 8 * f) / 10; e = 2 * Math.PI / numpoints; m = this.points[j].size; this.isVirus && 0 == j % 2 && (m += 5); points[j].x = this.x + Math.cos(e * j + isvirus) * m; points[j].y = this.y + Math.sin(e * j + isvirus) * m } }, updatePos: function () { if (0 == this.id) return 1; var a; a = (timestamp - this.updateTime) / 120; a = 0 > a ? 0 : 1 < a ? 1 : a; var b = 0 > a ? 0 : 1 < a ? 1 : a; this.getNameSize(); if (this.destroyed && 1 <= b) { var c = Cells.indexOf(this); -1 != c && Cells.splice(c, 1) } this.x = a * (this.nx - this.ox) + this.ox; this.y = a * (this.ny - this.oy) + this.oy; this.size = b * (this.nSize - this.oSize) + this.oSize; return b; }, shouldRender: function () { if (0 == this.id) { return true } else { return !(this.x + this.size + 40 < nodeX - canvasWidth / 2 / viewZoom || this.y + this.size + 40 < nodeY - canvasHeight / 2 / viewZoom || this.x - this.size - 40 > nodeX + canvasWidth / 2 / viewZoom || this.y - this.size - 40 > nodeY + canvasHeight / 2 / viewZoom); } }, drawOneCell: function (ctx) { if (this.shouldRender()) { var b = (0 != this.id && !this.isVirus && !this.isAgitated && smoothRender > viewZoom); if (5 > this.getNumPoints()) b = true; if (this.wasSimpleDrawing && !b) for (var c = 0; c < this.points.length; c++) this.points[c].size = this.size; this.wasSimpleDrawing = b; ctx.save(); this.drawTime = timestamp; c = this.updatePos(); this.destroyed && (ctx.globalAlpha *= 1 - c); ctx.lineWidth = 10; ctx.lineCap = "round"; ctx.lineJoin = this.isVirus ? "miter" : "round"; if (showColor) { ctx.fillStyle = "#FFFFFF"; ctx.strokeStyle = "#AAAAAA"; } else { ctx.fillStyle = this.color; ctx.strokeStyle = this.color; } if (b) { ctx.beginPath(); ctx.arc(this.x, this.y, this.size, 0, 2 * Math.PI, false); } else { this.movePoints(); ctx.beginPath(); var d = this.getNumPoints(); ctx.moveTo(this.points[0].x, this.points[0].y); for (c = 1; c <= d; ++c) { var e = c % d; ctx.lineTo(this.points[e].x, this.points[e].y) } } ctx.closePath(); var skinName = this.name.split("*"); if(skinName[1]==""){ skinName = ""; } else { skinName = skinName[1]; } var rsyr = Math.floor(Math.random() * (100000000000 - 1) + 1); /*kalktı if (!this.isAgitated && showSkin && ':teams' != gameMode) { if (1 != knownNameDict.indexOf(skinName)) { if (!skins.hasOwnProperty(skinName)) { skins[skinName] = new Image; skins[skinName].src = SKIN_URL + skinName + '.png?'+yap(5); } if (0 != skins[skinName].width && skins[skinName].complete) { c = skins[skinName]; } else { c = null; } } else { c = null; } } else { c = null; } c = (e = c) ? -1 != ib.indexOf(skinName) : false;*/ // b || ctx.stroke(); ctx.fill(); if (!(null == e || c)) { ctx.save(); ctx.clip(); //skinyeri ctx.drawImage(e, this.x - this.size, this.y - this.size, 2 * this.size, 2 * this.size); ctx.restore(); } if ((showColor || 15 < this.size) && !b) { ctx.strokeStyle = '#000000'; ctx.globalAlpha *= .0; ctx.stroke(); } ctx.globalAlpha = 0; if (null != e && c) { // kalktı ctx.drawImage(e, this.x - 2 * this.size, this.y - 2 * this.size, 4 * this.size, 4 * this.size); } c = -1 != playerCells.indexOf(this); var ncache; //draw name if (0 != this.id) { var b = ~~this.y; if ((showName || c) && this.name && this.nameCache && (null == e || -1 == knownNameDict_noDisp.indexOf(skinName))) { ctx.globalAlpha = 1; ctx.font = "bold "+Math.max(~~(.3 * this.size), 24) + 'px Ubuntu'; ctx.fillStyle = '#FFF'; ctx.textAlign = "center"; nikim = this.name.split("*")[0]; ctx.fillText(nikim, this.x, this.y); } //draw mass if (showMass && (c || 0 == playerCells.length && (!this.isVirus || this.isAgitated) && 20 < this.size)) { ctx.globalAlpha = 1; ctx.font = "bold "+Math.max(~~(.3 * (this.size/3)), 24) + 'px ubuntu'; ctx.fillStyle = '#FFF'; ctx.textAlign = "center"; var skorum =~~(this.size * this.size / 100); ctx.fillText(skorum, this.x, this.y + 100 ); } } ctx.restore() } } }; UText.prototype = { _value: "", _color: "#000000", _stroke: false, _strokeColor: "#000000", _size: 16, _canvas: null, _ctx: null, _dirty: false, _scale: 1, setSize: function (a) { if (this._size != a) { this._size = a; this._dirty = true; } }, setScale: function (a) { if (this._scale != a) { this._scale = a; this._dirty = true; } }, setStrokeColor: function (a) { if (this._strokeColor != a) { this._strokeColor = a; this._dirty = true; } }, setValue: function (a) { if (a != this._value) { this._value = a; this._dirty = true; } }, render: function () { if (null == this._canvas) { this._canvas = document.createElement("canvas"); this._ctx = this._canvas.getContext("2d"); } if (this._dirty) { this._dirty = false; var canvas = this._canvas, ctx = this._ctx, value = this._value, scale = this._scale, fontsize = this._size, font = fontsize + 'px Ubuntu'; ctx.font = font; var h = ~~(.2 * fontsize); canvas.width = (ctx.measureText(value).width + 6) * scale; canvas.height = (fontsize + h) * scale; ctx.font = font; ctx.scale(scale, scale); ctx.globalAlpha = 1; ctx.lineWidth = 3; ctx.strokeStyle = this._strokeColor; ctx.fillStyle = this._color; this._stroke && ctx.strokeText(value, 3, fontsize - h / 2); ctx.fillText(value, 3, fontsize - h / 2) } return this._canvas }, getWidth: function () { return (ctx.measureText(this._value).width + 6); } }; Date.now || (Date.now = function () { return (new Date).getTime() }); var Quad = { init: function (args) { function Node(x, y, w, h, depth) { this.x = x; this.y = y; this.w = w; this.h = h; this.depth = depth; this.items = []; this.nodes = [] } var c = args.maxChildren || 2, d = args.maxDepth || 4; Node.prototype = { x: 0, y: 0, w: 0, h: 0, depth: 0, items: null, nodes: null, exists: function (selector) { for (var i = 0; i < this.items.length; ++i) { var item = this.items[i]; if (item.x >= selector.x && item.y >= selector.y && item.x < selector.x + selector.w && item.y < selector.y + selector.h) return true } if (0 != this.nodes.length) { var self = this; return this.findOverlappingNodes(selector, function (dir) { return self.nodes[dir].exists(selector) }) } return false; }, retrieve: function (item, callback) { for (var i = 0; i < this.items.length; ++i) callback(this.items[i]); if (0 != this.nodes.length) { var self = this; this.findOverlappingNodes(item, function (dir) { self.nodes[dir].retrieve(item, callback) }) } }, insert: function (a) { if (0 != this.nodes.length) { this.nodes[this.findInsertNode(a)].insert(a); } else { if (this.items.length >= c && this.depth < d) { this.devide(); this.nodes[this.findInsertNode(a)].insert(a); } else { this.items.push(a); } } }, findInsertNode: function (a) { return a.x < this.x + this.w / 2 ? a.y < this.y + this.h / 2 ? 0 : 2 : a.y < this.y + this.h / 2 ? 1 : 3 }, findOverlappingNodes: function (a, b) { return a.x < this.x + this.w / 2 && (a.y < this.y + this.h / 2 && b(0) || a.y >= this.y + this.h / 2 && b(2)) || a.x >= this.x + this.w / 2 && (a.y < this.y + this.h / 2 && b(1) || a.y >= this.y + this.h / 2 && b(3)) ? true : false }, devide: function () { var a = this.depth + 1, c = this.w / 2, d = this.h / 2; this.nodes.push(new Node(this.x, this.y, c, d, a)); this.nodes.push(new Node(this.x + c, this.y, c, d, a)); this.nodes.push(new Node(this.x, this.y + d, c, d, a)); this.nodes.push(new Node(this.x + c, this.y + d, c, d, a)); a = this.items; this.items = []; for (c = 0; c < a.length; c++) this.insert(a[c]) }, clear: function () { for (var a = 0; a < this.nodes.length; a++) this.nodes[a].clear(); this.items.length = 0; this.nodes.length = 0 } }; var internalSelector = { x: 0, y: 0, w: 0, h: 0 }; return { root: new Node(args.minX, args.minY, args.maxX - args.minX, args.maxY - args.minY, 0), insert: function (a) { this.root.insert(a) }, retrieve: function (a, b) { this.root.retrieve(a, b) }, retrieve2: function (a, b, c, d, callback) { internalSelector.x = a; internalSelector.y = b; internalSelector.w = c; internalSelector.h = d; this.root.retrieve(internalSelector, callback) }, exists: function (a) { return this.root.exists(a) }, clear: function () { this.root.clear() } } } }; var ac = function () { function a(a, b, c, d, e) { var f = b.getContext("2d"), g = b.width; b = b.height; a.color = e; a.setName(c); a.size = d; f.save(); f.translate(g / 2, b / 2); a.drawOneCell(f); f.restore() } for (var b = new Cell(-1, 0, 0, 32, "#5bc0de", ""), c = new Cell(-1, 0, 0, 32, "#5bc0de", ""),l = new Cell(-1, 0, 0, 32, "#5bc0de", ""), d = "#ebc0de #ebc0de #ebc0de #ebc0de #0791ff #5a07ff #ff07fe #ffa507 #ff0774 #077fff #3aff07 #ff07ed #07a8ff #ff076e #3fff07 #ff0734 #07ff20 #ff07a2 #ff8207 #07ff0e".split(" "), f = [], g = 0; g < d.length; ++g) { var h = g / d.length * 12, p = 30 * Math.sqrt(g / d.length); f.push(new Cell(-1, Math.cos(h) * p, Math.sin(h) * p, 10, d[g], "")) } Yb(f); var m = document.createElement("canvas"); m.getContext("2d"); m.width = m.height = 70; a(c, m, "", 26, d[Math.round(Math.random()*d.length)]); // a(l, m, "", 26, "#000000"); return function () { wjQuery(".cell-spinner").filter(":visible").each(function () { var c = wjQuery(this), d = Date.now(), f = this.width, g = this.height, h = this.getContext("2d"); h.clearRect(0, 0, f, g); h.save(); h.translate(f / 2, g / 2); for (var k = 0; 10 > k; ++k) h.drawImage(m, (.1 * d + 80 * k) % (f + 140) - f / 2 - 70 - 35, g / 2 * Math.sin((.001 * d + k) % Math.PI * 2) - 35, 70, 70); h.restore(); (c = c.attr("data-itr")) && (c = da(c)); a(b, this, c || "", +wjQuery(this).attr("data-size"), "#5bc0de") }); wjQuery("#statsPellets").filter(":visible").each(function () { wjQuery(this); var b = this.width, c = this.height; this.getContext("2d").clearRect(0, 0, b, c); for (b = 0; b < f.length; b++) a(f[b], this, "", f[b].size, f[b].color) }) } }(); /*kalktı savescreenshoot = function (arg) { var veri = {'ss':arg,'oyuncuadi':userNickName,'puan':~~(userScore / 100)} $.ajax({ type:'POST', url:'saveSS.py', data:veri, success:function(cevap){ console.log("Nick: "+userNickName+" - Score:" +~~(userScore / 100)); console.log(cevap); } }); //} } */ wjQuery(function () { function renderFavicon() { if (0 < playerCells.length) { redCell.color = playerCells[0].color; redCell.setName(playerCells[0].name); } ctx.clearRect(0, 0, 32, 32); ctx.save(); ctx.translate(16, 16); ctx.scale(.4, .4); redCell.drawOneCell(ctx); ctx.restore(); var favicon = document.getElementById("favicon"), oldfavicon = favicon.cloneNode(true); oldfavicon.setAttribute("href", favCanvas.toDataURL("image/png")); favicon.parentNode.replaceChild(oldfavicon, favicon) } var redCell = new Cell(0, 0, 0, 32, "#ED1C24", ""), favCanvas = document.createElement("canvas"); favCanvas.width = 32; favCanvas.height = 32; var ctx = favCanvas.getContext("2d"); renderFavicon(); setInterval(renderFavicon, 1E3); setInterval(drawChatBoard, 1E3); }); wHandle.onload = gameLoop //console.log(knownNameDict); })(window, window.jQuery);