#include <string.h>
#include <time.h>
#include <sys/time.h>
+#include <unistd.h>
#include "constant.h"
#include "debug.h"
int scale = 1;
int height = 20;
-int width = 9;
+int minwidth = 8;
+int width = 10;
+int maxwidth = 15;
int nbdigit = 5;
int maxscor = 100000;
int usage (int ret)
{
FILE *fd = ret ? stderr : stdout;
- fprintf (fd, "usage: %s [-f file] [-h] [-s int] [-v level]\n", progname);
+ fprintf (fd, "usage: %s [-f file] [-h] [-s int] [-v int] [-w int]\n", progname);
fprintf (fd, " -f: file name (%s)\n", (filename) ? filename : "none");
fprintf (fd, " -s: scale [0..3] (%d)\n", scale);
fprintf (fd, " -v: verbose level (%d)\n", verbose);
+ fprintf (fd, " -w: board width [%d, %d] (%d)\n", minwidth, maxwidth, width);
fprintf (fd, "%s version %s\n", progname, version);
return ret;
}
verbose = atoi (arg);
break;
+ case 'w':
+ arg = (arg[2]) ? arg + 2 : (--argc > 0) ? *(++argv) : NULL;
+ if (arg == NULL) {
+ VERBOSE (ERROR, fprintf (stderr, "%s: no width specified\n", progname));
+ return usage (1);
+ }
+ width = atoi (arg);
+ break;
case 'h':
default:
return usage (c != 'h');
VERBOSE (ERROR, fprintf (stderr, "incorrect scale (%d)\n", scale));
return 1;
}
+ if ((width < minwidth) || (width > maxwidth)) {
+ VERBOSE (ERROR, fprintf (stderr, "incorrect width (%d)\n", width));
+ return 1;
+ }
/* init all variables */
board_t *board = NULL;
while (nblines-- > 0) {
boardwindow (board, 0);
stackboard (board);
+ usleep ((200 + 2000 / (lines / 10 + 1)) * 100);
+ refresh ();
}
boardwindow (board, 0);
scorewindow (xscore, yscore, nbdigit, score, (lines / 10) + 1);
/* test: tetris.exe -s 2>&1 | grep 'no scale' */
/* test: tetris.exe -s 4 2>&1 | grep incorrect */
/* test: tetris.exe -v 2>&1 | grep missing */
+/* test: tetris.exe -w 2>&1 | grep 'no width' */
+/* test: tetris.exe -w 6 2>&1 | grep incorrect */
/* test: tetris.exe _ 2>&1 | grep invalid */
/* test: { sleep 1; echo -n s; sleep 1; echo ouuljk; sleep 1; echo q; } | tetris.exe -s 0 */
/* test: { sleep 1; echo -n s; sleep 1; echo ouuljk; sleep 1; echo q; } | tetris.exe -s 1 */
/* test: { sleep 1; echo -n s; sleep 1; echo ouuljk; sleep 1; echo q; } | tetris.exe -s 2 */
/* test: { sleep 1; echo -n s; sleep 1; echo ouuljk; sleep 1; echo q; } | tetris.exe -s 3 */
/* test: { sleep 1; echo -n skkkkkkkkkkkkkkkkkk; sleep 6; echo -n kkkkkkkkkkkkkkkkk; sleep 1; echo q; } | tetris.exe */
-/* test: { sleep 1; echo -n s; sleep 1; echo oup; sleep 1; echo puljk; sleep 1; echo -ne 'sb.ttr\e'; sleep 1; echo -e 'sab\b.ttr'; sleep 1; echo q; } | tetris.exe -v 3 */
+/* test: { sleep 1; echo -n s; sleep 1; echo oup; sleep 1; echo puljk; sleep 1; echo -ne 'sb.ttr\e'; sleep 1; echo -e 'sab\b.ttr'; sleep 1; echo q; } | tetris.exe -w 9 -v 3 */
/* test: { sleep 1; echo -n s; sleep 1; echo q; } | tetris.exe -f a.ttr && rm a.ttr && test \! -f b.ttr */
-/* test: { echo -n s; sleep 1; echo ooolllk; sleep 1; echo uuukjjj; sleep 1; echo ooolllk; sleep 1; echo uuukjjj; sleep 1; echo ooolllk; sleep 1; echo uuukjjj; sleep 1; echo ooolllk; sleep 1; echo uuukjjj; sleep 1; echo cccc; sleep 1; echo q; } | tetris.exe */
-/* test: { echo -n s; sleep 1; echo lllololo; sleep 1; echo jjjujuju; sleep 1; echo lllololo; sleep 1; echo jjjujuju; sleep 1; echo q; } | tetris.exe */
+/* test: { echo -n s; sleep 1; echo ooollllk; sleep 1; echo uuukjjjj; sleep 1; echo ooollllk; sleep 1; echo uuukjjjj; sleep 1; echo ooollllk; sleep 1; echo uuukjjjj; sleep 1; echo ooollllk; sleep 1; echo uuukjjjj; sleep 1; echo cccc; sleep 1; echo q; } | tetris.exe -w 9 */
+/* test: { echo -n s; sleep 1; echo lllololo; sleep 1; echo jjjujuju; sleep 1; echo lllololo; sleep 1; echo jjjujuju; sleep 1; echo q; } | tetris.exe -w 9*/
/* test: { echo -n s; sleep 1; echo ccccccccccccc; sleep 1; echo q; } | tetris.exe */
-/* test: { echo -n s; sleep 1; echo -n jjuuc; sleep 1; echo -n jjc; sleep 1; echo q; } | tetris.exe -f lines.ttr */
+/* test: { echo -n s; sleep 1; echo -n jjuuuc; sleep 1; echo -n jjoc; sleep 1; echo q; } | tetris.exe -f lines.ttr */
/* vim: set ts=4 sw=4 et: */