First hit not counted; bugfixes on sound
This commit is contained in:
@@ -54,7 +54,8 @@ typedef enum {
|
||||
typedef enum {
|
||||
RESULT_LOSE = -1,
|
||||
RESULT_NONE = 0,
|
||||
RESULT_HIT = 1
|
||||
RESULT_HIT = 1,
|
||||
RESULT_FIRST_HIT = 2,
|
||||
} PingResult;
|
||||
|
||||
#define FREQ_BABY 2
|
||||
@@ -207,7 +208,7 @@ static void display_ball(void) {
|
||||
char_display = '#';
|
||||
}
|
||||
} 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
|
||||
} else {
|
||||
if (overlap) {
|
||||
@@ -222,9 +223,11 @@ static void display_ball(void) {
|
||||
|
||||
static PingResult update_ball(uint8_t difficulty) {
|
||||
bool ball_hit = paddle_hit_ball();
|
||||
bool first_hit = false;
|
||||
if (!game_state.ball_is_moving) {
|
||||
if (ball_hit) {
|
||||
game_state.ball_is_moving = true;
|
||||
first_hit = true;
|
||||
} else {
|
||||
return RESULT_NONE;
|
||||
}
|
||||
@@ -235,7 +238,7 @@ static PingResult update_ball(uint8_t difficulty) {
|
||||
}
|
||||
display_ball();
|
||||
if (ball_hit) {
|
||||
return RESULT_HIT;
|
||||
return first_hit ? RESULT_FIRST_HIT : RESULT_HIT;
|
||||
} else {
|
||||
return RESULT_NONE;
|
||||
}
|
||||
@@ -378,7 +381,7 @@ static void display_title(ping_state_t *state) {
|
||||
movement_request_tick_frequency(1);
|
||||
game_state.curr_screen = SCREEN_TITLE;
|
||||
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 ");
|
||||
display_sound_indicator(state -> soundOn);
|
||||
_ticks_show_title = 1;
|
||||
@@ -392,7 +395,7 @@ static void display_score_screen(ping_state_t *state) {
|
||||
memset(&game_state, 0, sizeof(game_state));
|
||||
game_state.curr_screen = SCREEN_SCORE;
|
||||
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) {
|
||||
watch_display_text(WATCH_POSITION_BOTTOM, "HS --");
|
||||
}
|
||||
@@ -435,9 +438,6 @@ static void begin_playing(ping_state_t *state) {
|
||||
display_paddle();
|
||||
display_ball();
|
||||
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) {
|
||||
@@ -461,8 +461,12 @@ static void update_game(ping_state_t *state) {
|
||||
display_lose_screen(state);
|
||||
} else if (game_result == RESULT_HIT) {
|
||||
add_to_score(state);
|
||||
if (state -> soundOn) {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user