wallCollision: function(head) { if (head.x >= 600) { head.x -= 600; } else if (head.x < 0) { head.x += 600; } if (head.y >= 450) { head.y -= 450; } else if (head.y < 0) { head.y += 450; } }