crosshair

This commit is contained in:
onezplpl 2024-07-18 17:04:40 -04:00
parent 328be44ed0
commit e799d50f77
No known key found for this signature in database
GPG key ID: 7EC026A136F9EEC3
5 changed files with 94 additions and 18 deletions

View file

@ -134,8 +134,10 @@ struct v3f control_rtrace(double cx, double cy, vec3 pos, int mode) {
vec3_add(temp_pos, temp_pos, temp_dir);
if (gen_cube(temp_pos[0],temp_pos[1],temp_pos[2],placeChunk,0,-1) != 0) {
if (mode == 0) vec3_sub(temp_pos,temp_pos,temp_dir);
if (gen_cube(temp_pos[0], temp_pos[1], temp_pos[2], placeChunk, 0, -1) !=
0) {
if (mode == 0)
vec3_sub(temp_pos, temp_pos, temp_dir);
break;
}
}
@ -149,15 +151,21 @@ struct v3f control_rtrace(double cx, double cy, vec3 pos, int mode) {
void control_lclick(double cx, double cy, vec3 pos) {
struct v3f highlighted = control_rtrace(cx, cy, pos, 1);
struct chunk placeChunk;
int cube = gen_cube(highlighted.pos[0],highlighted.pos[1],highlighted.pos[2],placeChunk,0,-1);
if (cube == 0) return;
gen_cube(highlighted.pos[0],highlighted.pos[1],highlighted.pos[2],placeChunk,0,0);
int cube = gen_cube(highlighted.pos[0], highlighted.pos[1],
highlighted.pos[2], placeChunk, 0, -1);
if (cube == 0)
return;
gen_cube(highlighted.pos[0], highlighted.pos[1], highlighted.pos[2],
placeChunk, 0, 0);
}
void control_rclick(double cx, double cy, vec3 pos) {
struct v3f highlighted = control_rtrace(cx, cy, pos, 0);
struct chunk placeChunk;
int cube = gen_cube(highlighted.pos[0],highlighted.pos[1],highlighted.pos[2],placeChunk,0,-1);
if (cube != 0) return;
gen_cube(highlighted.pos[0],highlighted.pos[1],highlighted.pos[2],placeChunk,0,1);
int cube = gen_cube(highlighted.pos[0], highlighted.pos[1],
highlighted.pos[2], placeChunk, 0, -1);
if (cube != 0)
return;
gen_cube(highlighted.pos[0], highlighted.pos[1], highlighted.pos[2],
placeChunk, 0, 1);
}