First of all there are a bunch of tutorials on Google regarding building Pac-man clones in eg. Flash. Some of these explain the idea pretty well. There is also a site telling the story and ruleset of the original Pacman ghosts AI. Will see if I can find that link again someday.
But regarding your question.
First of all you need to know your "maximum size" of your levels. In PacMan (from now on "PM" only) the maze is of a certain size, but this wouldnt be too hard to change later though - its only for the principles.
A 2D maze can be implemented with ARRAY's 2 dimensional arrays are just large strings of data.
I will try to show it with characters here:
XXXXXXXXXX
X...X....X
X.X.X.XX.X
X.X...X..X
X.X.X.XX.X
X...X....X
XXXXXXXXXX
Now thats not a pretty reprecentation of the actual PM, but enough for my point. What I can do now is to store these within a simple array/list of strings.
As you havent told us what programming language you will be using, I will just try to use some "pseudo kinda description" (javascript/actionscript/C# kinda )
var maze string[10];
maze[0] = "XXXXXXXXXX";
maze[1] = "X...X....X";
maze[2] = "X.X.X.XX.X";
maze[3] = "X.X...X..X";
maze[4] = "X.X.X.XX.X";
maze[5] = "X...X....X";
maze[6] = "XXXXXXXXXX";
From this I can find out where the walls are. I can use this for collision detection, I can use it for pathfinding and I can use it to draw the actual map.
You just make a function that will return what kinda "tile" is on a certain coordinate.
tiletype GetTile(xcoord:int, ycoord:int)
{
return substring(maze[ycoord], xcoord,1); // returns a substring (string, starting at xcoord, length)
}
You could also make it more "specific" if you want.
boolean isWall(xcoord:int, ycoord:int)
{
return (substring(maze[ycoord], xcoord,1) == "x")
}
Does this make sense?