diff options
| author | Preston Pan <preston@nullring.xyz> | 2023-02-06 12:18:59 -0800 |
|---|---|---|
| committer | Preston Pan <preston@nullring.xyz> | 2023-02-06 12:18:59 -0800 |
| commit | e4baba24a4c30ea7162d54711e39e0b457515d88 (patch) | |
| tree | cd7b3845fb01862ceb579f9c5d47a06b44613acb | |
| parent | 59dd4d68c95142ceca1539491b0017985bd96357 (diff) | |
i forgot what i updated
| -rw-r--r-- | README | 3 | ||||
| -rw-r--r-- | snake.c | 8 |
2 files changed, 8 insertions, 3 deletions
@@ -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. @@ -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); |
