-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovement_controller.hpp
More file actions
42 lines (36 loc) · 1.25 KB
/
movement_controller.hpp
File metadata and controls
42 lines (36 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include "lve_game_object.hpp"
#include "lve_window.hpp"
#include "entity_components.hpp"
#include "KeyInput.hpp" // Include the KeyInput header
#include <memory> // For std::unique_ptr
#include <map>
#include <string>
namespace lve {
class MovementController {
public:
struct KeyMappings {
std::map<std::string, int> keyMap;
KeyMappings() {
keyMap["moveLeft"] = GLFW_KEY_A;
keyMap["moveRight"] = GLFW_KEY_D;
keyMap["moveForward"] = GLFW_KEY_W;
keyMap["moveBackward"] = GLFW_KEY_S;
keyMap["moveUp"] = GLFW_KEY_E;
keyMap["moveDown"] = GLFW_KEY_Q;
keyMap["lookLeft"] = GLFW_KEY_LEFT;
keyMap["lookRight"] = GLFW_KEY_RIGHT;
keyMap["lookUp"] = GLFW_KEY_UP;
keyMap["lookDown"] = GLFW_KEY_DOWN;
}
};
MovementController(GLFWwindow* window);
void moveInPlaneXZ(float dt, LveGameObject& gameObject);
void moveInPlaneXZ(float dt, TransformComponent& transform);
KeyMappings keys;
float moveSpeed{ 3.f };
float lookSpeed{ 1.5f };
private:
std::unique_ptr<KeyInput> keyInput;
};
}