Tengo un juego basado en agar.io y quiero mejorar está función de modo que el juego vaya más rapido , alguien que de verdad sepa puede hacerlo ?
ARCHIVO COMPLETO POR SI DESEAS VERLO: http://ogar.pw/assets/js/main_out.js
Código (javascript) [Seleccionar]
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.getInt32(offset, true);
offset += 4;
posY = view.getInt32(offset, true);
offset += 4;
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 & 0x01),
flagEjected = !!(flags & 0x20),
flagAgitated = !!(flags & 0x10),
_skin = "";
flags & 2 && (offset += 4);
if (flags & 4) {
for (;;) { // skin name
t = view.getUint8(offset, true) & 0x7F;
offset += 1;
if (0 == t) break;
_skin += String.fromCharCode(t);
}
}
for (var char, name = "";;) { // nick 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, _skin);
nodelist.push(node);
nodes[nodeid] = node;
node.ka = posX;
node.la = posY;
}
node.isVirus = flagVirus;
node.isEjected = flagEjected;
node.isAgitated = flagAgitated;
node.nx = posX;
node.ny = posY;
node.setSize(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)
}
[/i]ARCHIVO COMPLETO POR SI DESEAS VERLO: http://ogar.pw/assets/js/main_out.js