summaryrefslogtreecommitdiff
path: root/src/player.c
diff options
context:
space:
mode:
authorSchark <jordan@schark.online>2024-03-06 02:00:59 -0800
committerSchark <jordan@schark.online>2024-03-06 02:00:59 -0800
commitc356e96932b5d1a23bf41914934cf83e8b535994 (patch)
tree9ee15f23c0ae584443d8af63b473d5c2eee094ba /src/player.c
parentce811be0799bfee8355aa56d3ab566fb5b5dab55 (diff)
downloadgamedev-c356e96932b5d1a23bf41914934cf83e8b535994.tar.gz
gamedev-c356e96932b5d1a23bf41914934cf83e8b535994.zip
Working barebones heightmap renderer
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c44
1 files changed, 0 insertions, 44 deletions
diff --git a/src/player.c b/src/player.c
deleted file mode 100644
index f2d9883..0000000
--- a/src/player.c
+++ /dev/null
@@ -1,44 +0,0 @@
-#include <GLFW/glfw3.h>
-#include <math.h>
-
-#include "player.h"
-
-void move_player(Player *player, GLFWwindow* window, double* mouse_x, double* mouse_y, double width, double height) {
- if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) {
- player->pos_x += player->dir_x * player->move_speed;
- player->pos_y += player->dir_y * player->move_speed;
- }
- if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) {
- player->pos_x -= player->dir_x * player->move_speed;
- player->pos_y -= player->dir_y * player->move_speed;
- }
- if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) {
- player->pos_x += player->dir_y * player->move_speed;
- player->pos_y -= player->dir_x * player->move_speed;
- }
- if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) {
- player->pos_x -= player->dir_y * player->move_speed;
- player->pos_y += player->dir_x * player->move_speed;
- }
-
- // mouse controls (including y-shearing angle calculations
- // DO NOT TOUCH, THIS TOOK A WHOLE NIGHT TO FIGURE OUT
- double mouse_dx, mouse_dy;
- double old_mouse_x, old_mouse_y;
- old_mouse_x = *mouse_x;
- old_mouse_y = *mouse_y;
- glfwGetCursorPos(window, mouse_x, mouse_y);
- mouse_dx = *mouse_x - old_mouse_x;
- mouse_dy = *mouse_y - old_mouse_y;
- double rot_speed = mouse_dx * player->sensitivity;
- double old_dir_x = player->dir_x;
- player->dir_x = player->dir_x * cos(rot_speed) - player->dir_y * sin(rot_speed);
- player->dir_y = old_dir_x * sin(rot_speed) + player->dir_y * cos(rot_speed);
- double old_plane_x = player->plane_x;
- player->plane_x = player->plane_x * cos(rot_speed) - player->plane_y * sin(rot_speed);
- player->plane_y = old_plane_x * sin(rot_speed) + player->plane_y * cos(rot_speed);
- player->look_angle += mouse_dy * player->sensitivity;
- if (player->look_angle > M_PI/4) { player->look_angle = M_PI/4; }
- if (player->look_angle < -M_PI/4) { player->look_angle = -M_PI/4; }
-
-}