summaryrefslogtreecommitdiffstats
path: root/tetris/screen.c
diff options
context:
space:
mode:
authorhubertf <hubertf@NetBSD.org>1999-01-03 02:00:17 +0000
committerhubertf <hubertf@NetBSD.org>1999-01-03 02:00:17 +0000
commitbb3d9b5a7d9f27925fc7284fcb2394b29406be8d (patch)
treeb098b9b517a645916326699d028008cd33c73a61 /tetris/screen.c
parent88ddc247b226dce915bba2681778e7926086e59a (diff)
downloadbsdgames-darwin-bb3d9b5a7d9f27925fc7284fcb2394b29406be8d.tar.gz
bsdgames-darwin-bb3d9b5a7d9f27925fc7284fcb2394b29406be8d.tar.zst
bsdgames-darwin-bb3d9b5a7d9f27925fc7284fcb2394b29406be8d.zip
Add previewing of next shape. Old (previous) behaviour can be
restored by compiling with NO_PREVIEW defined.
Diffstat (limited to 'tetris/screen.c')
-rw-r--r--tetris/screen.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/tetris/screen.c b/tetris/screen.c
index fe0e21ad..c4a4ff87 100644
--- a/tetris/screen.c
+++ b/tetris/screen.c
@@ -1,4 +1,4 @@
-/* $NetBSD: screen.c,v 1.7 1998/08/10 02:25:45 perry Exp $ */
+/* $NetBSD: screen.c,v 1.8 1999/01/03 02:00:18 hubertf Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -279,8 +279,8 @@ scr_set()
Cols = COnum;
if (Rows < MINROWS || Cols < MINCOLS) {
(void) fprintf(stderr,
- "the screen is too small: must be at least %d x %d",
- MINROWS, MINCOLS);
+ "the screen is too small: must be at least %dx%d, ",
+ MINCOLS, MINROWS);
stop(""); /* stop() supplies \n */
}
if (tcgetattr(0, &oldtt) < 0)
@@ -376,6 +376,7 @@ scr_update()
register regcell so, cur_so = 0;
register int i, ccol, j;
sigset_t sigset, osigset;
+ static struct shape *lastshape;
sigemptyset(&sigset);
sigaddset(&sigset, SIGTSTP);
@@ -389,10 +390,47 @@ scr_update()
putpad(HOstr);
else
moveto(0, 0);
- (void) printf("%d", score);
+ (void) printf("Score: %d", score);
curscore = score;
}
+#ifndef NO_PREVIEW
+ /* draw preview of nextpattern */
+ if (nextshape != lastshape) {
+ int i;
+ static int r=5, c=2;
+ int tr, tc, t;
+
+ lastshape = nextshape;
+
+ /* clean */
+ putpad(SEstr);
+ moveto(r-1, c-1); putstr(" ");
+ moveto(r, c-1); putstr(" ");
+ moveto(r+1, c-1); putstr(" ");
+ moveto(r+2, c-1); putstr(" ");
+
+ moveto(r-3, c-2);
+ putstr("Next shape:");
+
+ /* draw */
+ putpad(SOstr);
+ moveto(r, 2*c);
+ putstr(" ");
+ for(i=0; i<3; i++) {
+ t = c + r*B_COLS;
+ t += nextshape->off[i];
+
+ tr = t / B_COLS;
+ tc = t % B_COLS;
+
+ moveto(tr, 2*tc);
+ putstr(" ");
+ }
+ putpad(SEstr);
+ }
+#endif
+
bp = &board[D_FIRST * B_COLS];
sp = &curscreen[D_FIRST * B_COLS];
for (j = D_FIRST; j < D_LAST; j++) {