finish mirroring. abstract entity removal

This commit is contained in:
user
2025-07-07 17:25:29 -04:00
parent 5706c90f87
commit c54089ae19
17 changed files with 193 additions and 231 deletions

View File

@@ -10,33 +10,33 @@ struct AssetPair {
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<std::string> &getImage() const = 0;
virtual const std::vector<std::string> &getMask() const = 0;
virtual char getDefaultColor() const noexcept = 0;
public:
Entity() : x(0.0f), y(0.0f), entity_id(++next_id) {}
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)
: x(init_x), y(init_y), entity_id(++next_id) {}
: 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 size_t getWidth() const noexcept { return getImage()[0].length(); }
size_t getId() const noexcept { return entity_id; }
virtual void update() noexcept = 0;
virtual const std::vector<std::string> &getImage() const = 0;
virtual const std::vector<std::string> &getMask() const = 0;
virtual char getDefaultColor() const noexcept = 0;
virtual bool shouldBeRemoved() const noexcept;
virtual std::unique_ptr<Entity> createReplacement() const { return nullptr; }
virtual int getPreferredLayer() const noexcept = 0;
void draw() const;
protected:
// Helper function to get the maximum width of any row in an image
static size_t getMaxRowWidth(const std::vector<std::string> &image) noexcept;
};