Refactor WalkerHackScreen, close on success
All checks were successful
Build and Publish WASM version of demo / Build-And-Deploy (push) Successful in 22s
All checks were successful
Build and Publish WASM version of demo / Build-And-Deploy (push) Successful in 22s
This commit is contained in:
parent
bfa1e31305
commit
8b44a59317
2 changed files with 15 additions and 16 deletions
|
@ -61,8 +61,7 @@ bool WalkerHackScreen::update(float dt, bool resized) {
|
||||||
GetScreenWidth() / 2 - type_f_size - BUTTON_DRAW_OFFSET &&
|
GetScreenWidth() / 2 - type_f_size - BUTTON_DRAW_OFFSET &&
|
||||||
GetTouchX() <= GetScreenWidth() / 2 - BUTTON_DRAW_OFFSET &&
|
GetTouchX() <= GetScreenWidth() / 2 - BUTTON_DRAW_OFFSET &&
|
||||||
GetTouchY() <= font_size) {
|
GetTouchY() <= font_size) {
|
||||||
*walker_hack_success = true;
|
on_success();
|
||||||
button_type = BUTTON_TYPE_SIZE;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BUTTON_TYPE_J:
|
case BUTTON_TYPE_J:
|
||||||
|
@ -70,8 +69,7 @@ bool WalkerHackScreen::update(float dt, bool resized) {
|
||||||
GetTouchX() <=
|
GetTouchX() <=
|
||||||
GetScreenWidth() / 2 + BUTTON_DRAW_OFFSET + type_j_size &&
|
GetScreenWidth() / 2 + BUTTON_DRAW_OFFSET + type_j_size &&
|
||||||
GetTouchY() <= font_size) {
|
GetTouchY() <= font_size) {
|
||||||
*walker_hack_success = true;
|
on_success();
|
||||||
button_type = BUTTON_TYPE_SIZE;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BUTTON_TYPE_A:
|
case BUTTON_TYPE_A:
|
||||||
|
@ -80,8 +78,7 @@ bool WalkerHackScreen::update(float dt, bool resized) {
|
||||||
GetTouchX() <= GetScreenWidth() / 2 - BUTTON_DRAW_OFFSET &&
|
GetTouchX() <= GetScreenWidth() / 2 - BUTTON_DRAW_OFFSET &&
|
||||||
GetTouchY() >= font_size + BUTTON_DRAW_OFFSET &&
|
GetTouchY() >= font_size + BUTTON_DRAW_OFFSET &&
|
||||||
GetTouchY() <= font_size * 2 + BUTTON_DRAW_OFFSET) {
|
GetTouchY() <= font_size * 2 + BUTTON_DRAW_OFFSET) {
|
||||||
*walker_hack_success = true;
|
on_success();
|
||||||
button_type = BUTTON_TYPE_SIZE;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BUTTON_TYPE_L:
|
case BUTTON_TYPE_L:
|
||||||
|
@ -90,8 +87,7 @@ bool WalkerHackScreen::update(float dt, bool resized) {
|
||||||
GetScreenWidth() / 2 + BUTTON_DRAW_OFFSET + type_l_size &&
|
GetScreenWidth() / 2 + BUTTON_DRAW_OFFSET + type_l_size &&
|
||||||
GetTouchY() >= font_size + BUTTON_DRAW_OFFSET &&
|
GetTouchY() >= font_size + BUTTON_DRAW_OFFSET &&
|
||||||
GetTouchY() <= font_size * 2 + BUTTON_DRAW_OFFSET) {
|
GetTouchY() <= font_size * 2 + BUTTON_DRAW_OFFSET) {
|
||||||
*walker_hack_success = true;
|
on_success();
|
||||||
button_type = BUTTON_TYPE_SIZE;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -102,26 +98,22 @@ bool WalkerHackScreen::update(float dt, bool resized) {
|
||||||
switch (GetKeyPressed()) {
|
switch (GetKeyPressed()) {
|
||||||
case KEY_F:
|
case KEY_F:
|
||||||
if (button_type == BUTTON_TYPE_F) {
|
if (button_type == BUTTON_TYPE_F) {
|
||||||
*walker_hack_success = true;
|
on_success();
|
||||||
button_type = BUTTON_TYPE_SIZE;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_J:
|
case KEY_J:
|
||||||
if (button_type == BUTTON_TYPE_J) {
|
if (button_type == BUTTON_TYPE_J) {
|
||||||
*walker_hack_success = true;
|
on_success();
|
||||||
button_type = BUTTON_TYPE_SIZE;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_A:
|
case KEY_A:
|
||||||
if (button_type == BUTTON_TYPE_A) {
|
if (button_type == BUTTON_TYPE_A) {
|
||||||
*walker_hack_success = true;
|
on_success();
|
||||||
button_type = BUTTON_TYPE_SIZE;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_L:
|
case KEY_L:
|
||||||
if (button_type == BUTTON_TYPE_L) {
|
if (button_type == BUTTON_TYPE_L) {
|
||||||
*walker_hack_success = true;
|
on_success();
|
||||||
button_type = BUTTON_TYPE_SIZE;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -191,3 +183,9 @@ void WalkerHackScreen::set_sizes() {
|
||||||
type_a_size = MeasureText("A", font_size);
|
type_a_size = MeasureText("A", font_size);
|
||||||
type_l_size = MeasureText("L", 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;
|
||||||
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ class WalkerHackScreen : public Screen {
|
||||||
bool screen_pop_requested;
|
bool screen_pop_requested;
|
||||||
|
|
||||||
void set_sizes();
|
void set_sizes();
|
||||||
|
void on_success();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue