Welcome to Pacman-C_ncurses, a school project developed in December 2023.
This project is implemented in C and utilizes the ncurses library to create a Text-based User Interface (TUI). It is designed to be compiled and run on Linux systems.
The goal of the game is to move a character named Pac-Man through a maze to eat all the small yellow pellets present. Within this maze, there are 1 to 4 ghosts that are the enemies of Pac-Man. The user must avoid being caught by any of these ghosts.
- Program the grid as a 2D array. Define values for obstacles and cells with pellets.
- Initially, use a modest grid size (e.g., 10x10 or smaller for initial tests).
- Hardcode the grid with a 2D array initialization.
- Program the functionality to visualize the maze. Initially, use a console interface with the
printf()
function.
- Program the functionality to allow the user to choose the number of ghosts (1 to 4).
- Program the functionality to place ghosts randomly within the maze, avoiding walls.
- Program the functionality for Pac-Man to move randomly without touching the walls.
- Implement scoring, such as tracking the number of pellets eaten.
- Program the functionality to allow the user to move Pac-Man using keyboard inputs.
- Program the functionality to save and load a game in progress.
- Implement the rules of Pac-Man, including ghost behavior and power pellets.
(Before proceeding, please install ncurses.h on Linux or via WSL on Windows)
To compile and run this project, follow these steps :
- Clone the repository using
git clone
or Download ZIP. - Navigate to the project directory using
cd Pacman-C_ncurses/src
. - Compile the project using :
(First part of the project)
gcc random_pacman.c -o random_pacman && ./pacman1
(Second part of the project with ncurses.h)
gcc pacman.c -o pacman -lncurses && ./pacman
I've implemented a system for harvesting fruit that appears on the map, as well as changing the colour of ghosts when Pac-Man eats a power pill.
I didn't have the time to implement Pac-Man so that he could eat the ghosts, nor the ghosts' movements using complex algorithms such as A* or Dijkstra.