]> git.localhorst.tv Git - blank.git/blob - src/controller.hpp
f674e23df9a0a9375c14bc56838acf8279881594
[blank.git] / src / controller.hpp
1 #ifndef BLANK_CONTROLLER_HPP_
2 #define BLANK_CONTROLLER_HPP_
3
4 #include "entity.hpp"
5 #include "geometry.hpp"
6
7 #include <glm/glm.hpp>
8
9
10 namespace blank {
11
12 class FPSController {
13
14 public:
15         explicit FPSController(Entity &) noexcept;
16
17         Ray Aim() const noexcept { return entity.Aim(entity.ChunkCoords()); }
18
19         const glm::vec3 &Velocity() const noexcept { return velocity; }
20         void Velocity(const glm::vec3 &vel) noexcept { velocity = vel; }
21
22         // all angles in radians (full circle = 2π)
23         float Pitch() const noexcept { return pitch; }
24         void Pitch(float p) noexcept;
25         void RotatePitch(float delta) noexcept;
26         float Yaw() const noexcept { return yaw; }
27         void Yaw(float y) noexcept;
28         void RotateYaw(float delta) noexcept;
29
30         void Update(int dt) noexcept;
31
32 private:
33         Entity &entity;
34
35         glm::vec3 velocity;
36
37         float pitch;
38         float yaw;
39
40 };
41
42
43 class RandomWalk {
44
45 public:
46         explicit RandomWalk(Entity &) noexcept;
47
48         void Update(int dt) noexcept;
49
50 private:
51         Entity &entity;
52
53         int time_left;
54
55 };
56
57 }
58
59 #endif