Skip to main content
The Pacman project follows a traditional C project layout with source code, headers, game data, and build files organized in separate directories.

Project root

pacman/
├── Makefile           # Build configuration
├── Makefile.old       # Previous Makefile version
├── README.md          # Project documentation
├── .gitignore         # Git exclusion rules
├── sound              # Sound utility executable
├── src/               # Source code directory
└── data/              # Game assets (graphics and audio)

Root files

Makefile
file
Main build configuration using GNU Make.Key settings:
  • Compiler: gcc
  • Optimization: -O3 -ffast-math -funroll-loops
  • SDL include path: /usr/include/SDL
  • Links: SDL, SDL_image, libmikmod, GLFW
Targets:
  • all - Build the pacman executable (default)
  • clean - Remove object files and executable
See: Dependencies reference
README.md
file
Project documentation in Spanish, including:
  • Feature overview
  • Installation instructions
  • Usage examples
  • Resolution restoration explanation
  • Git ignore policy
.gitignore
file
Git exclusion rules:
*.o        # Object files from compilation
*~         # Editor backup files (Emacs, Vim)
pacman     # Compiled executable
sound
binary
Compiled utility executable for sound/audio operations.Type: ELF 64-bit LSB executablePlatform: Linux x86-64

Source directory

src/
├── include/           # Header files
├── main.c             # Entry point and initialization
├── gfx.c              # Graphics and rendering
├── menuopt.c          # Menu and options
├── mov_fig.c          # Character movement
├── sprites.c          # Sprite management
├── movefant.c         # Ghost movement logic
├── misc.c             # Miscellaneous utilities
├── fantasma.c         # Ghost behavior
├── frutas.c           # Fruit/bonus items
├── intro.c            # Intro screen
├── loadimage.c        # Image loading
├── fade.c             # Fade effects
├── array.c            # Array utilities
├── paleta.c           # Color palette
├── scores.c           # Score management
├── sprfan.c           # Ghost sprites
├── teclado.c          # Keyboard input
├── trata_nu.c         # Number handling
├── niveles.c          # Level data
├── writef.c           # Text rendering
├── writef             # Text utility (binary)
├── memcpy32.asm       # Optimized memory copy (x86 asm)
└── mov_fig.c.original # Backup of mov_fig.c

Core source files

Purpose: Program entry point and initializationKey functions:
  • main() - Command-line parsing and game launch
  • guardarResolucionOriginal() - Save display configuration
  • restaurarResolucionOriginal() - Restore display on exit
  • xrandr_disponible() - Check for xrandr utility
  • setup() - Initialize display detection
  • help() - Display usage information
Location: src/main.cSee: Command-line reference
Purpose: Graphics initialization and renderingHandles SDL surface management, screen updates, and video mode setup.
Purpose: Player character movementImplements Pacman movement logic, collision detection, and animation.
Purpose: Ghost AI and movementContains artificial intelligence for ghost behavior and pathfinding.
Purpose: Miscellaneous game utilitiesGeneral-purpose functions used throughout the game.
Purpose: Sprite loading and managementLoads sprite graphics from BMP files and manages sprite rendering.

Supporting files

memcpy32.asm
assembly
Optimized x86 assembly implementation of memory copy operations for performance-critical rendering.Size: 228 bytes
*.original
backup
Backup copies of modified source files for reference.

Header files

src/include/
├── defines.h          # Global constants and macros (2685 bytes)
├── gfx.h              # Graphics function prototypes
├── pacman.h           # Main game structures (1585 bytes)
├── sprites.h          # Sprite definitions (2724 bytes)
├── menuopt.h          # Menu structures (2224 bytes)
├── fantasmas.h        # Ghost definitions (1131 bytes)
├── misc.h             # Utility prototypes (1224 bytes)
├── mov_fig.h          # Movement prototypes
├── intro.h            # Intro screen
├── loadimage.h        # Image loading
├── memcpy32.h         # Memory copy
└── paleta.h           # Palette definitions

Key headers

defines.h
header
Central configuration file with:
  • Screen resolution constants (RES_XB, RES_YB)
  • Game speed and timing
  • Tile dimensions
  • Color definitions
  • Platform-specific macros
Size: 2,685 bytes (largest header)Location: src/include/defines.h
sprites.h
header
Sprite system definitions:
  • Sprite structure definitions
  • Animation frame data
  • Sprite coordinate constants
Size: 2,724 bytes
pacman.h
header
Core game structures:
  • Player state
  • Game board representation
  • Score and lives
  • Level data
Size: 1,585 bytes
menuopt.h
header
Menu system structures:
  • Menu options
  • UI elements
  • Option flags
Size: 2,224 bytes
fantasmas.h
header
Ghost (enemy) definitions:
  • Ghost types and colors
  • AI behavior modes
  • Ghost state structures
Size: 1,131 bytes
misc.h
header
Utility function prototypes:
  • Timer functions
  • Helper utilities
  • Math operations
Size: 1,224 bytes

Data directory

data/
├── sprites.bmp        # Main sprite sheet (65KB)
├── sprites.gif        # Sprite sheet GIF (11KB)
├── sprites2.gif       # Additional sprites (8KB)
├── fonts.bmp          # Font bitmap (192KB)
├── fonts.gif          # Font GIF (3KB)
├── tablero.bmp        # Game board texture (307KB)
├── tablero2.bmp       # Alternate board (192KB)
├── portada.bmp        # Title screen (192KB)
├── *.wav              # Sound effects and music
└── old/               # Archived assets

Graphics assets

sprites.bmp
image
Main sprite sheet containing:
  • Pacman animations (all directions)
  • Ghost sprites (4 colors)
  • Fruit and bonus items
  • UI elements
Format: BMPSize: 65,038 bytes
fonts.bmp
image
Bitmap font for text rendering.Format: BMPSize: 192,054 bytes (largest asset)
tablero.bmp
image
Game board background texture.Format: BMPSize: 307,254 bytes (second largest)
portada.bmp
image
Title screen / intro screen.Format: BMPSize: 192,054 bytes

Audio assets

The data/ directory contains numerous WAV files for game audio:
  • pacman.wav (746KB) - Main theme music
  • pacman3.wav (52KB) - Alternative music track
  • pacman4.wav (40KB) - Additional music
  • come.wav - Eating pellets sound
  • startups.wav (50KB) - Game start sound
  • offline.wav (91KB) - Game over sound
  • cfaccess.wav - Menu/access sound
Ghost chase music with increasing tempo:
  • siren1.wav (70KB)
  • siren2.wav (65KB)
  • siren3.wav (55KB)
  • siren4.wav (50KB)
  • siren5.wav (45KB)
  • 1b.wav (154KB) - Additional sound effect
  • fondo.wav - Background ambient sound
  • pacman2.wav - Short jingle
All audio files are in WAV format and played using libmikmod. Total audio data: approximately 1.5 MB.

Old assets directory

old/
directory
Archive of previous versions of graphics and audio files, including:
  • Older sprite versions
  • Previous font files
  • Original audio recordings
  • PassThroughMovie.zip - Video content archive
Purpose: Version history and backup

Build artifacts

These files are generated during compilation and excluded from version control:
*.o           # Object files (one per .c source)
pacman        # Final executable

Object files

During compilation, each .c file produces a corresponding .o object file:
  • src/main.o
  • src/gfx.o
  • src/menuopt.o
  • src/mov_fig.o
  • src/sprites.o
  • src/movefant.o
  • src/misc.o
These are linked together to create the final pacman executable.

Executable

pacman
binary
Final game executable after successful compilation.Type: ELF 64-bit LSB executablePlatform: Linux x86-64Usage: ./pacman -f or ./pacman -wSee: Command-line reference

Temporary files

Runtime generated files

/tmp/restaurar_xrandr.sh
script
Generated at: Game startup (fullscreen mode)Purpose: Restore display configuration on exitContains:
  • xrandr commands for each connected display
  • Resolution and refresh rate settings
  • Monitor position and layout
  • Primary display designation
Permissions: Executable (chmod +x)Location: /tmp/ directoryLifecycle: Created at startup, executed at exit, persists until system reboot

Development files

Editor and temporary files ignored by git:
  • *~ - Backup files from Emacs, Vim, and other editors
  • .*.swp - Vim swap files
  • *.o - Compiled object files

Project statistics

Approximate line counts and file sizes:
CategoryFilesTotal SizeNotes
Source (.c)20+~120 KBIncluding main.c, gfx.c, etc.
Headers (.h)13~15 KBAll in src/include/
Graphics10+~1.3 MBBMP and GIF files
Audio15+~1.5 MBWAV format
Documentation1~3 KBREADME.md
Total project size: Approximately 3 MB (source + assets)

Finding specific functionality

# See: src/main.c
# Functions: main(), setup(), init_gfx()

See also

Build docs developers (and LLMs) love