16#define M_PI 3.14159265358979323846
43 float angle = std::atan2(velocity->y, velocity->x);
44 if (std::abs(velocity->x) < 0.1f && std::abs(velocity->y) < 0.1f)
49 angle += 2.0f *
static_cast<float>(
M_PI);
50 if (angle >= 0 && angle <
M_PI / 4)
52 else if (angle >=
M_PI / 4 && angle < 3 *
M_PI / 4)
54 else if (angle >= 3 *
M_PI / 4 && angle < 5 *
M_PI / 4)
56 else if (angle >= 5 *
M_PI / 4 && angle < 7 *
M_PI / 4)
63 int frame_x = (frame % frames_per_row) * frame_width;
64 int frame_y = (frame / frames_per_row) * frame_height;
66 rect->pos_x =
static_cast<float>(frame_x);
67 rect->pos_y =
static_cast<float>(frame_y);
68 rect->size_x = frame_width;
69 rect->size_y = frame_height;
This file contains the component definitions.
Configuration constants for the game.
This file contains the Registry class declaration.
PlayerDirectionSystem(PlayerDirectionSystem &&)=delete
PlayerDirectionSystem(const PlayerDirectionSystem &)=delete
void update(ecs::Registry ®istry, float) override
PlayerDirectionSystem & operator=(PlayerDirectionSystem &&)=delete
~PlayerDirectionSystem() override=default
PlayerDirectionSystem & operator=(const PlayerDirectionSystem &)=delete
PlayerDirectionSystem()=default
Class for managing entities and their components.
std::unordered_map< Entity, T > & getAll()
T * getComponent(Entity e)
constexpr float SPRITE_WIDTH
constexpr int FRAMES_PER_ROW
constexpr float SPRITE_HEIGHT