-#define FONT_NAME "-*-times-*-*-*-*-18-*-*-*-*-*-*-*"
-
-static Display *dpy;
-static Window window;
-static int Width, Height;
-static GC fg_gc, bg_gc, text_fg_gc, text_bg_gc;
-static char *words;
-static char *get_words (void);
-static int x, y;
-static XFontStruct *font;
-static char *def_words = "I'm out running around.";
-static void walk (int dir);
-static void talk (int erase);
-static void talk_1 (void);
-static int think (void);
-static unsigned long interval;
-static unsigned long look (void);
-static Pixmap left1, left2, right1, right2;
-static Pixmap left_front, right_front, front, down;
-
-static char *program, *orig_program, *filename, *text;
+
+
+struct state {
+ Display *dpy;
+ Window window;
+ int Width, Height;
+ GC fg_gc, bg_gc, text_fg_gc, text_bg_gc;
+ char *words;
+ int x, y;
+ XFontStruct *font;
+
+ unsigned long interval;
+ Pixmap left1, left2, right1, right2;
+ Pixmap left_front, right_front, front, down;
+
+ char *program, *orig_program;
+
+ int state; /* indicates states: walking or getting passwd */
+ int first_time;
+
+ void (*next_fn) (struct state *);
+
+ int move_length, move_dir;
+
+ int walk_lastdir;
+ int walk_up;
+ Pixmap walk_frame;
+
+ int X, Y, talking;
+
+ struct {
+ int x, y, width, height;
+ } s_rect;
+
+ char word_buf[BUFSIZ];
+};
+
+static char *get_words (struct state *);
+static void walk (struct state *, int dir);
+static void talk (struct state *, int erase);
+static void talk_1 (struct state *);
+static int think (struct state *);
+static unsigned long look (struct state *);