暫無描述
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 951B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. float x, y;
  14. float xv = 0, yv = 0;
  15. int w, h;
  16. uint8_t tileX = 0;
  17. uint8_t tileY = 0;
  18. uint8_t tileCols = 4;
  19. uint8_t tileRows = 4;
  20. float rotation = 0;
  21. float rotationSpeed = 0;
  22. #ifdef _DEBUG
  23. olc::Pixel DEBUG_COLOR;
  24. #endif
  25. public:
  26. Entity(Debuggers* game, olc::Sprite* s);
  27. virtual ~Entity(){};
  28. virtual void Update(float dt);
  29. virtual void Draw();
  30. float GetX() { return x; }
  31. float GetY() { return y; }
  32. bool Collides(Entity* entity);
  33. float Dist(Entity* entity) { return std::hypot(x - entity->x, y - entity->y); }
  34. virtual bool IsActive();
  35. virtual void ResetPosition();
  36. virtual void Kill();
  37. };
  38. }
  39. #endif