#pragma once #include #include #include struct AssetPair { std::vector image; std::vector mask; }; class Entity { protected: const bool moving_right; float x; float y; static inline size_t next_id = 0; const size_t entity_id; virtual const std::vector &getImage() const = 0; virtual const std::vector &getMask() const = 0; virtual char getDefaultColor() const noexcept = 0; public: Entity() : moving_right(false), x(0.0f), y(0.0f), entity_id(++next_id) {} Entity(bool moving_right) : moving_right(moving_right), x(0.0f), y(0.0f), entity_id(++next_id) {} Entity(float init_x, float init_y) : moving_right(false), x(init_x), y(init_y), entity_id(++next_id) {} virtual ~Entity() = default; float getX() const noexcept { return x; } float getY() const noexcept { return y; } virtual int getWidth() const noexcept { return getImage()[0].length(); } size_t getId() const noexcept { return entity_id; } virtual void update() noexcept = 0; virtual bool shouldBeRemoved() const noexcept; virtual std::unique_ptr createReplacement() const { return nullptr; } virtual int getPreferredLayer() const noexcept = 0; void draw() const; };