control fix
This commit is contained in:
parent
646d1c9ed3
commit
0f38b89e1c
4 changed files with 15 additions and 7 deletions
4
Makefile
4
Makefile
|
@ -1,6 +1,6 @@
|
||||||
make:
|
make:
|
||||||
gcc -lm -lglfw -o ./monke *.c
|
gcc -lm -lglfw -o ./monke *.c
|
||||||
windows:
|
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:
|
clean:
|
||||||
rm ./*.o ./*.exe ./monke
|
rm ./*.o ./*.exe ./monke
|
||||||
|
|
10
control.c
10
control.c
|
@ -18,7 +18,7 @@ int collision(struct chunk chunk, vec3 pos, vec3 dir_temp, int col, int n) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (yd < 0 && n == 1) {
|
if (yd < 0 && n == 1) {
|
||||||
dir_temp[1] = 0.015;
|
dir_temp[1] = 0.015 / 2;
|
||||||
pos[1] = closestVert[1];
|
pos[1] = closestVert[1];
|
||||||
return 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);
|
vec3_add(pos, pos, dir_temp);
|
||||||
|
|
||||||
dir_temp[1] -= 0.03 * delta;
|
dir_temp[1] -= 0.03 * delta;
|
||||||
|
int is_col = 0;
|
||||||
if (collision(chunk, pos, dir_temp, col, 1)) {
|
if (collision(chunk, pos, dir_temp, col, 1)) {
|
||||||
|
is_col = 1;
|
||||||
col = 0;
|
col = 0;
|
||||||
|
|
||||||
off[1] = -2;
|
off[1] = -2;
|
||||||
|
@ -106,6 +110,10 @@ struct v3f control_handler(double cx, double cy, vec3 pos, vec3 dir_temp,
|
||||||
struct v3f dirOut;
|
struct v3f dirOut;
|
||||||
vec3_dup(dirOut.pos, direction);
|
vec3_dup(dirOut.pos, direction);
|
||||||
|
|
||||||
|
if (is_col && fabs(dir_temp[1]) < 0.1) {
|
||||||
|
pos[1] -= dir_temp[1];
|
||||||
|
}
|
||||||
|
|
||||||
return dirOut;
|
return dirOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
gen.c
4
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) {
|
if (chunk.exists == 1 && chunk.x != x && chunk.y != y && chunk.z != z) {
|
||||||
gen_save(chunk);
|
//gen_save(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
char fname[1024];
|
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);
|
printf("%i %i %i\n",a,b,c);
|
||||||
|
|
||||||
cubes_refresh(a / CHUNK_LENGTH, b / CHUNK_LENGTH, c / CHUNK_LENGTH,
|
cubes_refresh(a / CHUNK_LENGTH, b / CHUNK_LENGTH, c / CHUNK_LENGTH,
|
||||||
dat, 255);
|
dat, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
main.c
4
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,
|
void mouse_button_callback(GLFWwindow *window, int button, int action,
|
||||||
int mods) {
|
int mods) {
|
||||||
if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) {
|
if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) {
|
||||||
fr = 1;
|
|
||||||
control_rclick(cx, cy, player.pos, player.inv, slot);
|
control_rclick(cx, cy, player.pos, player.inv, slot);
|
||||||
|
fr = 1;
|
||||||
}
|
}
|
||||||
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) {
|
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) {
|
||||||
fr = 1;
|
|
||||||
control_lclick(cx, cy, player.pos, player.inv);
|
control_lclick(cx, cy, player.pos, player.inv);
|
||||||
|
fr = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue