diff --git a/include/state.h b/include/state.h index f3dd7ac..1f8b3f3 100644 --- a/include/state.h +++ b/include/state.h @@ -16,6 +16,7 @@ extern "C" { float ball_dx; float ball_dy; double launch_time; + bool super_ball; }; #define MAX_BALLS 20 diff --git a/src/render.cpp b/src/render.cpp index ea9cfa5..e301efe 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -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); diff --git a/src/update.cpp b/src/update.cpp index 57b30b2..d3792a4 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -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; } }