No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

entity.h 1013B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef ENTITY_H
  2. #define ENTITY_H
  3. #include "olcPGEX_Graphics2D.h"
  4. #include "olcPixelGameEngine.h"
  5. #include <cmath>
  6. namespace pabloader {
  7. class Debuggers;
  8. class Entity {
  9. protected:
  10. Debuggers* game;
  11. olc::Sprite* sprite;
  12. olc::GFX2D::Transform2D transform;
  13. olc::vf2d pos;
  14. olc::vf2d vel;
  15. olc::vi2d size;
  16. olc::v2d_generic<uint8_t> tile{ 0, 0 };
  17. olc::v2d_generic<uint8_t> tileDim{ 4, 4 };
  18. float rotation = 0;
  19. float rotationSpeed = 0;
  20. bool alive = true;
  21. #ifdef _DEBUG
  22. olc::Pixel DEBUG_COLOR;
  23. #endif
  24. public:
  25. Entity(Debuggers* game, olc::Sprite* s);
  26. virtual ~Entity(){};
  27. virtual void Update(float dt);
  28. virtual void Draw();
  29. float GetX() { return pos.x; }
  30. float GetY() { return pos.y; }
  31. bool IsInScreen();
  32. bool Collides(Entity* entity);
  33. float Dist(Entity* entity) { return (pos - entity->pos).mag(); }
  34. virtual bool IsActive();
  35. virtual bool IsAlive();
  36. virtual void ResetPosition();
  37. virtual void Kill();
  38. };
  39. }
  40. #endif