R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
Transform.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** RTYPE
4** File description:
5** Transform
6*/
7
8#pragma once
9
10#include "IComponent.hpp"
11
12namespace ecs {
20 class Transform : public IComponent {
21 public:
26 struct Vector2 {
27 float x;
28 float y;
29 };
30
35 Transform() : _position{0.0f, 0.0f}, _rotation(0.0f), _scale{1.0f, 1.0f} {}
36
42 Transform(float posX, float posY) : _position{posX, posY}, _rotation(0.0f), _scale{1.0f, 1.0f} {}
43
52 Transform(float posX, float posY, float rotation, float scaleX, float scaleY)
53 : _position{posX, posY}, _rotation(rotation), _scale{scaleX, scaleY} {}
54
55 ~Transform() override = default;
56
61 Vector2 getPosition() const { return _position; }
62
67 float getRotation() const { return _rotation; }
68
73 Vector2 getScale() const { return _scale; }
74
80 void setPosition(float posX, float posY) {
81 _position.x = posX;
82 _position.y = posY;
83 }
84
89 void setRotation(float rotation) { _rotation = rotation; }
90
96 void setScale(float scaleX, float scaleY) {
97 _scale.x = scaleX;
98 _scale.y = scaleY;
99 }
100
105 ComponentType getType() const override { return getComponentType<Transform>(); }
106
107 private:
109 float _rotation;
111 };
112} // namespace ecs
Base interface for all ECS components.
Component representing position, rotation and scale in 2D space.
Definition Transform.hpp:20
float getRotation() const
Get the rotation angle.
Definition Transform.hpp:67
Vector2 _scale
Scale factors (default: 1, 1)
Transform()
Default constructor. Initializes position to (0, 0), rotation to 0, and scale to (1,...
Definition Transform.hpp:35
void setRotation(float rotation)
Set the rotation angle.
Definition Transform.hpp:89
Vector2 _position
Entity position in world space.
void setScale(float scaleX, float scaleY)
Set the scale factors.
Definition Transform.hpp:96
Vector2 getPosition() const
Get the position vector.
Definition Transform.hpp:61
Transform(float posX, float posY)
Constructor with position only.
Definition Transform.hpp:42
ComponentType getType() const override
Get the component type ID.
~Transform() override=default
Vector2 getScale() const
Get the scale vector.
Definition Transform.hpp:73
Transform(float posX, float posY, float rotation, float scaleX, float scaleY)
Full constructor with all parameters.
Definition Transform.hpp:52
void setPosition(float posX, float posY)
Set the position.
Definition Transform.hpp:80
float _rotation
Rotation angle in degrees.
Maximum number of distinct component types supported by the Registry.
Definition GameLogic.hpp:26
std::size_t ComponentType
Type alias for component identification.
2D vector structure for positions and scales.
Definition Transform.hpp:26
float x
X coordinate.
Definition Transform.hpp:27
float y
Y coordinate.
Definition Transform.hpp:28