Entity.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // Created by jovian on 18/07/17.
  3. //
  4. #ifndef TINYSHOOTER_ENTITY_H
  5. #define TINYSHOOTER_ENTITY_H
  6. #include <box2d/box2d.h>
  7. #include <vector>
  8. #include "../Graphics/Visual.h"
  9. enum Faction {WALL, BULLET, ALLY, FOE};
  10. /* class Entity :
  11. * Store interactive data of a game object.
  12. */
  13. class Entity {
  14. /// Methods :
  15. public :
  16. Entity(Faction faction, unsigned int imgId, b2World* physics);
  17. virtual ~Entity();
  18. virtual void update() = 0; // Update physical and game entity
  19. virtual Visual* makeVisual(); // Generate graphical description
  20. bool isExist() const;
  21. bool isTouching() const;
  22. b2Vec2 getPos() const;
  23. Faction getFaction() const;
  24. void setExistence(bool exist);
  25. protected:
  26. void establishPhysicalLink(); // Put entity data in body's user-data
  27. /// Variables :
  28. protected:
  29. Faction m_faction; // Allows identification in TinyWorld
  30. bool m_exist; // Entity is destroyed if set to false
  31. b2World* m_physics; // Link to physic world
  32. b2Body* m_body; // Link to physic world
  33. unsigned int m_imgId; // Current picture id
  34. };
  35. #endif //TINYSHOOTER_ENTITY_H