Module Name: src
Committed By: kre
Date: Fri May 12 13:29:41 UTC 2023
Modified Files:
src/games/worms: worms.c
Log Message:
When using -H, make the appearance of the worm head depend upon the body
(more than it did before).
To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/games/worms/worms.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/games/worms/worms.c
diff -u src/games/worms/worms.c:1.30 src/games/worms/worms.c:1.31
--- src/games/worms/worms.c:1.30 Wed Apr 26 22:58:09 2023
+++ src/games/worms/worms.c Fri May 12 13:29:41 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: worms.c,v 1.30 2023/04/26 22:58:09 kre Exp $ */
+/* $NetBSD: worms.c,v 1.31 2023/05/12 13:29:41 kre Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
#if 0
static char sccsid[] = "@(#)worms.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: worms.c,v 1.30 2023/04/26 22:58:09 kre Exp $");
+__RCSID("$NetBSD: worms.c,v 1.31 2023/05/12 13:29:41 kre Exp $");
#endif
#endif /* not lint */
@@ -173,6 +173,11 @@ static const char flavor[] = {
'+', 'x', ':', '^', '_', '&', '@', 'w'
};
static const int flavors = __arraycount(flavor);
+static const char eyeball[] = {
+ '0', 'X', '@', 'S', 'X', '@', 'O', '=',
+ '#', '*', '=', 'v', 'L', '@', 'o', 'm'
+};
+__CTASSERT(sizeof(flavor) == sizeof(eyeball));
static const short xinc[] = {
1, 1, 1, 0, -1, -1, -1, 0
@@ -182,7 +187,7 @@ static const short xinc[] = {
static struct worm {
int orientation, head, len;
short *xpos, *ypos;
- chtype ch, attr;
+ chtype ch, eye, attr;
} *worm;
static volatile sig_atomic_t sig_caught;
@@ -447,6 +452,7 @@ main(int argc, char *argv[])
w->attr = nc ? ctab[n % nc] : 0;
i = (nc && number > flavors ? n / nc : n) % flavors;
w->ch = flavor[i];
+ w->eye = eyeball[i];
if (!(ip = malloc((size_t)(w->len * sizeof(short)))))
nomem();
@@ -493,7 +499,7 @@ main(int argc, char *argv[])
sleep(delay / 1000000);
}
for (n = 0, w = &worm[0]; n < number; n++, w++) {
- chtype c = docaput ? (w->ch == '@' ? '0' : '@') : w->ch;
+ chtype c = docaput ? w->eye : w->ch;
if ((x = w->xpos[h = w->head]) < 0) {
mvaddch(y = w->ypos[h] = bottom,