Dead snakes are gray
This commit is contained in:
+4
-5
@@ -20,8 +20,9 @@ function ellipse(cx, cy, rx, ry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function drawPlayer(ratio, p) {
|
function drawPlayer(ratio, p) {
|
||||||
ctx.fillStyle = p.color;
|
ctx.fillStyle = p.alive ? p.color : '#757575';
|
||||||
ctx.fillText(p.name, p.pos.x, p.pos.y - ratio * 10);
|
ctx.fillText(p.name, p.pos.x, p.pos.y - ratio * 10);
|
||||||
|
if (p.alive) {
|
||||||
ellipse(p.pos.x, p.pos.y, ratio * 3, ratio * 3);
|
ellipse(p.pos.x, p.pos.y, ratio * 3, ratio * 3);
|
||||||
if (p.starting > 0)
|
if (p.starting > 0)
|
||||||
return;
|
return;
|
||||||
@@ -35,10 +36,9 @@ function drawPlayer(ratio, p) {
|
|||||||
history[p.name].list[history[p.name].i0] = p.pos;
|
history[p.name].list[history[p.name].i0] = p.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawHistory(p) {
|
|
||||||
if (history[p.name]) {
|
if (history[p.name]) {
|
||||||
const h = history[p.name];
|
const h = history[p.name];
|
||||||
ctx.strokeStyle = p.color;
|
ctx.strokeStyle = p.alive ? p.color : '#757575';
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
if(!h.list[h.i0])
|
if(!h.list[h.i0])
|
||||||
return;
|
return;
|
||||||
@@ -63,6 +63,7 @@ function drawHistory(p) {
|
|||||||
}
|
}
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawGame() {
|
function drawGame() {
|
||||||
@@ -86,11 +87,9 @@ function drawGame() {
|
|||||||
const names = Object.keys(players);
|
const names = Object.keys(players);
|
||||||
names.forEach(function (name) {
|
names.forEach(function (name) {
|
||||||
const p = players[name];
|
const p = players[name];
|
||||||
if(p.alive)
|
|
||||||
drawPlayer(ratio, players[name]);
|
drawPlayer(ratio, players[name]);
|
||||||
if (name === current.name)
|
if (name === current.name)
|
||||||
current = players[name];
|
current = players[name];
|
||||||
drawHistory(players[name]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
requestAnimationFrame(drawGame);
|
requestAnimationFrame(drawGame);
|
||||||
|
|||||||
Reference in New Issue
Block a user