public void move() { Vector2 nextDirection = Vector2.add(new Vector2(getHead().getX(), getHead().getY()), _direction); if (nextDirection.x < SNAKE_WIDTH * 2 || nextDirection.x >= _mapWidth - SNAKE_WIDTH * 2 || nextDirection.y < SNAKE_WIDTH * 2 || nextDirection.y >= _mapHeight - SNAKE_WIDTH * 2) { turned(); return; } if (_steps == 0) { turned(); } _steps++; boolean isTurned = false; if (_steps >= SNAKE_WIDTH) { _steps = 0; isTurned = true; } _body.move(isTurned); }