control fix

This commit is contained in:
onezplpl 2024-07-23 15:13:44 -04:00
parent 646d1c9ed3
commit 0f38b89e1c
No known key found for this signature in database
GPG key ID: 7EC026A136F9EEC3
4 changed files with 15 additions and 7 deletions

View file

@ -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
rm ./*.o ./*.exe ./monke

View file

@ -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;
}

4
gen.c
View file

@ -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);
}
}
}

4
main.c
View file

@ -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;
}
}