Consider movement direction of head. We're not going to do 50/50s

This commit is contained in:
sigonasr2, Sig, Sigo 2022-08-16 12:42:18 +00:00
parent fcfd6e1e98
commit d032cf3002

View File

@ -172,6 +172,15 @@ snake.onTick = function(obj) { // When the game updates
return false;
}
}
for (var player in obj.players) {
if (player !== "sigonasr2") {
var head = obj.players[player].head
var dir = obj.players[player].direction
if (head[0]+(dir===LEFT?1:dir===RIGHT?-1:0)===newCoords[0]&&head[1]+(dir===DOWN?1:dir===UP?-1:0)===newCoords[1]) {
return false
}
}
}
if (newCoords[0] < 0 || newCoords[0] > 149 || newCoords[1] < 0 || newCoords[1] > 149) {
return false;
}