game reset via OPTIONS button
This commit is contained in:
parent
1ab28665f2
commit
9eb8e3189b
@ -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)
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user