Consider movement direction of head. We're not going to do 50/50s
This commit is contained in:
parent
fcfd6e1e98
commit
d032cf3002
9
index.js
9
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user