> For the complete documentation index, see [llms.txt](https://azuriohs-organization.gitbook.io/r-type/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://azuriohs-organization.gitbook.io/r-type/transform-components/position.md).

# Position

The Position component represents the 2D coordinates of an entity.

It provides a clean and simple API to manage the X and Y position of any object in your game world.

### Class Overview

```cpp
class Position {
public:
    using PositionType = std::pair<float, float>;

    Position(float x, float y);

    float GetX() const;
    float GetY() const;

    void SetX(float x);
    void SetY(float y);
    void Set(float x, float y);

    PositionType GetPosition() const;

private:
    PositionType _position;
};
```

### 🏠 Constructor

***

Creates a new Position component with the given x and y coordinates.

```cpp
Components::Position pos(100.f, 200.f);
```

### 🐝 Getters

***

float GetX() const

Returns the x coordinate.

```cpp
float x = pos.GetX();
```

float GetY() const

Returns the y coordinate.

```cpp
float y = pos.GetY();
```

### 🧀 Setters

***

void SetX(float x)

Updates only the x coordinate.

```cpp
pos.SetX(150.f);
```

void SetY(float y)

Updates only the y coordinate.

```cpp
pos.SetY(300.f);
```

void Set(float x, float y)

Updates both coordinates at once.

```cpp
pos.Set(500.f, 400.f);
```
