-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayer.h
31 lines (27 loc) · 813 Bytes
/
player.h
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
// Todo: Assuming that the player is the only entity
#include "glad/glad.h"
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/type_ptr.hpp>
#ifndef INPUT
#define INPUT
#include "input.h"
#endif
struct Player {
unsigned int id;
glm::vec3 position;
float speed;
glm::quat orientation;
float pitch_rads; // currently just for rolling animation
float yaw_rads;
glm::vec3 forward() {
glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), yaw_rads, {0, 1, 0});
// TODO pitch
glm::vec4 res = rotation * glm::vec4{ 1, 0, 0, 1 };
return { res.x, res.y, res.z };
}
};
Player initial_player(unsigned int id, glm::vec2 initial_position);
void step_player(PlayerInputs input, Player *player);