• Advertisement
Sign in to follow this  

Storing and rendering a single wall based maze

This topic is 1334 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

I've been pondering for a long while now how to design, store and render the maze walls for a game which has some similarities to the old Pac-Man game, but a much more compact maze layout.

 

The easiest way to show the maze i'm trying to recreate is through a video at 

 

In summary from my observations the game characters can travel on top most/all tiles but cannot leave in all directions.

So I wondered if the best way to store a map like this is by storing the paths that the characters can move along.

 

Looking at the graphics / lines used for the maze walls it appears that there is only 3 variations: a horizontal top line, a left hand vertical line and a dot on the left side.

 

Does anybody else have thoughts on how this style of maze can be stored and rendered for a game ?

Share this post


Link to post
Share on other sites
Advertisement

You could work with blocks (x,y,w,h) instead of lines. Then, you could create patterns of walls as different objects. You could create a default Wall class that has all the basic information of each block (With x, y, w, h, etc). Then, you could create the different patterns:

class WallType1(Wall): ...

?class WallType2(Wall): ...

?class WallType3(Wall): ...

Each one of them could store the blocks in their different raw positions in a list or array, and the whole walltype (With their different blocks) could be moved just by setting the x and y.
Then, you could procedurally generate their positions for each map and create unpredictable mazes at each game.

The free-blocks would be just positions, like the walls, but they would comprise no walls, so, you could filter them with a "if not in wall-positions" logic, and allow the player and the ghosts to walk only through them. Concerning the AI, I think it would be a lot easier to think about once you have the free blocks.

You could procedurally generate just "lines of blocks", alternating randomly between horizontal and vertical wall-lines, but that would give you a much more randomic maze than the ones of the video. So that's why I've recommented the pattern-wall-objects (Groups of wall-blocks that can be randomly positioned at the creation of the level). I've made an algorithm that procedurally generates mazes for my game, and a more simplified version is available on Khan Academy.

Check it out and see if it inspires you:

https://www.khanacademy.org/cs/procedural-maze-generation-with-camera-translation-and-minimap/6384329197355008

Share this post


Link to post
Share on other sites
For each tile, store flags to indicate whether there is a horizontal top line and a vertical left line. When you come to render the maze you can simply test these flags and render walls as appropriate. You could have other flags for pills, etc. For movement/AI, you can check the flags in a tile to see if you can go up or left and the tiles below/right for moving down/right.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement