diff --git a/index.js b/index.js index b410410..1f7189d 100644 --- a/index.js +++ b/index.js @@ -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; }