Javatpoint Logo
Javatpoint Logo

Pacman Game in C++

A simple console application or a quick clip game called Pacman Game in C was made for entertainment. Similar to the snake game, Pacman needs to be moved such that he travels along a predefined blue route before it is erased or eaten by Pacman. The game is easy to play and awards points for clearing paths as you go. Here you may get the source code and output screens for this project.

Program Breakdown

We are including all the necessary files required in our code.

We are declaring the structure of our game with the help of map of char type.

The above peace of code is used to print show the map of our game.

The above peace of code show the position of pacman initially.

The above class entity is used to make our pacman move or walk in the map.

The above peace of code will show the position of the pacman after it moves.

This function is used by pacman to detect or find the path.

In this part of driver code the user will be give instruction like arrow key to move your hero, eat the dots produced by the eater to gain points and don't get caught by the eater. It will also ask for hard, normal or easy level.

If the user has selected for H,N or E, the speed will increase accordingly.

Program for Pacman Game in C++

Output:

Instruction:
1. Arrow Keys to move your hero
2. Eat the dots produced by the Eater to gain poins
3. Don't get caught by the Eater
H -> Hard
N -> Normal
E -> Easy

Input : N
+#############################+
|...                          | 0
|  .                          |
|##.########### ##   #########|
|  .|                         |
| |.|### |  |           |     |
| |.     |  | |###  |   |  |  |
| |.#####|  | |      ## |     |
| |......     |###  |      |  |
| |#####.###         ##       |
|       ..E ######  ####### ###|
|                             |
|# ### ####      ###   #######|
|                             |
|                             |
|                             |
|              H              |
+#############################+

You Lose and your score is : 0






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA