more control fixes

This commit is contained in:
onezplpl 2024-07-19 14:05:26 -04:00
parent 1939e2dff5
commit 2ce46f188b
No known key found for this signature in database
GPG key ID: 7EC026A136F9EEC3
4 changed files with 23 additions and 14 deletions

View file

@ -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; dir_temp[1] = 0.015;
pos[1] = closestVert[1]; pos[1] = closestVert[1];
return 1; return 1;
} }
@ -66,9 +66,9 @@ struct v3f control_handler(double cx, double cy, vec3 pos, vec3 dir_temp,
for (int a = -2; a < 0; a++) { for (int a = -2; a < 0; a++) {
off[1] = a; off[1] = a;
for (int b = -1; b < 1; b++) { for (int b = -1; b < 1; b++) {
off[0] = b + 0.5; off[0] = (b + 0.5)*0.95;
for (int c = -1; c < 1; c++) { for (int c = -1; c < 1; c++) {
off[2] = c + 0.5; off[2] = (c + 0.5)*0.95;
col = col || gen_cube(pos[0] + off[0], pos[1] + off[1], pos[2] + off[2], col = col || gen_cube(pos[0] + off[0], pos[1] + off[1], pos[2] + off[2],
chunk, 0, -1); chunk, 0, -1);
} }
@ -82,9 +82,9 @@ struct v3f control_handler(double cx, double cy, vec3 pos, vec3 dir_temp,
off[1] = -2; off[1] = -2;
for (int b = -1; b < 1; b++) { for (int b = -1; b < 1; b++) {
off[0] = b + 0.5; off[0] = (b + 0.5)*0.95;
for (int c = -1; c < 1; c++) { for (int c = -1; c < 1; c++) {
off[2] = c + 0.5; off[2] = (c + 0.5)*0.95;
col = col || gen_cube(pos[0] + off[0], pos[1] + off[1], pos[2] + off[2], col = col || gen_cube(pos[0] + off[0], pos[1] + off[1], pos[2] + off[2],
chunk, 0, -1); chunk, 0, -1);
} }

View file

@ -40,10 +40,10 @@ void cubes_rect(struct v3f *cube, int *i, double x1, double x2, double y1,
d.pos[0] += TEXT_GAP_H; d.pos[0] += TEXT_GAP_H;
d.pos[1] += TEXT_GAP_V; d.pos[1] += TEXT_GAP_V;
} else { } else {
b.pos[0]++; b.pos[0] = x2;
c.pos[1]++; c.pos[1] = y2;
d.pos[0]++; d.pos[0] = x2;
d.pos[1]++; d.pos[1] = y2;
} }
cube[*i] = a2; cube[*i] = a2;

19
main.c
View file

@ -354,9 +354,18 @@ int main(void) {
glUniform1i(use_shading, 0); glUniform1i(use_shading, 0);
int iz = CBLOCK_ALL * 18; int iz = CBLOCK_ALL * 18;
int iz2 = iz;
cubes_rect(cubeO, &iz, -0.5, 0.5, -0.5, 0.5, 0, 0, 6); cubes_rect(cubeO, &iz, -0.5, 0.5, -0.5, 0.5, 0, 0, 6);
cubes_rect(textO, &iz, -0.5, 0.5, -0.5, 0.5, 1, 0, 6); cubes_rect(textO, &iz, -0.5, 0.5, -0.5, 0.5, 1, 0, 6);
for (int i = 0; i < 10; i++) {
iz += 6;
cubes_rect(cubeO, &iz, ((i - 4.5) * 2.5) - 1, ((i - 4.5) * 2.5) + 1, -11,
-9, 0, 1, 6);
cubes_rect(textO, &iz, ((i - 4.5) * 2.5) - 1, ((i - 4.5) * 2.5) + 1, -11,
-9, 1, 1, 6);
}
mat4x4_identity(v); mat4x4_identity(v);
mat4x4_ortho(p, -ratio * 15, ratio * 15, -1.f * 15, 1.f * 15, 1.0f, -1.0f); mat4x4_ortho(p, -ratio * 15, ratio * 15, -1.f * 15, 1.f * 15, 1.0f, -1.0f);
mat4x4_mul(mvp, p, v); mat4x4_mul(mvp, p, v);
@ -365,15 +374,15 @@ int main(void) {
glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat *)&mvp); glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat *)&mvp);
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer[1]); glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer[1]);
glBufferSubData(GL_ARRAY_BUFFER, CTRI_ALL, (long)6 * sizeof(struct v3f), glBufferSubData(GL_ARRAY_BUFFER, CTRI_ALL,
&textO[iz]); (long)6 * 11 * sizeof(struct v3f), &textO[iz2]);
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer[0]); glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer[0]);
glBufferSubData(GL_ARRAY_BUFFER, CTRI_ALL, (long)6 * sizeof(struct v3f), glBufferSubData(GL_ARRAY_BUFFER, CTRI_ALL,
&cubeO[iz]); (long)6 * 11 * sizeof(struct v3f), &cubeO[iz2]);
glBindVertexArray(vertex_array); glBindVertexArray(vertex_array);
glDrawArrays(GL_TRIANGLES, CBLOCK_ALL * 18, 6); glDrawArrays(GL_TRIANGLES, CBLOCK_ALL * 18, 6 * 11);
} }
if (fp) { if (fp) {

BIN
test.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Before After
Before After