Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/worms When using -H, make the appearance of the worm h...



details:   https://anonhg.NetBSD.org/src/rev/c3ff7cc95df5
branches:  trunk
changeset: 374784:c3ff7cc95df5
user:      kre <kre%NetBSD.org@localhost>
date:      Fri May 12 13:29:41 2023 +0000

description:
When using -H, make the appearance of the worm head depend upon the body
(more than it did before).

diffstat:

 games/worms/worms.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (56 lines):

diff -r e89999ae0988 -r c3ff7cc95df5 games/worms/worms.c
--- a/games/worms/worms.c       Fri May 12 11:49:47 2023 +0000
+++ b/games/worms/worms.c       Fri May 12 13:29:41 2023 +0000
@@ -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 @@
 #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,



Home | Main Index | Thread Index | Old Index