summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h9
-rw-r--r--doc/snake3.13
-rw-r--r--snake.c7
3 files changed, 13 insertions, 6 deletions
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..7d8a2d2
--- /dev/null
+++ b/config.h
@@ -0,0 +1,9 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+int boardSize = 15;
+int obstacleSize = 2;
+int obstacles = 2;
+int speed = 3;
+
+#endif
diff --git a/doc/snake3.1 b/doc/snake3.1
index 3cfa2e6..8eac3d0 100644
--- a/doc/snake3.1
+++ b/doc/snake3.1
@@ -9,7 +9,8 @@ snake3 \- small command line snake program
You control a snake, and the objective is to grow as long as possible.
Use your head to eat the F characters to grow longer. Crashing into
yourself loses the game. You may use vi(1) keybindings or the WASD
-keys to navigate. The game becomes faster as you grow.
+keys to navigate. The game becomes faster as you grow. You can change
+the default values for the game with the \fBconfig.h\fP file.
.SS Options
\fB--version\fP
diff --git a/snake.c b/snake.c
index 7465e3f..1d26e4a 100644
--- a/snake.c
+++ b/snake.c
@@ -11,16 +11,14 @@
#include "snake.h"
#include "conio.h"
#include "colors.h"
-
+#include "config.h"
#define UNUSED(x) (void)(x)
/*** GLOBAL VARIABLES ***/
volatile sig_atomic_t intCtrlC = 0; /* flag for ctrl-c interrupt */
-int speed = 3;
int score = 0;
-int boardSize = 15;
int updateInterval = 300000000L;
-int obstacleSize = 2;
+
vectorp_t obstaclePositions;
vectorp_t snakePositions;
vector_t foodPos;
@@ -38,7 +36,6 @@ int main(int argc, char **argv) {
/* parsing arguments */
char *last_flag;
int was_flag = 0;
- int obstacles = 2;
for(int i = 1; i < argc; i++) {
if(strcmp("--version", argv[i]) == 0) {
printf("snake3, version 2.0\n");