1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #ifndef GAME_H
- #define GAME_H
- #include <vector>
- #include <deque>
- #include "input/Keys.h"
- #include "rendering/Renderer.h"
- struct Point {
- bool operator<(const Point& other) const;
- float distance(const Point& other) const;
-
- float x;
- float y;
- };
- class Game final {
- public:
- Game(Keys& control, const char* file, bool steps);
- void tick();
- void render(float lag, Renderer& renderer) const;
- bool isRunning() const;
- private:
- enum State {
- SPLIT, MERGE, FIND_LOWER_TANGENT, FIND_UPPER_TANGENT, FINALIZE_MERGE, END
- };
- bool isLowerTangent(const std::vector<Point>& hull) const;
- bool isUpperTangent(const std::vector<Point>& hull) const;
- bool findLowerTangent();
- bool findUpperTangent();
- int findMaxX(const std::vector<Point>& hull) const;
- int findMinX(const std::vector<Point>& hull) const;
- float det(const Point& a, const Point& b, const Point& c) const;
- void split();
- bool merge();
- void finalizeMerge();
- void next();
- void renderGroup(Renderer& renderer, const std::vector<Point>& hull, uint color) const;
- void skip();
- float normalizeX(float f) const;
- float normalizeY(float f) const;
- Keys& keys;
- int keyNext;
- std::vector<Point> data;
- std::vector<Point> convexHull;
- int active;
- std::deque<std::vector<Point>> groups[2];
- State state;
- std::vector<Point> hullA;
- std::vector<Point> hullB;
- int lowerIndexA;
- int lowerIndexB;
- int upperIndexA;
- int upperIndexB;
- float minX;
- float maxX;
- float minY;
- float maxY;
- };
- #endif
|