Gave an extra jumping frame for non-hard mode; Curr scroll now loops; Title changed to ER
This commit is contained in:
parent
ed3c4d3c30
commit
abc0bedbde
@ -31,22 +31,23 @@ typedef enum {
|
|||||||
JUMP,
|
JUMP,
|
||||||
JUMPING_1,
|
JUMPING_1,
|
||||||
JUMPING_2,
|
JUMPING_2,
|
||||||
|
JUMPING_3,
|
||||||
JUMP_COUNT
|
JUMP_COUNT
|
||||||
} ScrollingJumpState;
|
} RunnerJumpState;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SCREEN_TITLE = 0,
|
SCREEN_TITLE = 0,
|
||||||
SCREEN_PLAYING,
|
SCREEN_PLAYING,
|
||||||
SCREEN_LOSE,
|
SCREEN_LOSE,
|
||||||
SCREEN_COUNT
|
SCREEN_COUNT
|
||||||
} ScrollingCurrScreen;
|
} RunnerCurrScreen;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DIFF_NORM = 0, // 8x speed; 4 0's min;
|
DIFF_NORM = 0, // 8x speed; 4 0's min; jump is 3 frames
|
||||||
DIFF_HARD, // 8x speed; 3 0's min; 2 - Easy 4x speed; 4 0's min
|
DIFF_HARD, // 8x speed; 3 0's min; jump is 2 frames
|
||||||
DIFF_EASY, // 4x speed; 4 0's min
|
DIFF_EASY, // 4x speed; 4 0's min; jump is 3 frames
|
||||||
DIFF_COUNT
|
DIFF_COUNT
|
||||||
} ScrollingDifficulty;
|
} RunnerDifficulty;
|
||||||
|
|
||||||
#define NUM_GRID 12
|
#define NUM_GRID 12
|
||||||
#define FREQ 8
|
#define FREQ 8
|
||||||
@ -158,7 +159,7 @@ static void display_title(endless_runner_state_t *state) {
|
|||||||
memset(&game_state, 0, sizeof(game_state));
|
memset(&game_state, 0, sizeof(game_state));
|
||||||
game_state.sec_before_moves = 1; // The first obstacles will all be 0s, which is about an extra second of delay.
|
game_state.sec_before_moves = 1; // The first obstacles will all be 0s, which is about an extra second of delay.
|
||||||
if (state -> soundOn) game_state.sec_before_moves--; // Start chime is about 1 second
|
if (state -> soundOn) game_state.sec_before_moves--; // Start chime is about 1 second
|
||||||
watch_display_string("SC SEL ", 0);
|
watch_display_string("ER SEL ", 0);
|
||||||
display_score(state -> hi_score);
|
display_score(state -> hi_score);
|
||||||
display_difficulty(state -> difficulty);
|
display_difficulty(state -> difficulty);
|
||||||
}
|
}
|
||||||
@ -167,7 +168,7 @@ static void display_lose_screen(endless_runner_state_t *state) {
|
|||||||
movement_request_tick_frequency(1);
|
movement_request_tick_frequency(1);
|
||||||
state -> curr_screen = SCREEN_LOSE;
|
state -> curr_screen = SCREEN_LOSE;
|
||||||
state -> curr_score = 0;
|
state -> curr_score = 0;
|
||||||
watch_display_string(" LOSEr", 4);
|
watch_display_string(" U LOSE ", 0);
|
||||||
if (state -> soundOn)
|
if (state -> soundOn)
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_A1, 600);
|
watch_buzzer_play_note(BUZZER_NOTE_A1, 600);
|
||||||
else
|
else
|
||||||
@ -195,16 +196,19 @@ static bool display_obstacle(bool obstacle, int grid_loc, endless_runner_state_t
|
|||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (obstacle) { // If an obstacle is here, it means the ball cleared it
|
if (obstacle) { // If an obstacle is here, it means the ball cleared it
|
||||||
success_jump = true;
|
// Counter will continuously roll over, but high score will max out on the first roll-over
|
||||||
if (state -> curr_score < MAX_DISP_SCORE) {
|
state -> curr_score = (state -> curr_score + 1) % (MAX_DISP_SCORE + 1);
|
||||||
state -> curr_score++;
|
if (state -> curr_score == 0) // This means the counter rolled over
|
||||||
if (state -> curr_score > state -> hi_score)
|
state -> hi_score = MAX_DISP_SCORE + 1;
|
||||||
state -> hi_score = state -> curr_score;
|
else if (state -> curr_score > state -> hi_score)
|
||||||
display_score(state -> curr_score);
|
state -> hi_score = state -> curr_score;
|
||||||
}
|
display_score(state -> curr_score);
|
||||||
}
|
}
|
||||||
//fall through
|
//fall through
|
||||||
case 0:
|
case 0:
|
||||||
|
if (obstacle) // If an obstacle is here, it means the ball cleared it
|
||||||
|
success_jump = true;
|
||||||
|
//fall through
|
||||||
case 5:
|
case 5:
|
||||||
if (obstacle)
|
if (obstacle)
|
||||||
watch_set_pixel(0, 18 + grid_loc);
|
watch_set_pixel(0, 18 + grid_loc);
|
||||||
@ -308,9 +312,12 @@ bool endless_runner_face_loop(movement_event_t event, movement_settings_t *setti
|
|||||||
game_state.jump_state = JUMPING_1;
|
game_state.jump_state = JUMPING_1;
|
||||||
break;
|
break;
|
||||||
case JUMPING_1:
|
case JUMPING_1:
|
||||||
game_state.jump_state = JUMPING_2;
|
game_state.jump_state = (state -> difficulty == DIFF_HARD) ? JUMPING_3 : JUMPING_2;
|
||||||
break;
|
break;
|
||||||
case JUMPING_2:
|
case JUMPING_2:
|
||||||
|
game_state.jump_state = JUMPING_3;
|
||||||
|
break;
|
||||||
|
case JUMPING_3:
|
||||||
game_state.jump_state = NOT_JUMPING;
|
game_state.jump_state = NOT_JUMPING;
|
||||||
display_ball(game_state.jump_state);
|
display_ball(game_state.jump_state);
|
||||||
if (state -> soundOn){
|
if (state -> soundOn){
|
||||||
@ -323,8 +330,10 @@ bool endless_runner_face_loop(movement_event_t event, movement_settings_t *setti
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (game_state.jump_state == NOT_JUMPING && (game_state.loc_2_on || game_state.loc_3_on))
|
if (game_state.jump_state == NOT_JUMPING && (game_state.loc_2_on || game_state.loc_3_on)) {
|
||||||
|
delay_ms(200); // To show the player jumping onto the obstacle before displaying the lose screen.
|
||||||
display_lose_screen(state);
|
display_lose_screen(state);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -332,7 +341,7 @@ bool endless_runner_face_loop(movement_event_t event, movement_settings_t *setti
|
|||||||
case EVENT_ALARM_BUTTON_UP:
|
case EVENT_ALARM_BUTTON_UP:
|
||||||
if (state -> curr_screen == SCREEN_TITLE) {
|
if (state -> curr_screen == SCREEN_TITLE) {
|
||||||
state -> curr_screen = SCREEN_PLAYING;
|
state -> curr_screen = SCREEN_PLAYING;
|
||||||
movement_request_tick_frequency(state -> difficulty == DIFF_EASY ? FREQ_EASY : FREQ);
|
movement_request_tick_frequency((state -> difficulty == DIFF_EASY) ? FREQ_EASY : FREQ);
|
||||||
watch_display_string(" ", 4);
|
watch_display_string(" ", 4);
|
||||||
display_ball(false);
|
display_ball(false);
|
||||||
do // Avoid the first array of obstacles being a boring line of 0s
|
do // Avoid the first array of obstacles being a boring line of 0s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user