Files
fissh/src/Entity.h
2025-07-08 09:30:11 -04:00

43 lines
1.2 KiB
C++

#pragma once
#include <memory>
#include <string>
#include <vector>
struct AssetPair {
std::vector<std::string> image;
std::vector<std::string> 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<std::string> &getImage() const = 0;
virtual const std::vector<std::string> &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<Entity> createReplacement() const { return nullptr; }
virtual int getPreferredLayer() const noexcept = 0;
void draw() const;
};