super balls

This commit is contained in:
Zack Buhman 2025-12-05 20:08:17 -06:00
parent e1d8a89e8c
commit 1ab28665f2
3 changed files with 18 additions and 5 deletions

View File

@ -16,6 +16,7 @@ extern "C" {
float ball_dx;
float ball_dy;
double launch_time;
bool super_ball;
};
#define MAX_BALLS 20

View File

@ -194,10 +194,19 @@ void render(mesh block_mesh,
mat4x4 trans = a * t * ry * rx;
mat3x3 normal_trans = submatrix(ry * rx, 3, 3);
float hue = state->time - ball.launch_time;
hue = hue - floorf(hue);
vec3 c = hsv_to_rgb(hue, 1.0f, 1.0f);
vec4 base_color = vec4(c.x, c.y, c.z, 1.0f);
vec4 base_color = vec4(0.5f, 0.5f, 0.5f, 1.0f);
if (ball.super_ball) {
float hue = state->time - ball.launch_time;
hue = hue - floorf(hue);
vec3 c = hsv_to_rgb(hue, 1.0f, 1.0f);
base_color = vec4(c.x, c.y, c.z, 1.0f);
} else if (0) {
float hue = sin(ball.launch_time) * 0.5 - 0.5;
hue = hue - floorf(hue);
vec3 c = hsv_to_rgb(hue, 1.0f, 1.0f);
base_color = vec4(c.x, c.y, c.z, 1.0f) * 0.5f;
}
glBindBuffer(GL_ARRAY_BUFFER, ball_mesh.vtx);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ball_mesh.idx);

View File

@ -92,6 +92,8 @@ void launch_ball(struct game_state * state, double time)
ball.ball_dy = -d.y;
ball.launch_time = time;
ball.super_ball = state->balls_launched % 5 == 4;
state->balls_launched += 1;
state->intro_shown = true;
}
@ -154,7 +156,8 @@ void update_ball(struct game_state * state, struct ball_state& ball, double time
struct collision_data cd;
bool collided = aabb_circle_collision(block_position, ball_position, block_bounds, &cd);
if (collided) {
ball_collision_response(ball, cd);
if (ball.super_ball == 0)
ball_collision_response(ball, cd);
state->blocks[block_ix].destroyed_time = time;
}
}