diff --git a/fw/Core/Hitcon/App/DinoApp.cc b/fw/Core/Hitcon/App/DinoApp.cc index 0ca672a..ecfccfa 100644 --- a/fw/Core/Hitcon/App/DinoApp.cc +++ b/fw/Core/Hitcon/App/DinoApp.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include @@ -17,6 +18,8 @@ namespace hitcon { namespace app { namespace dino { +int combo_button_ctr = 0; + DinoApp dino_app; DinoApp::DinoApp() @@ -41,6 +44,17 @@ void DinoApp::OnEntry() { void DinoApp::OnExit() { scheduler.DisablePeriodic(&_routine_task); } void DinoApp::OnButton(button_t button) { + if (button == COMBO_BUTTON_DINO[combo_button_ctr]) { + combo_button_ctr++; + } else { + combo_button_ctr = (button == COMBO_BUTTON_DINO[0]) ? 1 : 0; + } + if (combo_button_ctr == COMBO_BUTTON_DINO_LEN) { + // surprise + combo_button_ctr = (button == COMBO_BUTTON_DINO[0]) ? 1 : 0; + _no_big_cactus = true; + } + switch (button & BUTTON_VALUE_MASK) { case BUTTON_BACK: badge_controller.change_app(&main_menu); @@ -84,27 +98,27 @@ void DinoApp::Routine(void* unused) { if (_obstacle_interval > DINO_OBS_LEAST_DISTANCE) { if ((_obstacle_interval > DISPLAY_WIDTH * 2) || (g_fast_random_pool.GetRandom() % _generate_obs_rate == 0)) { - switch (g_fast_random_pool.GetRandom() % 4) { + switch (g_fast_random_pool.GetRandom() % (_no_big_cactus ? 3 : 4)) { case 0: // bird writeObsByte(DISPLAY_WIDTH, bird_bitmap[0]); writeObsByte(DISPLAY_WIDTH + 1, bird_bitmap[1]); writeObsByte(DISPLAY_WIDTH + 2, bird_bitmap[2]); _obstacle_interval = -6; break; - case 1: // big cactus - writeObsByte(DISPLAY_WIDTH, big_cactus_bitmap[0]); - writeObsByte(DISPLAY_WIDTH + 1, big_cactus_bitmap[1]); - writeObsByte(DISPLAY_WIDTH + 2, big_cactus_bitmap[2]); - _obstacle_interval = -5; - break; - case 2: // small tall cactus + case 1: // small tall cactus writeObsByte(DISPLAY_WIDTH, small_tall_cactus_bitmap[0]); _obstacle_interval = -3; break; - case 3: // small short cactus + case 2: // small short cactus writeObsByte(DISPLAY_WIDTH, small_short_cactus_bitmap[0]); _obstacle_interval = -3; break; + case 3: // big cactus + writeObsByte(DISPLAY_WIDTH, big_cactus_bitmap[0]); + writeObsByte(DISPLAY_WIDTH + 1, big_cactus_bitmap[1]); + writeObsByte(DISPLAY_WIDTH + 2, big_cactus_bitmap[2]); + _obstacle_interval = -5; + break; default: my_assert(false); } diff --git a/fw/Core/Hitcon/App/DinoApp.h b/fw/Core/Hitcon/App/DinoApp.h index b971a66..2edba30 100644 --- a/fw/Core/Hitcon/App/DinoApp.h +++ b/fw/Core/Hitcon/App/DinoApp.h @@ -34,6 +34,7 @@ class DinoApp : public App { uint8_t _game_over : 1; uint8_t _dino_ani_frame : 1; int8_t _dino_jump_vel : 3; + bool _no_big_cactus = false; enum dino_actions { DINO_RUN, DINO_JUMP, DINO_CRUNCH } _dino_state; void Routine(void* unused); bool dinoDied(); diff --git a/fw/Core/Hitcon/Secret/secret.h b/fw/Core/Hitcon/Secret/secret.h index 25ab34d..5d0bf76 100644 --- a/fw/Core/Hitcon/Secret/secret.h +++ b/fw/Core/Hitcon/Secret/secret.h @@ -8,7 +8,11 @@ constexpr button_t COMBO_BUTTON[] = { BUTTON_UP, BUTTON_UP, BUTTON_DOWN, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT, BUTTON_LEFT, BUTTON_RIGHT, BUTTON_BRIGHTNESS, BUTTON_MODE, }; +constexpr button_t COMBO_BUTTON_DINO[] = { + BUTTON_DOWN, BUTTON_DOWN, BUTTON_RIGHT, BUTTON_RIGHT, BUTTON_OK +}; constexpr size_t COMBO_BUTTON_LEN = sizeof(COMBO_BUTTON) / sizeof(button_t); +constexpr size_t COMBO_BUTTON_DINO_LEN = sizeof(COMBO_BUTTON_DINO) / sizeof(button_t); extern int combo_button_ctr; constexpr uint8_t kGameAchievementData[] = {