From 384f833e839cf8f5e71b656cf7b390fc80d89e9d Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Wed, 1 Jun 2022 15:47:02 +0800 Subject: Help text, wasd/hjkl navigation --- sirtet.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'sirtet.c') diff --git a/sirtet.c b/sirtet.c index 9e9d0b2..3dc76f3 100644 --- a/sirtet.c +++ b/sirtet.c @@ -95,6 +95,7 @@ void sirtet() { clear(); printrect(0, 0, H, W); printmap(map, 1, 1, H, W); + printhelp(3, 2 * W + 8); // display game stats mvprintw(1, 2 * W + 8, "Points: %d", points); @@ -133,15 +134,23 @@ void sirtet() { break; // arrow keys: move piece on map case KEY_LEFT: + case 'a': + case 'h': if (col > 0) col--; break; case KEY_RIGHT: + case 'd': + case 'l': if (col + pc->w < W) col++; break; case KEY_UP: + case 'w': + case 'k': if (row > 0) row--; break; case KEY_DOWN: + case 's': + case 'j': if (row + pc->h < H) row++; break; // [ and ]: switch pieces @@ -165,6 +174,11 @@ void sirtet() { } } break; + // q: quit + case 'q': + confirmed = true; + over = true; + break; } } @@ -203,8 +217,8 @@ void sirtet() { } if (!has_placeable) { // game over - mvprintw(3, 2 * W + 8, "Game over"); - mvprintw(4, 2 * W + 8, "Press any key to exit"); + mvprintw(7, 2 * W + 8, "Game over"); + mvprintw(8, 2 * W + 8, "Press any key to exit"); refresh(); while (getch() == 0); over = true; -- cgit v1.2.3