From 2b0c3fc169a6e00a6d39e13be25a94b7a022a4dc Mon Sep 17 00:00:00 2001 From: Bendi Date: Sun, 28 Nov 2021 01:12:56 +0100 Subject: [PATCH] Added entities and updated Character class --- include/entity/character.h | 25 ++++++++++++++++--- .../entity/{controlable.h => controllable.h} | 4 ++- include/entity/drawable_handler.h | 4 +-- include/entity/entity.h | 24 ++++++++++++++++++ include/entity/physical_entity.h | 20 +++++++-------- include/entity/schedulable.h | 18 +++---------- include/entity/wall.h | 2 +- 7 files changed, 64 insertions(+), 33 deletions(-) rename include/entity/{controlable.h => controllable.h} (81%) create mode 100644 include/entity/entity.h diff --git a/include/entity/character.h b/include/entity/character.h index 545c3ab..5a77bb0 100644 --- a/include/entity/character.h +++ b/include/entity/character.h @@ -4,18 +4,35 @@ #include "drawable_handler.h" #include "physical_entity.h" #include "schedulable.h" +#include + +// dependencies +class Hitbox{ /* Stuff with hitboxes */ }; + class Character : Controllable, DrawableHandler, PhysicalEntity, Schedulable { private: - /* data */ -public: - virtual void sendEvent( sf::Event e ); - + std::vector attackHitbox; + Hitbox damageHitbox; + + +public: Character(/* args */); ~Character(); + + virtual void sendEvent( sf::Event e ); + + + float maxLife; + float currentLife; + float strength; + float speed; + float jumpHeight; + + }; Character::Character(/* args */) diff --git a/include/entity/controlable.h b/include/entity/controllable.h similarity index 81% rename from include/entity/controlable.h rename to include/entity/controllable.h index ff83146..2af85a5 100644 --- a/include/entity/controlable.h +++ b/include/entity/controllable.h @@ -1,9 +1,11 @@ #ifndef CONTROLLABLE_H #define CONTROLLABLE_H +#include "entity.h" #include -class Controllable + +class Controllable : public virtual Entity { private: diff --git a/include/entity/drawable_handler.h b/include/entity/drawable_handler.h index 41e0e42..cc066ef 100644 --- a/include/entity/drawable_handler.h +++ b/include/entity/drawable_handler.h @@ -1,11 +1,11 @@ #ifndef DRAWABLE_HANDLER #define DRAWABLE_HANDLER - +#include "entity.h" #include #include #include -class DrawableHandler : public sf::Drawable { +class DrawableHandler : public sf::Drawable, public virtual Entity { private: std::vector toDraw; virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const { diff --git a/include/entity/entity.h b/include/entity/entity.h new file mode 100644 index 0000000..37df772 --- /dev/null +++ b/include/entity/entity.h @@ -0,0 +1,24 @@ +#ifndef ENTITY_H +#define ENTITY_H + +class Entity +{ +private: + +public: + Entity(); + ~Entity(); +}; + +Entity::Entity() +{ +} + +Entity::~Entity() +{ +} + + + + +#endif \ No newline at end of file diff --git a/include/entity/physical_entity.h b/include/entity/physical_entity.h index fdeeb4a..68f0ffd 100644 --- a/include/entity/physical_entity.h +++ b/include/entity/physical_entity.h @@ -1,25 +1,23 @@ #ifndef PHYSICAL_ENTITY #define PHYSICAL_ENTITY -#include +#include "entity.h" #include -typedef struct -{ - /* collider stuff ( e.g. linked list of vertex) */ -} Collider; - +class Hitbox{}; -class PhysicalEntity +class PhysicalEntity : public sf::Transformable { private: - Collider bndBox; + Hitbox physicalHitbox; + + public: virtual void updatePhysics(); //here some kind of phx::PhysicsHandler; - void getCollider(); - void setCollider(Collider newCollider); - + Hitbox getHitbox(); + void setHitbox(Hitbox newHitbox); + PhysicalEntity(/* args */); ~PhysicalEntity(); }; diff --git a/include/entity/schedulable.h b/include/entity/schedulable.h index 3c36e39..10920cc 100644 --- a/include/entity/schedulable.h +++ b/include/entity/schedulable.h @@ -1,31 +1,21 @@ #ifndef SCHEDULABLE.H #define SCHEDULABLE.H +#include "entity.h" #include #include #include -class Schedulable +class Schedulable : public virtual Entity { private: std::multimap > actions; // actions to do at a given frame (contains a frame and a function to call) - // Maybe a Circular buffer would be better ? + public: - void update(int frame) - /* - { - - if(actions.count(frame) > 0){ - - for(std::function currentAction : (actions.find(frame)) ){ - - } - } - - } */; // call this one each frame + void update(int frame); void addAction(int frame, std::function action); diff --git a/include/entity/wall.h b/include/entity/wall.h index dc5f7ab..2dd897f 100644 --- a/include/entity/wall.h +++ b/include/entity/wall.h @@ -8,7 +8,7 @@ class Wall: DrawableHandler, PhysicalEntity { private: - /* data */ + public: Wall(/* args */); ~Wall();