Small snake game in C
| 1 | #include "snake.h" |
| 2 | |
| 3 | uint8_t parse_parameters(int argc, char *args[]) { |
| 4 | |
| 5 | if (argc <= 1) { |
| 6 | return 1; |
| 7 | } |
| 8 | |
| 9 | |
| 10 | if (argc > 2) { |
| 11 | printf("Too many parameters\n"); |
| 12 | goto help_info; |
| 13 | } |
| 14 | |
| 15 | if (!strcmp(args[1], "-h") || !strcmp(args[1], "--help")) { |
| 16 | |
| 17 | printf("This is a small TUI snake game.\n\n"); |
| 18 | printf("Controls: Arrow keys/WASD to control the snake.\n"); |
| 19 | printf(" P/Enter to pause.\n"); |
| 20 | printf(" Q/Escape to quit.\n"); |
| 21 | |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | printf("Argument \"%s\" not recognized\n", args[1]); |
| 26 | |
| 27 | help_info: |
| 28 | printf("Try \"-h\" or \"--help\" for more information\n"); |
| 29 | return 0; |
| 30 | } |