jag

snake_c

public

Small snake game in C

Star0
Watch0

Commit 960b46cfd7ae

tarball

Jaglekon <jaglekon@jaglekon.de>2026-09-16 14:48 UTC

6 files changed+25-18
updated help
Modified file: CMakeLists.txt+1 additions−1 deletions
@@ -9,7 +9,7 @@ include(FetchContent)
99 FetchContent_Declare(
1010 jag_parse
1111 GIT_REPOSITORY https://codeberg.org/Jaglekon/jag_parse.git
12- GIT_TAG v1.1.0
12+ GIT_TAG v1.1.1
1313 )
1414
1515 FetchContent_Declare(
Modified file: source/animation/animation.c+1 additions−1 deletions
@@ -1,4 +1,4 @@
1-#include "../snake.h"
1+#include "animation.h"
22
33 #include "../read_input/read_input.h"
44
Added file: source/animation/animation.h+21 additions
@@ -0,0 +1,21 @@
1+#ifndef ANIMATION_H
2+#define ANIMATION_H
3+
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 10
14+
15+#define KEY_PROTECTION 2
16+
17+
18+bool start_animation();
19+
20+
21+#endif
Modified file: source/logic.c−13 deletions
@@ -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-}
Modified file: source/parameters.c+1 additions−1 deletions
@@ -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 }
Modified file: source/snake.h+1 additions−2 deletions
@@ -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[]);