summaryrefslogtreecommitdiffstats
path: root/worm
diff options
context:
space:
mode:
authorjsm <jsm@NetBSD.org>2001-08-30 10:49:50 +0000
committerjsm <jsm@NetBSD.org>2001-08-30 10:49:50 +0000
commitb832dece316930d89df04476c872cb967a95c7e5 (patch)
tree0cc299727daa1f805de066c3fb9c9454b05daa8f /worm
parenta732088281237e9473035a811c4203e82a2efb04 (diff)
downloadbsdgames-darwin-b832dece316930d89df04476c872cb967a95c7e5.tar.gz
bsdgames-darwin-b832dece316930d89df04476c872cb967a95c7e5.tar.zst
bsdgames-darwin-b832dece316930d89df04476c872cb967a95c7e5.zip
Check for screen sizes that are too small. Fix off-by-one error in
trying to place the prize. Position the score appropriately for screens that may not be 80 columns wide.
Diffstat (limited to 'worm')
-rw-r--r--worm/worm.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/worm/worm.c b/worm/worm.c
index f6e1be7c..67dfc20f 100644
--- a/worm/worm.c
+++ b/worm/worm.c
@@ -1,4 +1,4 @@
-/* $NetBSD: worm.c,v 1.20 2001/08/29 23:25:58 jsm Exp $ */
+/* $NetBSD: worm.c,v 1.21 2001/08/30 10:49:50 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
#if 0
static char sccsid[] = "@(#)worm.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: worm.c,v 1.20 2001/08/29 23:25:58 jsm Exp $");
+__RCSID("$NetBSD: worm.c,v 1.21 2001/08/30 10:49:50 jsm Exp $");
#endif
#endif /* not lint */
@@ -117,6 +117,15 @@ main(argc, argv)
#endif
slow = (baudrate() <= 1200);
clear();
+ if (COLS < 18 || LINES < 5) {
+ /*
+ * Insufficient room for the line with " Worm" and the
+ * score if fewer than 18 columns; insufficient room for
+ * anything much if fewer than 5 lines.
+ */
+ endwin();
+ errx(1, "screen too small");
+ }
if (argc == 2)
start_len = atoi(argv[1]);
if ((start_len <= 0) || (start_len > ((LINES-3) * (COLS-2)) / 3))
@@ -225,7 +234,7 @@ newpos(bp)
struct body * bp;
{
do {
- bp->y = rnd(LINES-3)+ 2;
+ bp->y = rnd(LINES-3)+ 1;
bp->x = rnd(COLS-3) + 1;
wmove(tv, bp->y, bp->x);
} while(winch(tv) != ' ');
@@ -311,7 +320,7 @@ process(ch)
prize();
score += growing;
running = 0;
- wmove(stw, 0, 68);
+ wmove(stw, 0, COLS - 12);
wprintw(stw, "Score: %3d", score);
wrefresh(stw);
}