From bb3d9b5a7d9f27925fc7284fcb2394b29406be8d Mon Sep 17 00:00:00 2001 From: hubertf Date: Sun, 3 Jan 1999 02:00:17 +0000 Subject: Add previewing of next shape. Old (previous) behaviour can be restored by compiling with NO_PREVIEW defined. --- tetris/screen.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'tetris/screen.c') 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++) { -- cgit v1.2.3-56-ge451