Index: tetris.6 =================================================================== RCS file: /cvsroot/src/games/tetris/tetris.6,v retrieving revision 1.14 diff -p -u -r1.14 tetris.6 --- tetris.6 15 Jul 2014 16:17:15 -0000 1.14 +++ tetris.6 18 Feb 2015 11:56:33 -0000 @@ -32,7 +32,7 @@ .\" .\" @(#)tetris.6 8.1 (Berkeley) 5/31/93 .\" -.Dd July 13, 2014 +.Dd February 18, 2015 .Dt TETRIS 6 .Os .Sh NAME @@ -69,6 +69,8 @@ drop pause .It q quit +.It n +down .El .Pp The options are as follows: @@ -84,11 +86,11 @@ The default control keys can be changed option. The .Ar keys -argument must have the six keys in order, and, remember to quote any +argument must have the seven keys in order, and, remember to quote any space or tab characters from the shell. For example: .sp -.Dl "tetris -l 2 -k 'jkl pq'" +.Dl "tetris -l 2 -k 'jkl pqn'" .sp will play the default games, i.e. level 2 and with the default control keys. Index: tetris.c =================================================================== RCS file: /cvsroot/src/games/tetris/tetris.c,v retrieving revision 1.27 diff -p -u -r1.27 tetris.c --- tetris.c 13 Jul 2014 17:38:38 -0000 1.27 +++ tetris.c 18 Feb 2015 11:56:33 -0000 @@ -130,7 +130,8 @@ main(int argc, char *argv[]) int pos, c; const char *keys; int level = 2; - char key_write[6][10]; +#define NUMKEYS 7 + char key_write[NUMKEYS][10]; int ch, i, j; int fd; @@ -143,7 +144,7 @@ main(int argc, char *argv[]) exit(1); close(fd); - keys = "jkl pq"; + keys = "jkl pqn"; while ((ch = getopt(argc, argv, "bk:l:ps")) != -1) switch(ch) { @@ -151,7 +152,7 @@ main(int argc, char *argv[]) nocolor = 1; break; case 'k': - if (strlen(keys = optarg) != 6) + if (strlen(keys = optarg) != NUMKEYS) usage(); break; case 'l': @@ -180,8 +181,8 @@ main(int argc, char *argv[]) fallrate = 1000000 / level; - for (i = 0; i <= 5; i++) { - for (j = i+1; j <= 5; j++) { + for (i = 0; i <= (NUMKEYS-1); i++) { + for (j = i+1; j <= (NUMKEYS-1); j++) { if (keys[i] == keys[j]) { errx(1, "duplicate command keys specified."); } @@ -195,9 +196,9 @@ main(int argc, char *argv[]) } snprintf(key_msg, sizeof(key_msg), -"%s - left %s - rotate %s - right %s - drop %s - pause %s - quit", +"%s - left %s - rotate %s - right %s - drop %s - pause %s - quit %s - down", key_write[0], key_write[1], key_write[2], key_write[3], - key_write[4], key_write[5]); + key_write[4], key_write[5], key_write[6]); (void)signal(SIGINT, onintr); scr_init(); @@ -297,6 +298,14 @@ main(int argc, char *argv[]) } continue; } + if (c == keys[6]) { + /* move down */ + if (fits_in(curshape, pos + B_COLS)) { + pos += B_COLS; + score++; + } + continue; + } if (c == '\f') { scr_clear(); scr_msg(key_msg, 1);