Game.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef GAME_H
  2. #define GAME_H
  3. #include <vector>
  4. #include <deque>
  5. #include "input/Keys.h"
  6. #include "rendering/Renderer.h"
  7. class Game final {
  8. public:
  9. Game(Keys& control);
  10. void tick();
  11. void render(float lag, Renderer& renderer) const;
  12. bool isRunning() const;
  13. private:
  14. struct Point {
  15. bool operator<(const Point& other);
  16. float x;
  17. float y;
  18. };
  19. bool isLowerTangent(const Point& a, const Point& b, const std::vector<Point>& hull) const;
  20. bool isUpperTangent(const Point& a, const Point& b, const std::vector<Point>& hull) const;
  21. void findLowerTangent(const std::vector<Point>& hullA, const std::vector<Point>& hullB, int& a, int& b) const;
  22. void findUpperTangent(const std::vector<Point>& hullA, const std::vector<Point>& hullB, int& a, int& b) const;
  23. int findMaxX(const std::vector<Point>& hull) const;
  24. int findMinX(const std::vector<Point>& hull) const;
  25. void split();
  26. float det(const Point& a, const Point& b, const Point& c) const;
  27. void merge();
  28. Keys& keys;
  29. int keyNext;
  30. std::vector<Point> data;
  31. std::vector<Point> convexHull;
  32. int active;
  33. std::deque<std::vector<Point>> groups[2];
  34. };
  35. #endif