From 0f38b89e1c44aca0d7819589879b3a8bae2489a5 Mon Sep 17 00:00:00 2001 From: onezplpl Date: Tue, 23 Jul 2024 15:13:44 -0400 Subject: [PATCH] control fix --- Makefile | 4 ++-- control.c | 10 +++++++++- gen.c | 4 ++-- main.c | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 5d36b3f..4e18765 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ make: gcc -lm -lglfw -o ./monke *.c windows: - x86_64-w64-mingw32-gcc -lm -o ./monke.exe ./*.c ./libglfw3.a ./libwinpthread.a ./libopengl32.a ./libgdi32.a + x86_64-w64-mingw32-gcc -lm -o monke.exe *.c libglfw3.a libwinpthread.a libopengl32.a libgdi32.a clean: - rm ./*.o ./*.exe ./monke \ No newline at end of file + rm ./*.o ./*.exe ./monke diff --git a/control.c b/control.c index 2959247..3d5cc5b 100644 --- a/control.c +++ b/control.c @@ -18,7 +18,7 @@ int collision(struct chunk chunk, vec3 pos, vec3 dir_temp, int col, int n) { return 1; } if (yd < 0 && n == 1) { - dir_temp[1] = 0.015; + dir_temp[1] = 0.015 / 2; pos[1] = closestVert[1]; return 1; } @@ -80,9 +80,13 @@ struct v3f control_handler(double cx, double cy, vec3 pos, vec3 dir_temp, } } + vec3_add(pos, pos, dir_temp); + dir_temp[1] -= 0.03 * delta; + int is_col = 0; if (collision(chunk, pos, dir_temp, col, 1)) { + is_col = 1; col = 0; off[1] = -2; @@ -106,6 +110,10 @@ struct v3f control_handler(double cx, double cy, vec3 pos, vec3 dir_temp, struct v3f dirOut; vec3_dup(dirOut.pos, direction); + if (is_col && fabs(dir_temp[1]) < 0.1) { + pos[1] -= dir_temp[1]; + } + return dirOut; } diff --git a/gen.c b/gen.c index 278557d..d08dd46 100644 --- a/gen.c +++ b/gen.c @@ -80,7 +80,7 @@ struct chunk gen_chunk(int x, int y, int z, int ci, int h) { } if (chunk.exists == 1 && chunk.x != x && chunk.y != y && chunk.z != z) { - gen_save(chunk); + //gen_save(chunk); } char fname[1024]; @@ -165,7 +165,7 @@ int gen_cube(int x, int y, int z, struct chunk dat, int ci, int val) { printf("%i %i %i\n",a,b,c); cubes_refresh(a / CHUNK_LENGTH, b / CHUNK_LENGTH, c / CHUNK_LENGTH, - dat, 255); + dat, 0); } } } diff --git a/main.c b/main.c index f70d13c..cf27290 100644 --- a/main.c +++ b/main.c @@ -80,12 +80,12 @@ static void key_callback(GLFWwindow *window, int key, int scancode, int action, void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) { if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) { - fr = 1; control_rclick(cx, cy, player.pos, player.inv, slot); + fr = 1; } if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) { - fr = 1; control_lclick(cx, cy, player.pos, player.inv); + fr = 1; } }