diff options
-rw-r--r-- | games/tetris/screen.c | 10 | ||||
-rw-r--r-- | games/tetris/shapes.c | 40 | ||||
-rw-r--r-- | games/tetris/tetris.6 | 7 | ||||
-rw-r--r-- | games/tetris/tetris.c | 21 | ||||
-rw-r--r-- | games/tetris/tetris.h | 4 |
5 files changed, 49 insertions, 33 deletions
diff --git a/games/tetris/screen.c b/games/tetris/screen.c index e2584e70b2b..d345dbe4a49 100644 --- a/games/tetris/screen.c +++ b/games/tetris/screen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen.c,v 1.8 2002/05/31 04:21:30 pjanzen Exp $ */ +/* $OpenBSD: screen.c,v 1.9 2002/07/26 20:19:22 mickey Exp $ */ /* $NetBSD: screen.c,v 1.4 1995/04/29 01:11:36 mycroft Exp $ */ /*- @@ -179,6 +179,8 @@ scr_init() for (p = tcstrings; p->tcaddr; p++) *p->tcaddr = tgetstr(p->tcname, &fill); } + if (classic) + SOstr = SEstr = NULL; { struct tcninfo *p; @@ -412,7 +414,7 @@ scr_update() if (SOstr) putpad(SOstr); moveto(r, 2 * c); - putstr(SOstr ? " " : "XX"); + putstr(SOstr ? " " : "[]"); for (i = 0; i < 3; i++) { t = c + r * B_COLS; t += nextshape->off[i]; @@ -421,7 +423,7 @@ scr_update() tc = t % B_COLS; moveto(tr, 2*tc); - putstr(SOstr ? " " : "XX"); + putstr(SOstr ? " " : "[]"); } putpad(SEstr); } @@ -448,7 +450,7 @@ scr_update() } putstr(" "); } else - putstr(so ? "XX" : " "); + putstr(so ? "[]" : " "); ccol = i + 1; /* * Look ahead a bit, to avoid extra motion if diff --git a/games/tetris/shapes.c b/games/tetris/shapes.c index 5adb2544365..3158f37566b 100644 --- a/games/tetris/shapes.c +++ b/games/tetris/shapes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: shapes.c,v 1.4 2002/05/31 04:21:30 pjanzen Exp $ */ +/* $OpenBSD: shapes.c,v 1.5 2002/07/26 20:19:22 mickey Exp $ */ /* $NetBSD: shapes.c,v 1.2 1995/04/22 07:42:44 cgd Exp $ */ /*- @@ -58,25 +58,25 @@ #define BR B_COLS+1 /* bottom right */ struct shape shapes[] = { - /* 0*/ { 7, { TL, TC, MR } }, - /* 1*/ { 8, { TC, TR, ML } }, - /* 2*/ { 9, { ML, MR, BC } }, - /* 3*/ { 3, { TL, TC, ML } }, - /* 4*/ { 12, { ML, BL, MR } }, - /* 5*/ { 15, { ML, BR, MR } }, - /* 6*/ { 18, { ML, MR, 2 } }, /* sticks out */ - /* 7*/ { 0, { TC, ML, BL } }, - /* 8*/ { 1, { TC, MR, BR } }, - /* 9*/ { 10, { TC, MR, BC } }, - /*10*/ { 11, { TC, ML, MR } }, - /*11*/ { 2, { TC, ML, BC } }, - /*12*/ { 13, { TC, BC, BR } }, - /*13*/ { 14, { TR, ML, MR } }, - /*14*/ { 4, { TL, TC, BC } }, - /*15*/ { 16, { TR, TC, BC } }, - /*16*/ { 17, { TL, MR, ML } }, - /*17*/ { 5, { TC, BC, BL } }, - /*18*/ { 6, { TC, BC, 2*B_COLS } }/* sticks out */ + /* 0*/ { 7, 7, { TL, TC, MR } }, + /* 1*/ { 8, 8, { TC, TR, ML } }, + /* 2*/ { 9, 11, { ML, MR, BC } }, + /* 3*/ { 3, 3, { TL, TC, ML } }, + /* 4*/ { 12, 14, { ML, BL, MR } }, + /* 5*/ { 15, 17, { ML, BR, MR } }, + /* 6*/ { 18, 18, { ML, MR, 2 } }, /* sticks out */ + /* 7*/ { 0, 0, { TC, ML, BL } }, + /* 8*/ { 1, 1, { TC, MR, BR } }, + /* 9*/ { 10, 2, { TC, MR, BC } }, + /*10*/ { 11, 9, { TC, ML, MR } }, + /*11*/ { 2, 10, { TC, ML, BC } }, + /*12*/ { 13, 4, { TC, BC, BR } }, + /*13*/ { 14, 12, { TR, ML, MR } }, + /*14*/ { 4, 13, { TL, TC, BC } }, + /*15*/ { 16, 5, { TR, TC, BC } }, + /*16*/ { 17, 15, { TL, MR, ML } }, + /*17*/ { 5, 16, { TC, BC, BL } }, + /*18*/ { 6, 6, { TC, BC, 2*B_COLS } }/* sticks out */ }; /* diff --git a/games/tetris/tetris.6 b/games/tetris/tetris.6 index 9f92478dd36..a107039bd52 100644 --- a/games/tetris/tetris.6 +++ b/games/tetris/tetris.6 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tetris.6,v 1.10 2001/08/18 03:27:17 pjanzen Exp $ +.\" $OpenBSD: tetris.6,v 1.11 2002/07/26 20:19:22 mickey Exp $ .\" .\" Copyright (c) 1992, 1993 .\" The Regents of the University of California. All rights reserved. @@ -44,7 +44,7 @@ .Nd the game of tetris .Sh SYNOPSIS .Nm tetris -.Op Fl ps +.Op Fl cps .Op Fl k Ar keys .Op Fl l Ar level .Sh DESCRIPTION @@ -77,6 +77,9 @@ quit .Pp The options are as follows: .Bl -tag -width indent +.It Fl c +Classic tetris mode, in which shapes rotate clockwise and are drawn with +.Dq [] . .It Fl k Ar keys The default control keys can be changed using the .Fl k diff --git a/games/tetris/tetris.c b/games/tetris/tetris.c index 232b2ee778d..356588ace83 100644 --- a/games/tetris/tetris.c +++ b/games/tetris/tetris.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tetris.c,v 1.12 2002/05/31 04:21:30 pjanzen Exp $ */ +/* $OpenBSD: tetris.c,v 1.13 2002/07/26 20:19:22 mickey Exp $ */ /* $NetBSD: tetris.c,v 1.2 1995/04/22 07:42:47 cgd Exp $ */ /*- @@ -73,7 +73,7 @@ long fallrate; int score; gid_t gid, egid; char key_msg[100]; -int showpreview; +int showpreview, classic; static void elide(void); static void setup_board(void); @@ -134,7 +134,7 @@ randshape() tmp = &shapes[random() % 7]; j = random() % 4; for (i = 0; i < j; i++) - tmp = &shapes[tmp->rot]; + tmp = &shapes[classic? tmp->rotc : tmp->rot]; return (tmp); } @@ -156,9 +156,17 @@ main(argc, argv) egid = getegid(); setegid(gid); - showpreview = 0; - while ((ch = getopt(argc, argv, "hk:l:ps")) != -1) + classic = showpreview = 0; + while ((ch = getopt(argc, argv, "chk:l:ps")) != -1) switch(ch) { + case 'c': + /* + * this means: + * - rotate the other way; + * - no reverse video. + */ + classic = 1; + break; case 'k': if (strlen(keys = optarg) != 6) usage(); @@ -285,7 +293,8 @@ main(argc, argv) } if (c == keys[1]) { /* turn */ - struct shape *new = &shapes[curshape->rot]; + struct shape *new = &shapes[ + classic? curshape->rotc : curshape->rot]; if (fits_in(new, pos)) curshape = new; diff --git a/games/tetris/tetris.h b/games/tetris/tetris.h index e27f38602df..5502d289246 100644 --- a/games/tetris/tetris.h +++ b/games/tetris/tetris.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tetris.h,v 1.6 2002/02/16 21:27:12 millert Exp $ */ +/* $OpenBSD: tetris.h,v 1.7 2002/07/26 20:19:22 mickey Exp $ */ /* $NetBSD: tetris.h,v 1.2 1995/04/22 07:42:48 cgd Exp $ */ /*- @@ -127,6 +127,7 @@ extern int Rows, Cols; /* current screen size */ */ struct shape { int rot; /* index of rotated version of this shape */ + int rotc; /* -- " -- in classic version */ int off[3]; /* offsets to other blots if center is at (0,0) */ }; @@ -174,6 +175,7 @@ extern gid_t gid, egid; extern char key_msg[100]; extern int showpreview; +extern int classic; int fits_in(struct shape *, int); void place(struct shape *, int, int); |