32 void setEnable(
bool enable)
override { (void)enable; }
36 std::vector<ecs::Entity> asteroidsToRemove;
47 if (!transform || !velocity || !rect || !texture || !scale || !animation)
50 animation->current_time += dt;
51 if (animation->current_time >= animation->frame_duration)
53 animation->current_time = 0.0f;
54 animation->current_frame = (animation->current_frame + 1) % animation->total_frames;
58 const int frame_y = 0;
59 rect->pos_x =
static_cast<float>(frame_x);
60 rect->pos_y =
static_cast<float>(frame_y);
63 transform->
x += velocity->
x * dt;
64 transform->y += velocity->
y * dt;
65 transform->rotation += asteroid.rotation_speed * dt;
68 std::round(transform->x), std::round(transform->y), scale->x, scale->y,
69 static_cast<int>(rect->pos_x),
static_cast<int>(rect->pos_y),
70 static_cast<int>(rect->size_x),
static_cast<int>(rect->size_y));
77 asteroidsToRemove.push_back(entity);
This file contains the component definitions.
Configuration constants for the game.
This file contains the IRenderer class declaration.
This file contains the Registry class declaration.
AsteroidSystem(const AsteroidSystem &)=delete
AsteroidSystem(AsteroidSystem &&)=delete
eng::IRenderer & m_renderer
~AsteroidSystem() override=default
void setEnable(bool enable) override
void update(ecs::Registry ®istry, float dt) override
AsteroidSystem & operator=(AsteroidSystem &&)=delete
AsteroidSystem(eng::IRenderer &renderer)
AsteroidSystem & operator=(const AsteroidSystem &)=delete
Class for managing entities and their components.
bool hasComponent(Entity e)
std::unordered_map< Entity, T > & getAll()
T * getComponent(Entity e)
void removeComponent(Entity e)
Interface for the renderer.
virtual void drawSprite(const std::string &name)=0
virtual void createSprite(const std::string &name, const std::string &textureName, float x, float y, float scale_x=1, float scale_y=1, int fx=0, int fy=0, int fnx=-1, int fny=-1)=0
constexpr float SPRITE_WIDTH
constexpr float REMOVE_MIN_Y
constexpr float REMOVE_MAX_Y