~ajpaon/squell

60252bba3a2f9dc351c8df363f58d594193663ff — Andrew Paon 10 months ago e0703b5 master
Add a constant for backspace
1 files changed, 9 insertions(+), 5 deletions(-)

M main.c
M main.c => main.c +9 -5
@@ 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);
    }
  }
}