Jump to content

View more

Image of the Day

Working on an auto spawn system. #gamedev #indiedev #screenshotsaturday https://t.co/Mm2kfekz7b
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Storing and rendering a single wall based maze

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 buddaboy   Members   


Posted 27 May 2014 - 12:31 PM

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 ?

#2 EricsonWillians   Members   


Posted 27 May 2014 - 01:15 PM

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:


Creator and only composer at Poisone Wein and Übelkraft dark musical projects:


#3 dave j   Members   


Posted 28 May 2014 - 05:22 AM

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.