Using entities to build characters
So far, we only have entities that define some abstract methods and provide the means of manipulating them, but nothing that can appear in the game world, be rendered, and walk around. At the same time, we don't want to re-implement all of that functionality all over again in the player or enemy classes, which means we need an intermediate-level abstract class: Character
. This class will provide all of the functionality that is shared between all entities that need to move around the world and be rendered. Let's get on with designing:
class Character : public EntityBase{ friend class EntityManager; public: Character(EntityManager* l_entityMgr); virtual ~Character(); void Move(const Direction& l_dir); void Jump(); void Attack(); void GetHurt(const int& l_damage); void Load(const std::string& l_path); virtual void OnEntityCollision( EntityBase* l_collider, bool l_attack) = 0; virtual void Update(float l_dT); void Draw(sf...