From 60252bba3a2f9dc351c8df363f58d594193663ff Mon Sep 17 00:00:00 2001 From: Andrew Paon Date: Sun, 16 Apr 2023 19:40:48 -0700 Subject: [PATCH] Add a constant for backspace --- main.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index e958478..54b06a3 100644 --- a/main.c +++ b/main.c @@ -590,18 +590,21 @@ void game_main() { "| SHIFT+Q .................. EXIT |\n" "+------------------------------------------+\n"; + const char backspace = 127; + while (1) { render(game); puts(controls); char c; + switch (game.state) { case CHOOSING_PIECE: printf("Pick piece [a-c]: "); c = getc(stdin); switch (c) { - case /* backspace */ 127: { + case backspace: { struct Game t = game; game = prev; prev = t; @@ -631,7 +634,7 @@ void game_main() { c = getc(stdin); switch (c) { - case /* backspace */ 127: + case backspace: game.state = CHOOSING_PIECE; continue; @@ -648,13 +651,13 @@ void game_main() { game.state = CHOOSING_ROW; break; - case CHOOSING_ROW: + case CHOOSING_ROW: { printf("Pick row [1-9]: "); c = getc(stdin); switch (c) { - case /* backspace */ 127: + case backspace: game.state = CHOOSING_COLUMN; continue; @@ -713,7 +716,8 @@ void game_main() { return; } - printf("\n%d\n", game.active_piece); + printf("\n%d\n", game.active_piece); + } } } -- 2.45.2