| 1 | # Games |
| 2 | |
| 3 | A collection of small games. Configuration is done in the source file of each |
| 4 | game. |
| 5 | |
| 6 | Each game is in its own directory, accompanied with a README file explaining how |
| 7 | to play the game and what configuration options are available. Additionally, |
| 8 | each game is only a single source file, allowing them the be turned into what |
| 9 | may be referred to as "C scripts". |
| 10 | |
| 11 | ## Compilation |
| 12 | |
| 13 | Each game requires only ncurses. Since the source for each game is a single |
| 14 | file, compilation is fairly simple, and no makefile is provided. |
| 15 | |
| 16 | Enter the directory for whichever game. Compile the single C file using any C |
| 17 | compiler, linking against ncurses. (`tcc` is my preferred compiler for this |
| 18 | project.) Once compiled, simply run the binary. |
| 19 | |
| 20 | For example, to run `snake`: |
| 21 | |
| 22 | ``` |
| 23 | $ cd snake |
| 24 | $ cc -o snake snake.c -lncurses |
| 25 | $ ./snake |
| 26 | ``` |
| 27 | |
| 28 | If using `tcc`, the game can be run directly from the compiler: |
| 29 | |
| 30 | ``` |
| 31 | $ cd snake |
| 32 | $ tcc -lncurses -run snake.c |
| 33 | ``` |
| 34 | |
| 35 | ## Configuring |
| 36 | |
| 37 | Configuration is done by either specifying the config options in the compiler |
| 38 | command line, or by `#define`-ing them at the top of the C file. |
| 39 | |
| 40 | To configure from the command line, the compilation command may look like this: |
| 41 | |
| 42 | ``` |
| 43 | $ cc -DX=128 -DY=64 -o snake snake.c -lncurses |
| 44 | ``` |
| 45 | |
| 46 | This will set the `X` option equal to `128` and the `Y` option to `64`. |
| 47 | |
| 48 | Configuring directly in the source file may look like this: |
| 49 | |
| 50 | ```c |
| 51 | // define your options here vvv |
| 52 | #define X 128 |
| 53 | #define Y 64 |
| 54 | |
| 55 | // this is stuff already in the file vvv |
| 56 | #include <ncurses.h> |
| 57 | ... |
| 58 | ``` |
| 59 | |