|
@@ -1,3 +1,4 @@
|
|
|
|
|
+#include <getopt.h>
|
|
|
#include <curses.h>
|
|
#include <curses.h>
|
|
|
#include <unistd.h>
|
|
#include <unistd.h>
|
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
@@ -19,8 +20,12 @@ enum dirs {
|
|
|
D /* down */
|
|
D /* down */
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+static size_t delay = 500;
|
|
|
|
|
|
|
|
|
|
+/* result window */
|
|
|
static WINDOW * winR;
|
|
static WINDOW * winR;
|
|
|
|
|
+
|
|
|
|
|
+/* sprite */
|
|
|
static void worm(WINDOW *win, int x, int y, char c0, char repl)
|
|
static void worm(WINDOW *win, int x, int y, char c0, char repl)
|
|
|
{
|
|
{
|
|
|
static int ax, ay;
|
|
static int ax, ay;
|
|
@@ -35,9 +40,10 @@ static void worm(WINDOW *win, int x, int y, char c0, char repl)
|
|
|
ax = x;
|
|
ax = x;
|
|
|
ay = y;
|
|
ay = y;
|
|
|
ac = repl;
|
|
ac = repl;
|
|
|
- usleep(150 * 1000);
|
|
|
|
|
|
|
+ usleep(delay * 1000);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* path lookup */
|
|
|
static __attribute((malloc)) __attribute__((nonnull)) char *get_it(truc_array const *src)
|
|
static __attribute((malloc)) __attribute__((nonnull)) char *get_it(truc_array const *src)
|
|
|
{
|
|
{
|
|
|
char *r = mallocx(src->len, MALLOCX_ZERO);
|
|
char *r = mallocx(src->len, MALLOCX_ZERO);
|
|
@@ -159,6 +165,7 @@ end:
|
|
|
return r;
|
|
return r;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* puzzle display */
|
|
|
static void print_it(truc_array src)
|
|
static void print_it(truc_array src)
|
|
|
{
|
|
{
|
|
|
WINDOW * win = newwin(14, 18, 1, 1);
|
|
WINDOW * win = newwin(14, 18, 1, 1);
|
|
@@ -174,7 +181,23 @@ int main(int argc, char *argv[])
|
|
|
{
|
|
{
|
|
|
truc_array a= {60, };
|
|
truc_array a= {60, };
|
|
|
char *r = NULL;
|
|
char *r = NULL;
|
|
|
-
|
|
|
|
|
|
|
+ static struct option longopts[] = {
|
|
|
|
|
+ { "delay", required_argument, NULL, 'd' },
|
|
|
|
|
+ { NULL, 0, NULL, 0 }
|
|
|
|
|
+ };
|
|
|
|
|
+ int ch;
|
|
|
|
|
+ while ((ch = getopt_long(argc, argv, "d:", longopts, NULL)) != -1) {
|
|
|
|
|
+ switch (ch) {
|
|
|
|
|
+ case 'd':
|
|
|
|
|
+ delay = strtoul(optarg, NULL, 10);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ /* long option */
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/* 012345789ABCDEF */
|
|
/* 012345789ABCDEF */
|
|
|
a.items[0] = "*01** $";
|
|
a.items[0] = "*01** $";
|