Can anyone plese tell me How do i create a Map for PacMan in C++. Any Suggestions for getting m Started.?
Thanx in Advance.
That's quite a wide question and depends on additional requirements. Basically I would go for a two-dimensional array that will simply represent the cells. Each cell would contain either:
The monsters and the pacman itself will not be represented in the map. Instead each should just have his position in the map.
This doesn't require C++, it only requires C, but if you deliberately want a C++ solution you can replace the arrays with a vector, or in this case, a vector of vectors.
How will the monsters move
If you want to reach point A from point B in a map, you can use any of a variety of algorithms that will find you the shortest path within the map - like the A* algorithm. However, in this case, you need to take a few things into account:
I would suggest using some random decisions when the monster reaches a "crossroad", along with a general bias towards the pacman itself. So if the monster is at a point where there are 3 directions, like East, West and North, and the pacman is to the north, I would make a random decision with 40% chance to the north, 30% to the east and 30% to the west.