> For the complete documentation index, see [llms.txt](https://redboard.gitbook.io/r-type-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://redboard.gitbook.io/r-type-1/client/ecs/components/create-a-new-component.md).

# Create a new component

Step by step to create a component

Every entities are link to one or many components. The components are the attributes of entities.\
A component don't have a logic, it is use to store data only.

Components are store in the ECS/Components with one component per file, in the namespace ECS/components.

Here an example of a component:

```cpp
namespace ECS {
    namespace components {
        class ParallaxComponent {
            public:
                ParallaxComponent(float scrollSpeed, float backgroundWidth): _scrollSpeed(scrollSpeed), _backgroundWidth(backgroundWidth) {}
                float getScrollSpeed() const { return _scrollSpeed; }
                float getBackgroundWidth() const { return _backgroundWidth; }
                
                void setScrollSpeed(const float &scrollSpeed);
                void setBackgroundWidth(const float &backgroundWidth);

            private:
                float _scrollSpeed;
                float _backgroundWidth;
        };
    }
}
```

It is compose of a constructor with data in argument:

{% code fullWidth="false" %}

```cpp
ParallaxComponent(float scrollSpeed, float backgroundWidth): _scrollSpeed(scrollSpeed), _backgroundWidth(backgroundWidth) {}
```

{% endcode %}

Variable are store in private, and we can access or modify with getter and setter only:

```cpp
float getScrollSpeed() const { return _scrollSpeed; } 
float getBackgroundWidth() const { return _backgroundWidth; }
```

```cpp
void setScrollSpeed(const float &scrollSpeed);
void setBackgroundWidth(const float &backgroundWidth);
```
