A Pac-Man clone written in C++ with raylib, featuring BFS-based ghost pathfinding and a built-in map editor.
The game runs on a 20x15 grid of cells loaded from CSV map files. Pac-Man eats the pellets scattered across every road cell while four ghosts hunt him. Ghost movement is driven by a breadth-first search over the grid: the BFS builds a shortest path from each ghost's cell to its target, and the ghost steps toward the next cell on that path.
- 3 maps x 3 difficulties — maps are loaded from
assets/Maps/map1.csv–map3.csv.- Easy/Medium: ghosts BFS toward random road cells and pick new targets on arrival.
- Hard: ghosts BFS directly toward Pac-Man's current cell.
- Map editor — draw your own maze with the mouse, then play it immediately.
- BFS pathfinding — shortest-path search on the cell grid (
Map::FindPath), with optional path coloring. - Top-3 high scores — persisted to
assets/scores.txtand shown on the win/lose screens. - Resizable window — the grid, sprites and speeds rescale with the window.
- Sound and sprites — background music, chomp effects, animated Pac-Man and ghost sprite sheets.
- C++ (built with
g++) - raylib — window, input, audio, 2D rendering
- raygui — immediate-mode UI for the menus (bundled in
raylib/include/raygui.h)
Grab the latest tarball from the Releases page — raylib is linked statically, so nothing else needs installing:
tar -xzf pacman-v1.0.0-linux-x86_64.tar.gz
cd pacman-v1.0.0-linux-x86_64
./game- A C++ compiler (
g++) andmake - raylib installed system-wide — the build links with
-lrayliband includes<raylib.h>. On Debian/Ubuntu:sudo apt install libraylib-dev, or build it from source.
make
./gameRun the binary from the repository root — assets are loaded via relative paths (assets/...).
Open ConsoleApplication1.sln in Visual Studio and build. The bundled raylib/raylib.lib and the headers in raylib/include/ are used for linking.
From the main menu:
| Option | What it does |
|---|---|
| START GAME | Pick a difficulty row (Easy / Medium / Hard) and a level column (Level 1–3) |
| HOW TO PLAY | In-game instructions |
| CREDITS | The team behind the project |
| CREATE YOUR OWN MAP | Draw a maze, then choose a difficulty and play it |
In-game controls
- Arrow keys — move Pac-Man
- Q or Esc — quit the level (your score is saved)
Map editor controls
- Left click — place a wall
- Right click — erase a wall back to road
- Q — finish drawing and start the game
Each pellet is worth 10 points. Eat them all to win; get caught by a ghost and you lose.
Source_files/ Implementation (.cpp)
Header_files/ Headers (.h)
assets/ Sprites, fonts, sounds, maps (CSV), scores.txt
raylib/ Bundled raylib/raygui headers + raylib.lib for the Windows build
Makefile Linux build
ConsoleApplication1.sln Visual Studio solution (Windows build)
Key pieces: Map (grid, BFS, pathfinding), Pacman and Ghost (movement, collision, animation), Level (game loop), Menu (raygui screens), mapmaker (map editor), FileIO (map + score persistence).