Pac-Man in C
The game running right in the terminal
pacman.c
1typedef struct { 2 Posicao pos; 3 char background_anterior; 4 int dir_x, dir_y; 5} Fantasma; 6 7typedef struct { 8 char **grade; 9 int linhas, colunas; 10 int pontos_totais, pontos_coletados; 11} Mapa;
About the project
Before the web version, Pac-Man started out in C, running in the terminal.
Mazes are read from text files and stored in a dynamically allocated grid. The game reads the keyboard without waiting for Enter using termios, moves the ghosts and draws everything with ANSI colors.
Technical highlights
- 01 Five maps loaded from files
- 02 Dynamically allocated map grid (char **)
- 03 Real-time key input with termios (Linux and macOS)