First hit not counted; bugfixes on sound
This commit is contained in:
@@ -54,7 +54,8 @@ typedef enum {
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
RESULT_LOSE = -1,
|
RESULT_LOSE = -1,
|
||||||
RESULT_NONE = 0,
|
RESULT_NONE = 0,
|
||||||
RESULT_HIT = 1
|
RESULT_HIT = 1,
|
||||||
|
RESULT_FIRST_HIT = 2,
|
||||||
} PingResult;
|
} PingResult;
|
||||||
|
|
||||||
#define FREQ_BABY 2
|
#define FREQ_BABY 2
|
||||||
@@ -207,7 +208,7 @@ static void display_ball(void) {
|
|||||||
char_display = '#';
|
char_display = '#';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_is_custom_lcd || char_pos == 4 || char_pos == 6) {
|
if (!_is_custom_lcd && (char_pos == 4 || char_pos == 6)) {
|
||||||
char_display = 'n'; // No need to check for overlap on these segments
|
char_display = 'n'; // No need to check for overlap on these segments
|
||||||
} else {
|
} else {
|
||||||
if (overlap) {
|
if (overlap) {
|
||||||
@@ -222,9 +223,11 @@ static void display_ball(void) {
|
|||||||
|
|
||||||
static PingResult update_ball(uint8_t difficulty) {
|
static PingResult update_ball(uint8_t difficulty) {
|
||||||
bool ball_hit = paddle_hit_ball();
|
bool ball_hit = paddle_hit_ball();
|
||||||
|
bool first_hit = false;
|
||||||
if (!game_state.ball_is_moving) {
|
if (!game_state.ball_is_moving) {
|
||||||
if (ball_hit) {
|
if (ball_hit) {
|
||||||
game_state.ball_is_moving = true;
|
game_state.ball_is_moving = true;
|
||||||
|
first_hit = true;
|
||||||
} else {
|
} else {
|
||||||
return RESULT_NONE;
|
return RESULT_NONE;
|
||||||
}
|
}
|
||||||
@@ -235,7 +238,7 @@ static PingResult update_ball(uint8_t difficulty) {
|
|||||||
}
|
}
|
||||||
display_ball();
|
display_ball();
|
||||||
if (ball_hit) {
|
if (ball_hit) {
|
||||||
return RESULT_HIT;
|
return first_hit ? RESULT_FIRST_HIT : RESULT_HIT;
|
||||||
} else {
|
} else {
|
||||||
return RESULT_NONE;
|
return RESULT_NONE;
|
||||||
}
|
}
|
||||||
@@ -378,7 +381,7 @@ static void display_title(ping_state_t *state) {
|
|||||||
movement_request_tick_frequency(1);
|
movement_request_tick_frequency(1);
|
||||||
game_state.curr_screen = SCREEN_TITLE;
|
game_state.curr_screen = SCREEN_TITLE;
|
||||||
watch_clear_colon();
|
watch_clear_colon();
|
||||||
watch_display_text_with_fallback(WATCH_POSITION_TOP, "PING", "PI ");
|
watch_display_text_with_fallback(WATCH_POSITION_TOP, "Ping", "PI ");
|
||||||
watch_display_text(WATCH_POSITION_BOTTOM, " Ping ");
|
watch_display_text(WATCH_POSITION_BOTTOM, " Ping ");
|
||||||
display_sound_indicator(state -> soundOn);
|
display_sound_indicator(state -> soundOn);
|
||||||
_ticks_show_title = 1;
|
_ticks_show_title = 1;
|
||||||
@@ -392,7 +395,7 @@ static void display_score_screen(ping_state_t *state) {
|
|||||||
memset(&game_state, 0, sizeof(game_state));
|
memset(&game_state, 0, sizeof(game_state));
|
||||||
game_state.curr_screen = SCREEN_SCORE;
|
game_state.curr_screen = SCREEN_SCORE;
|
||||||
watch_set_colon();
|
watch_set_colon();
|
||||||
watch_display_text_with_fallback(WATCH_POSITION_TOP, "PING ", "PI ");
|
watch_display_text_with_fallback(WATCH_POSITION_TOP, "PI ", "PI ");
|
||||||
if (hi_score > MAX_HI_SCORE) {
|
if (hi_score > MAX_HI_SCORE) {
|
||||||
watch_display_text(WATCH_POSITION_BOTTOM, "HS --");
|
watch_display_text(WATCH_POSITION_BOTTOM, "HS --");
|
||||||
}
|
}
|
||||||
@@ -435,9 +438,6 @@ static void begin_playing(ping_state_t *state) {
|
|||||||
display_paddle();
|
display_paddle();
|
||||||
display_ball();
|
display_ball();
|
||||||
display_score( game_state.curr_score);
|
display_score( game_state.curr_score);
|
||||||
if (state -> soundOn){
|
|
||||||
watch_buzzer_play_sequence(start_tune, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void display_lose_screen(ping_state_t *state) {
|
static void display_lose_screen(ping_state_t *state) {
|
||||||
@@ -461,8 +461,12 @@ static void update_game(ping_state_t *state) {
|
|||||||
display_lose_screen(state);
|
display_lose_screen(state);
|
||||||
} else if (game_result == RESULT_HIT) {
|
} else if (game_result == RESULT_HIT) {
|
||||||
add_to_score(state);
|
add_to_score(state);
|
||||||
|
if (state -> soundOn) {
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_C5, 60);
|
watch_buzzer_play_note(BUZZER_NOTE_C5, 60);
|
||||||
}
|
}
|
||||||
|
} else if (game_result == RESULT_FIRST_HIT && state -> soundOn) {
|
||||||
|
watch_buzzer_play_sequence(start_tune, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ping_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
void ping_face_setup(uint8_t watch_face_index, void ** context_ptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user