2048: Use the arrow keys and the Home key as input
All checks were successful
Build and test / build (push) Successful in 1m53s

This commit is contained in:
apio 2024-03-06 20:34:13 +01:00
parent fc37634a18
commit 70c63572b2
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -50,9 +50,9 @@ class GameWidget final : public ui::Widget
bool should_add_tile = false; bool should_add_tile = false;
switch (request.key) switch (request.code)
{ {
case 'w': { case moon::K_UpArrow: {
bool changed; bool changed;
changed = move_up(); changed = move_up();
if (changed) should_add_tile = true; if (changed) should_add_tile = true;
@ -61,7 +61,7 @@ class GameWidget final : public ui::Widget
if (changed) should_add_tile = true; if (changed) should_add_tile = true;
} }
break; break;
case 'a': { case moon::K_LeftArrow: {
bool changed; bool changed;
changed = move_left(); changed = move_left();
if (changed) should_add_tile = true; if (changed) should_add_tile = true;
@ -70,7 +70,7 @@ class GameWidget final : public ui::Widget
if (changed) should_add_tile = true; if (changed) should_add_tile = true;
} }
break; break;
case 's': { case moon::K_DownArrow: {
bool changed; bool changed;
changed = move_down(); changed = move_down();
if (changed) should_add_tile = true; if (changed) should_add_tile = true;
@ -79,7 +79,7 @@ class GameWidget final : public ui::Widget
if (changed) should_add_tile = true; if (changed) should_add_tile = true;
} }
break; break;
case 'd': { case moon::K_RightArrow: {
bool changed; bool changed;
changed = move_right(); changed = move_right();
if (changed) should_add_tile = true; if (changed) should_add_tile = true;
@ -88,7 +88,7 @@ class GameWidget final : public ui::Widget
if (changed) should_add_tile = true; if (changed) should_add_tile = true;
} }
break; break;
case 'r': { case moon::K_Home: {
reset(); reset();
return ui::EventResult::DidHandle; return ui::EventResult::DidHandle;
} }