From 9eb8e3189b3558d2ea7082a0ff32beab776c7806 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Fri, 5 Dec 2025 20:15:17 -0600 Subject: [PATCH] game reset via OPTIONS button --- src/main.c | 8 ++++++++ src/update.cpp | 9 ++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index 9f6b70b..60861d7 100644 --- a/src/main.c +++ b/src/main.c @@ -225,7 +225,9 @@ int main() float paddle_dx = 0.0; //float paddle_dy = 0.0; static bool last_x_press = false; + static bool last_option_press = false; bool x_press = false; + bool option_press = false; for (int i = 0; i < 16; i++) { int present = glfwJoystickPresent(GLFW_JOYSTICK_1 + i); @@ -253,6 +255,7 @@ int main() #endif x_press = buttons[X_BUTTON] != 0; + option_press = buttons[OPTIONS_BUTTON] != 0; const char * name = glfwGetJoystickName(GLFW_JOYSTICK_1 + i); if (name != last_gamepad_name) { @@ -278,6 +281,11 @@ int main() } last_x_press = x_press; + if (!last_option_press && option_press) { + reset_game(&state); + } + last_option_press = option_press; + float extent = 0.25; state.paddle_x += paddle_dx; if (state.paddle_x < extent) diff --git a/src/update.cpp b/src/update.cpp index d3792a4..3ad19dc 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -100,11 +100,6 @@ void launch_ball(struct game_state * state, double time) void reset_level(struct game_state * state) { - state->paddle_x = 0.0; - state->paddle_y = 26.0; - - state->start_time = 0.0; - //assert(src_level_level2_data_size == 13 * 28); const uint8_t * level = (const uint8_t *)levels[state->level_ix].data_start; const uint8_t * pal = (const uint8_t *)levels[state->level_ix].data_pal_start; @@ -118,6 +113,10 @@ void reset_level(struct game_state * state) void reset_game(struct game_state * state) { + state->paddle_x = 0; + state->paddle_y = 26.0; + + state->balls_launched = 0; state->level_ix = 0; reset_level(state); }