public void GetInput() { if (direction != HeadedDirections.LEFT && Input.IsActionPressed("ui_right")) { _velocity.x = MOVE_STEP; _velocity.y = 0; direction = HeadedDirections.RIGHT; } if (direction != HeadedDirections.RIGHT && Input.IsActionPressed("ui_left")) { _velocity.x = -MOVE_STEP; _velocity.y = 0; direction = HeadedDirections.LEFT; } if (direction != HeadedDirections.DOWN && Input.IsActionPressed("ui_up")) { _velocity.y = -MOVE_STEP; _velocity.x = 0; direction = HeadedDirections.UP; } if (direction != HeadedDirections.UP && Input.IsActionPressed("ui_down")) { _velocity.y = MOVE_STEP; _velocity.x = 0; direction = HeadedDirections.DOWN; } }
public override void _Ready() { // Set snake to move up by default _velocity = new Vector2(0, -MOVE_STEP); _previousMoveTimeLimit = _moveTimeLimit; direction = HeadedDirections.UP; }