Convert a game map format

I have a few hundred maze maps that use simple “X” and “.” to denote the walls and floor
but I’m having trouble figuring how to determine if the wall should be Horizontal (-) or Vertical (|) based solely on the text file. I have created a viable 3D image, placing a CUBE at each locaton, but a wall the has height, width and small depth is desireable

Something like

####
#
#

would be

+---
|
|

thought about examining the surrounding points, but there are situations that are ambigous

any ideas? I really do not want to rewrite all these mazes if I can help it

Can you post an entire one (or a much bigger portion) ?
it might be possible to tell based on whats to the left, right, above & below which orientation it should have

20
XXXXXXXXXXXXXXXXXXXXX
X...................X
X...XXXXXXXXXX..XX..X
X.X.X.........X.X.X.X
X.XXX...XX....XXX.X.X
X.......X.X.........X
X.......XXX.........X
X...................X
X.XXXXXXXXXXXX..XXXXX
X...................X
X.....XXXX..XXXXXX..X
X.....X...X.X.......X
X.....X...X.X.XXXX..X
X.....X.X.....X.....X
X.....X.X.....XX....X
X.......X.....X...X.X
XX......X.....X...X.X
X...X.........X...X.X
X.XXXXXX......X.XXX.X
X...................X
XXXXXXXXXXXXXX.XXXXXX

this is one of about 100

here is another, which seems to be the largest of the bunch

40
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X.......................................X
X.XXXXXXXXXXXXXXXXXX..XXXXXXXXXXXXXXXX..X
X.X.........X.......X...X.......X.....X.X
X.X.XXXXXX..XX......X...X.......X.....X.X
X.....X.X.........X.X...X.......X.....X.X
XXXX.X..XX..XXXX..X.X...X.......X.....X.X
X.X.X.......X.....X.X.........X.......X.X
X.X......X..X.XX..X.X.............XXXXX.X
X.....X.....X.....X.X.........X.......X.X
XX...XXX...XX.XX..X.X.......XXXX.X....X.X
X...X.....X.X...X.X.X.........X.......X.X
X.XXXX...XX.....X.X.X.................X.X
X.....X.......X...X.X.X...............X.X
XX.X..XX..XXXXX...X.X.XX..............X.X
X.....X.....X.X.X.X.X.X...............X.X
X.XX.....X....X.X.X...X...........XXXXX.X
X...X.....X.X.....X...X...X...........X.X
X...XX.XXXXXXXXX......XXXXXX..........X.X
X.X.................X...................X
X.XXXXXXXXXX.XXX..XXXX...XXXXXXXXXXXXXXXX
X...................X...................X
X.XXXXXXXXXXXXXXXX..X.XXXXXXXXXXXXXXXX..X
X.X...............X...X...............X.X
X.X.XX..XX..XX..XXX...X.XXXXXXXXXXXX..X.X
X.X.X.X.X.X.X.X.X...X.X.X...........X.X.X
X.X.XXX...X.XXX.XX....X.X.XXXXXXXX..X.X.X
X.X...X.....X.....X.X.X.X.X.......X.X.X.X
X.XX..XX..XXX.XX..X...X.X.X.XXXX..X.X.X.X
X.X.X.X.X.X.X.X.X.X.X.X.X.X.X...X.X.X.X.X
X.XXX.XXXXXXX.XXX.X...X.X.X.X...X.X.X.X.X
X.X.........X.....X.X.X.X.X...X.X.X.X.X.X
X.X.XX..XX..XX..XXX.X.X...XXXXX.X.X.X.X.X
X.X.X.X.X.X.X.X.X...X.X.X.......X.X.X.X.X
X.XXXXX.XXX.XXX.XX..X.X.XXXXXXXXX.X.X.X.X
X.X.....X.....X...X.X.X...........X.X.X.X
X.XXXXXXX.XX..XX..X.X.XXXXXXXXXXXXX.X.X.X
X.X...X.X.X.X.X.X.X.X...............X.X.X
X.X...XXX...X...X.X.XXXXXXXXXXXXXXXXX.X.X
X...X.....X.....X...................X...X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Hello Dave,

I am not sure how helpful this may be, in OpenGL, DirectX, and Vulkan, a standard block is 3 meters (about 10 feet). All sides are drawn the same (door, window, etc). Typically, numbers and the alphabet are used for mapping. Below is an example where I use 0, 1, and 9. To make it easier, the width, height, and depth are all the same (3 meter). This also makes it easier to determine the eyes of the character which is moving around - most people are 6 feet tall - ish. :slight_smile:

Doors, windows, pictures would all be drawn with the same texture on four sides. With OpenGL, Vulkan, etc, the winding (counterclockwise drawing) makes it so that the outer portion of each block is visible to the user, and the inner block is transparent.

Does this help with some possible solutions for you?

Maps-3d-Example_edit_0

//20 columns x 20 rows
//1=wall, 0=space, 9=player start position
MyRow0 =   Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
MyRow1 =   Array(1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1)
MyRow2 =   Array(1,0,0,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,1)
MyRow3 =   Array(1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1)
MyRow4 =   Array(1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1)
MyRow5 =   Array(1,0,0,0,0,0,1,0,0,0,1,1,0,1,1,1,0,0,0,1)
MyRow6 =   Array(1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1)
MyRow7 =   Array(1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1)
MyRow8 =   Array(1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1)
MyRow9 =   Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1)
MyRow10 = Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1)
MyRow11 = Array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1)
MyRow12 = Array(1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,1)
MyRow13 = Array(1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1)
MyRow14 = Array(1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1)
MyRow15 = Array(1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1)
MyRow16 = Array(1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1)
MyRow17 = Array(1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,9,0,1)
MyRow18 = Array(1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1)
MyRow19 = Array(1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
1 Like

Thanks that is exactly what I am doing now…. I’m using SCNBox in Swift Scenekit…. but really wanted each wall to be a SCNPlane
but I guess for now I’ll stay with this method

2 Likes

Found some old code that I wrote years ago that used these exact same mazes…

Turns out, everything on a ODD row represents a HORIZONTAL wall
and the EVEN rows are VERTICAL walls

So now to alter my Scenekit to use those rules :slight_smile:

2 Likes