summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-11-12 23:05:11 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-11-12 23:06:34 +1300
commitecb9d88b492e13fb2ea3ce5e3af37ea03fc92443 (patch)
treefd73d5020eb6c89d5cd835eec17a0e189211d7ee
parentRephrase a loop (diff)
downloadtexad-ecb9d88b492e13fb2ea3ce5e3af37ea03fc92443.tar.gz
texad-ecb9d88b492e13fb2ea3ce5e3af37ea03fc92443.zip
Create header file
-rw-r--r--Makefile1
-rw-r--r--texad.c63
-rw-r--r--texad.h64
3 files changed, 66 insertions, 62 deletions
diff --git a/Makefile b/Makefile
index 1d1d2dd..258f9e2 100644
--- a/Makefile
+++ b/Makefile
@@ -2,5 +2,6 @@
.PHONY: all clean
ALL = texad
all: $(ALL)
+texad: texad.c texad.h
clean:
rm -f $(ALL)
diff --git a/texad.c b/texad.c
index d44e10e..6b18318 100644
--- a/texad.c
+++ b/texad.c
@@ -2,68 +2,7 @@
#include <stdlib.h>
#include <string.h>
-#define INPUT_LIMIT 256
-#define PROMPT "> "
-
-enum action {
- UNKNOWN,
- LOOK,
- GO_NORTH,
- GO_SOUTH,
- GO_EAST,
- GO_WEST,
- QUIT
-};
-
-enum direction {
- NORTH,
- SOUTH,
- EAST,
- WEST
-};
-
-struct room {
- char *title;
- char *description;
- struct door **doors;
-};
-
-struct door {
- enum direction direction;
- struct room *src;
- struct room *dst;
-};
-
-struct world {
- struct player *player;
-};
-
-struct player {
- char *name;
- struct room *room;
-};
-
-struct command {
- enum action action;
- char *string;
-};
-
-struct world *genesis(void);
-void apocalypse(struct world *);
-enum action parse(char *);
-void move(struct player *, enum direction);
-void look(struct room *);
-int loop(struct world *);
-
-static struct command commands[] = {
- {LOOK , "l" },
- {GO_NORTH , "n" },
- {GO_SOUTH , "s" },
- {GO_EAST , "e" },
- {GO_WEST , "w" },
- {QUIT , "q" },
- {UNKNOWN , NULL}
-};
+#include "texad.h"
struct world *genesis(void)
{
diff --git a/texad.h b/texad.h
new file mode 100644
index 0000000..ec65ef1
--- /dev/null
+++ b/texad.h
@@ -0,0 +1,64 @@
+#include <stdlib.h>
+
+#define INPUT_LIMIT 256
+#define PROMPT "> "
+
+enum action {
+ UNKNOWN,
+ LOOK,
+ GO_NORTH,
+ GO_SOUTH,
+ GO_EAST,
+ GO_WEST,
+ QUIT
+};
+
+enum direction {
+ NORTH,
+ SOUTH,
+ EAST,
+ WEST
+};
+
+struct room {
+ char *title;
+ char *description;
+ struct door **doors;
+};
+
+struct door {
+ enum direction direction;
+ struct room *src;
+ struct room *dst;
+};
+
+struct world {
+ struct player *player;
+};
+
+struct player {
+ char *name;
+ struct room *room;
+};
+
+struct command {
+ enum action action;
+ char *string;
+};
+
+struct world *genesis(void);
+void apocalypse(struct world *);
+enum action parse(char *);
+void move(struct player *, enum direction);
+void look(struct room *);
+int loop(struct world *);
+
+struct command commands[] = {
+ {LOOK , "l" },
+ {GO_NORTH , "n" },
+ {GO_SOUTH , "s" },
+ {GO_EAST , "e" },
+ {GO_WEST , "w" },
+ {QUIT , "q" },
+ {UNKNOWN , NULL}
+};