50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
/********************\
|
|
| Copyright 2024, |
|
|
| Ulysse Cura |
|
|
\********************/
|
|
|
|
////////////////////////////////////////////////////
|
|
// //
|
|
// Composant de transformation, sert a donner //
|
|
// une position, dimension, etc... à une entitée. //
|
|
// //
|
|
////////////////////////////////////////////////////
|
|
|
|
#ifndef TRANSFORM_HPP
|
|
#define TRANSFORM_HPP
|
|
|
|
#include "ECS.hpp"
|
|
#include "../Vector2D.hpp"
|
|
|
|
struct TransformComponent : public Component {
|
|
TransformComponent()
|
|
{
|
|
position.zero();
|
|
}
|
|
|
|
TransformComponent(Vector2D<float> pos, Vector2D<int> dim, int sc, float spd) : position(pos), speed(spd), dimension(dim), scale(sc)
|
|
{}
|
|
|
|
void init() override
|
|
{
|
|
velocity.zero();
|
|
}
|
|
|
|
void update() override
|
|
{
|
|
position += (velocity * speed);
|
|
|
|
entity->draw_priority = static_cast<int>(position.y + static_cast<float>(dimension.y * scale));
|
|
}
|
|
|
|
Vector2D<float> position;
|
|
|
|
Vector2D<float> velocity;
|
|
float speed {1};
|
|
|
|
Vector2D<int> dimension {32, 32};
|
|
int scale {1};
|
|
};
|
|
|
|
#endif
|