summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2023-02-06 12:18:59 -0800
committerPreston Pan <preston@nullring.xyz>2023-02-06 12:18:59 -0800
commite4baba24a4c30ea7162d54711e39e0b457515d88 (patch)
treecd7b3845fb01862ceb579f9c5d47a06b44613acb
parent59dd4d68c95142ceca1539491b0017985bd96357 (diff)
i forgot what i updated
-rw-r--r--README3
-rw-r--r--snake.c8
2 files changed, 8 insertions, 3 deletions
diff --git a/README b/README
index c1a7668..fb0625b 100644
--- a/README
+++ b/README
@@ -3,7 +3,8 @@ Snake3
This is a simple snake game written in C. It is written
without ncurses or curses, and instead relies entirely
-on the termios library.
+on the termios library. It completely conforms to C99
+ISO standards.
May be networked in the future.
diff --git a/snake.c b/snake.c
index 5a021a5..c57530d 100644
--- a/snake.c
+++ b/snake.c
@@ -25,7 +25,6 @@ vector_t foodPos;
vector_t lastMoveDir;
void interrupt_handler(int sig); // passed into signal(3) to handle ctrl-c interrupts
-
//unsafe functions like printf cannot be called in async interrupt handler
void interrupt_handler(int sig) {
UNUSED(sig);
@@ -33,7 +32,8 @@ void interrupt_handler(int sig) {
}
int main(int argc, char **argv) {
- for (int i = 0; i < argc; i ++) {
+ /* parsing arguments */
+ for (int i = 1; i < argc; i ++) {
if (strcmp("--version", argv[i]) == 0) {
printf("snake3, version 1.0\n");
printf("Copyright 2023 Kai Stevenson\n");
@@ -43,8 +43,12 @@ int main(int argc, char **argv) {
} else if (strcmp("--help", argv[i]) == 0) {
printf("usage: snake3 [--version] [--help]\n");
return 0;
+ } else {
+ printf("usage: snake3 [--version] [--help]\n");
+ return 1;
}
}
+
//get terminal size
struct winsize win;
ioctl(fileno(stdout), TIOCGWINSZ, &win);