Small snake game in C
Commit 960b46cfd7ae
tarball6 files changed+25-18
@@ -9,7 +9,7 @@ include(FetchContent)
99
FetchContent_Declare(1010
jag_parse1111
GIT_REPOSITORY https://codeberg.org/Jaglekon/jag_parse.git12
- GIT_TAG v1.1.012
+ GIT_TAG v1.1.11313
)1414
1515
FetchContent_Declare(@@ -1,4 +1,4 @@
1
-#include "../snake.h"1
+#include "animation.h"22
33
#include "../read_input/read_input.h"44
@@ -0,0 +1,21 @@
1
+#ifndef ANIMATION_H2
+#define ANIMATION_H3
+4
+5
+#include "../read_input/read_input.h"6
+7
+#include <stdio.h>8
+#include <sys/ioctl.h>9
+#include <sys/stat.h>10
+11
+#include <jag_parse.h>12
+13
+#define DELAY 1014
+15
+#define KEY_PROTECTION 216
+17
+18
+bool start_animation();19
+20
+21
+#endif@@ -199,16 +199,3 @@ direction read_direction(char *string, bool wasd_enabled) {
199199
break;200200
}201201
}202
-203
-int32_t string_to_num(char* string, int32_t min, int32_t max, int32_t number) {204
- 205
- char *endptr;206
- int32_t new_num = strtol(string, &endptr, 10);207
-208
- if (string != endptr) {209
- if (new_num >= min && new_num <= max)210
- return new_num;211
- } 212
-213
- return number;214
-}@@ -17,7 +17,7 @@ uint8_t parse_parameters(int argc, char *args[]) {
1717
printf("This is a small TUI snake game.\n\n");1818
printf("Controls: Arrow keys/WASD to control the snake.\n");1919
printf(" P/Enter to pause.\n");20
- printf(" Q to quit.\n");20
+ printf(" Q/Escape to quit.\n");2121
2222
return 0;2323
}@@ -28,6 +28,7 @@
2828
#include <jag_write.h>2929
3030
#include "settings_file/settings_file.h"31
+#include "animation/animation.h"3132
3233
#define RIGHT_CODE 'C'3334
#define LEFT_CODE 'D'@@ -111,8 +112,6 @@ direction read_direction(char *string, bool wasd_enabled);
111112
112113
uint8_t make_folder(char *path);113114
114
-int32_t string_to_num(char* string, int32_t min, int32_t max, int32_t number);115
-116115
117116
uint8_t parse_parameters(int argc, char *args[]);