1 #include "controller.hpp"
3 #include <glm/gtx/euler_angles.hpp>
4 #include <glm/gtx/rotate_vector.hpp>
9 FPSController::FPSController(Entity &entity)
17 void FPSController::Pitch(float p) {
21 } else if (pitch < -PI / 2) {
26 void FPSController::RotatePitch(float delta) {
30 void FPSController::Yaw(float y) {
34 } else if (yaw < -PI) {
39 void FPSController::RotateYaw(float delta) {
44 void FPSController::Update(int dt) {
45 entity.Rotation(glm::eulerAngleYX(yaw, pitch));
46 entity.Velocity(glm::rotateY(velocity, yaw));
50 RandomWalk::RandomWalk(Entity &e)
57 void RandomWalk::Update(int dt) {
59 if (time_left > 0) return;
60 time_left += 2500 + (rand() % 5000);
62 constexpr float move_vel = 0.0005f;
64 glm::vec3 new_vel = entity.Velocity();
68 new_vel.x = -move_vel;
77 new_vel.y = -move_vel;
86 new_vel.z = -move_vel;
96 entity.Velocity(new_vel);