Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Pac Man

This topic is 5774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, I''m starting work on a pac-man type game, and i just have a few design issues/questions i would appreciate some help on. 1) How do most people represent the board?? i.e. where the players and AI are legally allowed to move. 2) How do you keep the ghosts from getting stuck in corners if they''re supposed to move closer to pac-man?? (i know random movements would help, and so whould a tree type search) any other suggestions? 3) Does anyone know of any online tutorial for something like this?? Thanks --Ninj4D4n

Share this post

Link to post
Share on other sites
I read a binary file into an array to represent the board. In this (hardcoded, my bad but I was lazy) I had a specific number of tiles that the characters were not allowed to move through. The exception to this (another hard coded number) was the tile that when the ghosts die and need to go back to their regen room they can walk through. I have an if statement that checks that in a CanMove function (if dead and tile is regen tile then they are allowed to move there)

I did not allow the ghosts to move backwards with the exception of two conditions:
Pac-man had just eaten the power pellet, they are allowed to turn around.
They are stuck in a dead end, and have to turn around to continue moving.

The way I check my agressive ghost next direction is to check which direction is closer to get to pac-man (X or Y) and try it, if the ghost is unable to move that direction it tries the other (if X was first, Y is now tried.) If that fails as well it drops through to a random movement (from a switch statement.)

Sorry but I don''t. I had thought to make my code into a tutorial but it is so badly written (hard coded values, hard to follow logic, no comments) that I hesitate to even mention that I have written pac-man.

If you want to catch me - ICQ 8612524 (Skibum)

Share this post

Link to post
Share on other sites
For the ghost motion. See it from their point of view.

1. If they see pac man along a corridor, set the direction to head for him.

2. If they don''t see pac man just set the direction to run along any old corridor

3. Keep going until they hit a wall then decide which way to go again.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!