]> git.seodisparate.com - jumpartifact.com_demo_0/commitdiff
Refactor WalkerHackScreen, close on success
authorStephen Seo <seo.disparate@gmail.com>
Thu, 24 Aug 2023 06:55:27 +0000 (15:55 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Thu, 24 Aug 2023 06:55:27 +0000 (15:55 +0900)
src/screen_walker_hack.cc
src/screen_walker_hack.h

index c07a22fdf852d31903989f1c6758675be9e23a50..7b1764be0b9b291acae150f57492b2a3b4bffa94 100644 (file)
@@ -61,8 +61,7 @@ bool WalkerHackScreen::update(float dt, bool resized) {
                 GetScreenWidth() / 2 - type_f_size - BUTTON_DRAW_OFFSET &&
             GetTouchX() <= GetScreenWidth() / 2 - BUTTON_DRAW_OFFSET &&
             GetTouchY() <= font_size) {
-          *walker_hack_success = true;
-          button_type = BUTTON_TYPE_SIZE;
+          on_success();
         }
         break;
       case BUTTON_TYPE_J:
@@ -70,8 +69,7 @@ bool WalkerHackScreen::update(float dt, bool resized) {
             GetTouchX() <=
                 GetScreenWidth() / 2 + BUTTON_DRAW_OFFSET + type_j_size &&
             GetTouchY() <= font_size) {
-          *walker_hack_success = true;
-          button_type = BUTTON_TYPE_SIZE;
+          on_success();
         }
         break;
       case BUTTON_TYPE_A:
@@ -80,8 +78,7 @@ bool WalkerHackScreen::update(float dt, bool resized) {
             GetTouchX() <= GetScreenWidth() / 2 - BUTTON_DRAW_OFFSET &&
             GetTouchY() >= font_size + BUTTON_DRAW_OFFSET &&
             GetTouchY() <= font_size * 2 + BUTTON_DRAW_OFFSET) {
-          *walker_hack_success = true;
-          button_type = BUTTON_TYPE_SIZE;
+          on_success();
         }
         break;
       case BUTTON_TYPE_L:
@@ -90,8 +87,7 @@ bool WalkerHackScreen::update(float dt, bool resized) {
                 GetScreenWidth() / 2 + BUTTON_DRAW_OFFSET + type_l_size &&
             GetTouchY() >= font_size + BUTTON_DRAW_OFFSET &&
             GetTouchY() <= font_size * 2 + BUTTON_DRAW_OFFSET) {
-          *walker_hack_success = true;
-          button_type = BUTTON_TYPE_SIZE;
+          on_success();
         }
         break;
       default:
@@ -102,26 +98,22 @@ bool WalkerHackScreen::update(float dt, bool resized) {
   switch (GetKeyPressed()) {
     case KEY_F:
       if (button_type == BUTTON_TYPE_F) {
-        *walker_hack_success = true;
-        button_type = BUTTON_TYPE_SIZE;
+        on_success();
       }
       break;
     case KEY_J:
       if (button_type == BUTTON_TYPE_J) {
-        *walker_hack_success = true;
-        button_type = BUTTON_TYPE_SIZE;
+        on_success();
       }
       break;
     case KEY_A:
       if (button_type == BUTTON_TYPE_A) {
-        *walker_hack_success = true;
-        button_type = BUTTON_TYPE_SIZE;
+        on_success();
       }
       break;
     case KEY_L:
       if (button_type == BUTTON_TYPE_L) {
-        *walker_hack_success = true;
-        button_type = BUTTON_TYPE_SIZE;
+        on_success();
       }
       break;
     default:
@@ -191,3 +183,9 @@ void WalkerHackScreen::set_sizes() {
   type_a_size = MeasureText("A", font_size);
   type_l_size = MeasureText("L", font_size);
 }
+
+void WalkerHackScreen::on_success() {
+  *walker_hack_success = true;
+  button_type = BUTTON_TYPE_SIZE;
+  timer = -1.0F;
+}
index a1aa1eb521763c4683adaf84a483206ca529c8ef..7fe395f363b91d2b7656232fe9d55a291072e1e0 100644 (file)
@@ -46,6 +46,7 @@ class WalkerHackScreen : public Screen {
   bool screen_pop_requested;
 
   void set_sizes();
+  void on_success();
 };
 
 #endif