Game.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. private:
  21. Vector3 splineTangent(const Vector3& prev, const Vector3& current, const Vector3& next) const;
  22. Vector3 interpolate(const Vector3& a, const Vector3& b, const Vector3& tanA, const Vector3& tanB, float t) const;
  23. float distance(uint index, uint splits) const;
  24. Vector3 pointUntilDistance(float leftDistance, uint index, uint splits) const;
  25. void getPointsAndTangents(uint index, Vector3& a, Vector3& b, Vector3& tanA, Vector3& tanB) const;
  26. void updateDistances();
  27. const Control& control;
  28. const Clock& fps;
  29. const Clock& tps;
  30. RenderSettings& renderSettings;
  31. Vector3 lastPos;
  32. mutable Vector3 pos;
  33. Quaternion lastRotation;
  34. Quaternion rotation;
  35. BlockRegistry blockRegistry;
  36. World world;
  37. WorldRenderer worldRenderer;
  38. struct Point {
  39. Vector3 pos;
  40. Quaternion q;
  41. float distance;
  42. };
  43. List<Point, 25> cameraPoints;
  44. uint pointIndex;
  45. float moveSpeed;
  46. float movedLength;
  47. enum Mode {
  48. AUTO, PLAYER
  49. };
  50. Mode mode;
  51. };
  52. #endif