StarShip.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // Created by jovian on 17/08/17.
  3. //
  4. #ifndef SPACEEXPANSION_STARSHIP_H
  5. #define SPACEEXPANSION_STARSHIP_H
  6. #include "../Maths/b2_math.h"
  7. #include "../Graphics/Visual.h"
  8. #include "Stock.h"
  9. #define NO_TARGET_PLANET -1
  10. enum ShipMotor {
  11. GAZ = 0, ION = 1, LASER = 2, ANTIMATER = 3, GRAVITY = 4, ALCUBIERRE = 5, HYPERDRIVE = 6
  12. };
  13. struct StarShipDef {
  14. StarShipDef() : motor(GAZ), cargo(10), militaryPower(0), stock(),
  15. pos(0.0f, 0.0f) {};
  16. ShipMotor motor;
  17. int cargo;
  18. int militaryPower;
  19. Stock stock;
  20. b2Vec2 pos;
  21. };
  22. class StarShip {
  23. // Methods
  24. public:
  25. StarShip(const StarShipDef &def);
  26. virtual ~StarShip();
  27. Visual *makeVisual();
  28. void update();
  29. Stock unload();
  30. void load(Stock stock);
  31. void travelTo(int targetPlanet, b2Vec2 targetPos);
  32. bool isArrived() const;
  33. int getTargetPlanet() const;
  34. const StarShipDef &getDef() const;
  35. // Attributes
  36. private:
  37. StarShipDef m_def;
  38. float m_angle;
  39. int m_targetPlanet;
  40. b2Vec2 m_targetPos;
  41. bool m_arrived;
  42. };
  43. #endif //SPACEEXPANSION_STARSHIP_H