20#define M_PI 3.14159265358979323846
45 (velocity !=
nullptr) && (rect !=
nullptr))
48 float angle = std::atan2(velocity->y, velocity->x);
49 if (std::abs(velocity->x) < 0.1f && std::abs(velocity->y) < 0.1f)
57 angle += 2.0f * std::numbers::pi_v<float>;
59 if (angle >= 0 && angle <
M_PI / 4)
63 else if (angle >=
M_PI / 4 && angle < 3 *
M_PI / 4)
67 else if (angle >= 3 *
M_PI / 4 && angle < 5 *
M_PI / 4)
71 else if (angle >= 5 *
M_PI / 4 && angle < 7 *
M_PI / 4)
83 int frame_x = (frame % frames_per_row) * frame_width;
84 int frame_y = (frame / frames_per_row) * frame_height;
87 frame_y += skin_offset;
89 rect->pos_x =
static_cast<float>(frame_x);
90 rect->pos_y =
static_cast<float>(frame_y);
91 rect->size_x = frame_width;
92 rect->size_y = frame_height;
This file contains the component definitions.
Configuration constants for the multiplayer game.
This file contains the interface for systems.
This file contains the Registry class declaration.
Abstract class for system.
Class for managing entities and their components.
std::unordered_map< Entity, T > & getAll()
T * getComponent(Entity e)
~PlayerDirectionSystem() override=default
PlayerDirectionSystem(PlayerDirectionSystem &&)=delete
PlayerDirectionSystem(const PlayerDirectionSystem &)=delete
void update(ecs::Registry ®istry, float) override
PlayerDirectionSystem & operator=(PlayerDirectionSystem &&)=delete
PlayerDirectionSystem(const int skinIndex)
PlayerDirectionSystem & operator=(const PlayerDirectionSystem &)=delete
This file contains common definitions and constants.
constexpr float SPRITE_HEIGHT
constexpr float SPRITE_WIDTH
constexpr int FRAMES_PER_ROW