# GraphicComponents

### SpriteComponent

This component encapsulates an SFML sprite, allowing entities to have a visual representation.

```cpp
class SpriteComponent {
public:
    sf::Sprite sprite; ///< The SFML sprite object.
};
```

### PosComponent

This component stores the x and y coordinates, representing the position of an entity in the game world.

```cpp
class PosComponent {
public:
    /**
     * @brief Construct a new Position Component object with default coordinates.
     * 
     * @param defaultX The default x-coordinate.
     * @param defaultY The default y-coordinate.
     */
    PosComponent(double defaultX = 0, double defaultY = 0) : coord(defaultX, defaultY) {}

    /**
     * @brief Construct a new Position Component object with a vector.
     * 
     * @param vec A vector containing the x and y coordinates.
     */
    explicit PosComponent(const Utils::Vec2& vec) : coord(vec) {}

    Utils::Vec2 coord; ///< The coordinates of the entity.
};
```

### ScaleComponent

This component stores the scale factors along the x and y axes.

```cpp
class ScaleComponent {
public:
    /**
     * @brief Construct a new Scale Component object with vector scaling.
     * 
     * @param v A vector containing the scale factors for x and y axes.
     */
    ScaleComponent(Utils::Vec2 v = {1, 1}) : scale(v) {};

    /**
     * @brief Construct a new Scale Component object with individual scale factors.
     * 
     * @param x Scale factor along the x-axis.
     * @param y Scale factor along the y-axis.
     */
    explicit ScaleComponent(float x = 1, float y = 1) : scale(x, y) {};

    Utils::Vec2 scale; ///< The scale factors of the entity.
};
```

### AnimationComponent

This component stores animation-related data, such as the current step, maximum steps, and the speed of the animation.

```cpp
class AnimationComponent {
public:
    /**
     * @brief Construct a new Animation Component object.
     * 
     * @param step The initial step of the animation.
     * @param maxStep The maximum step of the animation.
     * @param animationSpeed The speed of the animation.
     */
    AnimationComponent(int step, int maxStep, float animationSpeed)
        : step_value(step), max_step(maxStep), animation_speed(animationSpeed), last_step(0) {}

    int step_value; ///< The current step of the animation.
    int max_step; ///< The maximum step of the animation.
    int animation_speed; ///< The speed of the animation.
    int last_step; ///< The last step of the animation that was processed.
    std::chrono::high_resolution_clock::time_point last_animation_step_time; ///< The time point of the last animation step.
    sf::IntRect textureRect; ///< The texture rectangle for the sprite sheet.
};
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://r-type-5.gitbook.io/r-type/development-guidelines/ecs/graphic/graphiccomponents.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
