summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-rw-r--r--2048.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/2048.c b/2048.c
index 8546d4b..48c13cb 100644
--- a/2048.c
+++ b/2048.c
@@ -186,6 +186,8 @@ enum {
 	GridX = 2,
 	ScoreY = 0,
 	ScoreX = GridX + 4 * TileWidth - 10,
+	HelpY = GridY,
+	HelpX = GridX + 5 * TileWidth,
 };
 
 static void drawTile(uint y, uint x) {
@@ -225,6 +227,12 @@ static void draw(void) {
 	}
 }
 
+static void drawHelp(void) {
+	mvaddstr(HelpY + 0, HelpX, "Use the arrow keys to");
+	mvaddstr(HelpY + 1, HelpX, "slide and merge tiles.");
+	mvaddstr(HelpY + 2, HelpX, "Press q to quit.");
+}
+
 static bool input(void) {
 	switch (getch()) {
 		break; case 'h': case KEY_LEFT: if (left()) spawn();
@@ -240,7 +248,10 @@ uint play2048(void) {
 	curse();
 	spawn();
 	spawn();
+	drawHelp();
+	uint help = 0;
 	do {
+		if (help++ == 3) erase();
 		draw();
 	} while (input());
 	return score;
gmsg'> 2022-03-16Remove wcwidth portJune McEnroe DYLD_FORCE_FLAT_NAMESPACE no longer exists in macOS 12 so this approach doesn't work anymore. Moved to <https://git.causal.agency/jorts/tree/wcwidth> and compiled into <https://git.causal.agency/jorts/tree/ncurses>. 2022-03-16Remove -j4 from ./PlanJune McEnroe Plan learned to set this automatically! 2022-03-15Rewrite Linux install.sh for DebianJune McEnroe 2022-03-15Remove dashJune McEnroe