Thumbnail

rani/games.git

Clone URL: https://git.buni.party/rani/games.git

Viewing file on branch master

1# Games
2
3A collection of small games. Configuration is done in the source file of each
4game.
5
6Each game is in its own directory, accompanied with a README file explaining how
7to play the game and what configuration options are available. Additionally,
8each game is only a single source file, allowing them the be turned into what
9may be referred to as "C scripts".
10
11## Compilation
12
13Each game requires only ncurses. Since the source for each game is a single
14file, compilation is fairly simple, and no makefile is provided.
15
16Enter the directory for whichever game. Compile the single C file using any C
17compiler, linking against ncurses. (`tcc` is my preferred compiler for this
18project.) Once compiled, simply run the binary.
19
20For example, to run `snake`:
21
22```
23$ cd snake
24$ cc -o snake snake.c -lncurses
25$ ./snake
26```
27
28If 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
37Configuration is done by either specifying the config options in the compiler
38command line, or by `#define`-ing them at the top of the C file.
39
40To 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
46This will set the `X` option equal to `128` and the `Y` option to `64`.
47
48Configuring 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