Game.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef GAME_H
  2. #define GAME_H
  3. #include "client/input/Control.h"
  4. #include "client/utils/Clock.h"
  5. #include "client/rendering/RenderSettings.h"
  6. #include "client/rendering/Renderer.h"
  7. #include "client/rendering/Mesh.h"
  8. #include "client/rendering/FileTexture.h"
  9. #include "client/rendering/FontRenderer.h"
  10. #include "common/world/World.h"
  11. #include "common/block/BlockRegistry.h"
  12. #include "rendering/renderer/WorldRenderer.h"
  13. class Game final {
  14. public:
  15. Game(const Control& control, const Clock& fps, const Clock& tps, RenderSettings& renderSettings);
  16. void tick();
  17. void renderWorld(float lag, Renderer& renderer) const;
  18. void renderTextOverlay(float lag, Renderer& renderer, FontRenderer& fr) const;
  19. bool isRunning() const;
  20. Vector splineTangent(const Vector& prev, const Vector& current, const Vector& next) const;
  21. Vector interpolate(const Vector& a, const Vector& b, const Vector& tanA, const Vector& tanB, float t) const;
  22. float distance(uint index, uint splits) const;
  23. void getPointsAndTangents(uint index, Vector& a, Vector& b, Vector& tanA, Vector& tanB) const;
  24. private:
  25. const Control& control;
  26. const Clock& fps;
  27. const Clock& tps;
  28. RenderSettings& renderSettings;
  29. Vector lastPos;
  30. mutable Vector pos;
  31. Quaternion lastRotation;
  32. Quaternion rotation;
  33. BlockRegistry blockRegistry;
  34. World world;
  35. WorldRenderer worldRenderer;
  36. struct Point {
  37. Vector pos;
  38. float distance;
  39. };
  40. List<Point, 25> cameraPoints;
  41. uint pointIndex;
  42. float moveSpeed;
  43. float movedLength;
  44. enum Mode {
  45. AUTO, PLAYER
  46. };
  47. Mode mode;
  48. };
  49. #endif