Advertisement

Representing walls in a Pac-Man maze

Started by July 14, 2006 05:33 PM
0 comments, last by Steadtler 18 years, 4 months ago
I am making a Pac-Man clone in C++. I implemented the maze as a graph, where each node is at an intersection. I figured this would be the best choice for movement along the maze, and it worked fine until I got to the point where Pac-Man could eat the ghosts. When Pac-Man eats a ghost, its speed quadruples (which equates to 2x its original speed), and it tries to find its way back to the center to return it to its normal state. Unfortunately, they move so fast that they tend to overshoot the nodes, allowing them to go through the walls and off the maze. I've tried various methods to solve this problem, but none of them have worked. On one such attempt, if a ghost is approaching an intersection and would overshoot it, I merely place the ghost on that node for the next frame. Unfortunately, this causes the ghost to lock onto the node and stop moving. Any suggestions for how I should solve this problem?
First, compute the total travel for the ghost that frame.

If it overshoots the node, substract the distance to the node from the travel distance, place the ghost at the node and move it toward its next node by the remaining distance.

I cant see why this wouldnt work.

This topic is closed to new replies.

Advertisement