--- /dev/null
+#include "RandomWalk.hpp"
+
+#include "../world/Entity.hpp"
+
+
+namespace blank {
+
+RandomWalk::RandomWalk(Entity &e) noexcept
+: entity(e)
+, time_left(0) {
+
+}
+
+
+void RandomWalk::Update(int dt) noexcept {
+ time_left -= dt;
+ if (time_left > 0) return;
+ time_left += 2500 + (rand() % 5000);
+
+ constexpr float move_vel = 0.0005f;
+
+ glm::vec3 new_vel = entity.Velocity();
+
+ switch (rand() % 9) {
+ case 0:
+ new_vel.x = -move_vel;
+ break;
+ case 1:
+ new_vel.x = 0.0f;
+ break;
+ case 2:
+ new_vel.x = move_vel;
+ break;
+ case 3:
+ new_vel.y = -move_vel;
+ break;
+ case 4:
+ new_vel.y = 0.0f;
+ break;
+ case 5:
+ new_vel.y = move_vel;
+ break;
+ case 6:
+ new_vel.z = -move_vel;
+ break;
+ case 7:
+ new_vel.z = 0.0f;
+ break;
+ case 8:
+ new_vel.z = move_vel;
+ break;
+ }
+
+ entity.Velocity(new_vel);
+}
+
+}
--- /dev/null
+#ifndef BLANK_APP_RANDOMWALK_HPP_
+#define BLANK_APP_RANDOMWALK_HPP_
+
+#include <glm/glm.hpp>
+
+
+namespace blank {
+
+class Entity;
+
+/// Randomly start or stop moving in axis directions every now and then.
+class RandomWalk {
+
+public:
+ explicit RandomWalk(Entity &) noexcept;
+
+ void Update(int dt) noexcept;
+
+private:
+ Entity &entity;
+
+ int time_left;
+
+};
+
+}
+
+#endif
#include "Assets.hpp"
#include "FrameCounter.hpp"
-#include "RandomWalk.hpp"
+#include "../ai/RandomWalk.hpp"
#include "../audio/Audio.hpp"
#include "../graphics/Viewport.hpp"
#include "../ui/Interface.hpp"
--- /dev/null
+#include "FPSController.hpp"
+
+#include <glm/gtx/euler_angles.hpp>
+#include <glm/gtx/rotate_vector.hpp>
+
+
+namespace blank {
+
+FPSController::FPSController(Entity &entity) noexcept
+: entity(entity)
+, pitch(0)
+, yaw(0) {
+
+}
+
+
+void FPSController::Pitch(float p) noexcept {
+ pitch = p;
+ if (pitch > PI / 2) {
+ pitch = PI / 2;
+ } else if (pitch < -PI / 2) {
+ pitch = -PI / 2;
+ }
+}
+
+void FPSController::RotatePitch(float delta) noexcept {
+ Pitch(pitch + delta);
+}
+
+void FPSController::Yaw(float y) noexcept {
+ yaw = y;
+ if (yaw > PI) {
+ yaw -= PI * 2;
+ } else if (yaw < -PI) {
+ yaw += PI * 2;
+ }
+}
+
+void FPSController::RotateYaw(float delta) noexcept {
+ Yaw(yaw + delta);
+}
+
+
+void FPSController::Update(int dt) noexcept {
+ entity.Rotation(glm::eulerAngleYX(yaw, pitch));
+ entity.Velocity(glm::rotateY(velocity, yaw));
+}
+
+}
+++ /dev/null
-#ifndef BLANK_APP_RANDOMWALK_HPP_
-#define BLANK_APP_RANDOMWALK_HPP_
-
-#include <glm/glm.hpp>
-
-
-namespace blank {
-
-class Entity;
-
-/// Randomly start or stop moving in axis directions every now and then.
-class RandomWalk {
-
-public:
- explicit RandomWalk(Entity &) noexcept;
-
- void Update(int dt) noexcept;
-
-private:
- Entity &entity;
-
- int time_left;
-
-};
-
-}
-
-#endif
+++ /dev/null
-#include "FPSController.hpp"
-#include "RandomWalk.hpp"
-
-#include <glm/gtx/euler_angles.hpp>
-#include <glm/gtx/rotate_vector.hpp>
-
-
-namespace blank {
-
-FPSController::FPSController(Entity &entity) noexcept
-: entity(entity)
-, pitch(0)
-, yaw(0) {
-
-}
-
-
-void FPSController::Pitch(float p) noexcept {
- pitch = p;
- if (pitch > PI / 2) {
- pitch = PI / 2;
- } else if (pitch < -PI / 2) {
- pitch = -PI / 2;
- }
-}
-
-void FPSController::RotatePitch(float delta) noexcept {
- Pitch(pitch + delta);
-}
-
-void FPSController::Yaw(float y) noexcept {
- yaw = y;
- if (yaw > PI) {
- yaw -= PI * 2;
- } else if (yaw < -PI) {
- yaw += PI * 2;
- }
-}
-
-void FPSController::RotateYaw(float delta) noexcept {
- Yaw(yaw + delta);
-}
-
-
-void FPSController::Update(int dt) noexcept {
- entity.Rotation(glm::eulerAngleYX(yaw, pitch));
- entity.Velocity(glm::rotateY(velocity, yaw));
-}
-
-
-RandomWalk::RandomWalk(Entity &e) noexcept
-: entity(e)
-, time_left(0) {
-
-}
-
-
-void RandomWalk::Update(int dt) noexcept {
- time_left -= dt;
- if (time_left > 0) return;
- time_left += 2500 + (rand() % 5000);
-
- constexpr float move_vel = 0.0005f;
-
- glm::vec3 new_vel = entity.Velocity();
-
- switch (rand() % 9) {
- case 0:
- new_vel.x = -move_vel;
- break;
- case 1:
- new_vel.x = 0.0f;
- break;
- case 2:
- new_vel.x = move_vel;
- break;
- case 3:
- new_vel.y = -move_vel;
- break;
- case 4:
- new_vel.y = 0.0f;
- break;
- case 5:
- new_vel.y = move_vel;
- break;
- case 6:
- new_vel.z = -move_vel;
- break;
- case 7:
- new_vel.z = 0.0f;
- break;
- case 8:
- new_vel.z = move_vel;
- break;
- }
-
- entity.Velocity(new_vel);
-}
-
-}