3D Level help browsing

• posted
0

Hey, so I did a post like this before, but does anybody know how to make an expandable list with 3 numbers: 0 1 and 2, create a 3D game level? And if so, please explain how so people like me can understand it

Edit: and how to make 0 an empty space 1 a block and 2 A coin or something that opens the next file which is the next game when walked into?

Ex:# 1 = wall, 0 = empty 2=finish
level = [[1,1,1,1,1,1,1,1],
[1,1,1,2,0,0,1,1],
[1,1,1,1,1,0,0,1],
[1,1,1,0,0,1,0,1],
[1,1,1,0,0,1,0,1],
[1,1,1,0,1,1,0,1],
[1,1,1,0,0,0,0,1],
[1,1,1,1,1,1,1,1]]

• posted
1

A naive first attempt...

``````from random import choice

level = [[1,1,1,1,1,1,1,1],
[1,1,1,2,0,0,1,1],
[1,1,1,1,1,0,0,1],
[1,1,1,0,0,1,0,1],
[1,1,1,0,0,1,0,1],
[1,1,1,0,1,1,0,1],
[1,1,1,0,0,0,0,1],
[1,1,1,1,1,1,1,1]]

def new_level(maze_size=8):
level = [[choice((0, 1)) for x in range(maze_size)] for y in range(maze_size)]
level[choice(range(maze_size))][choice(range(maze_size))] = 2  # add the goal
return level

def print_level(level):
print('\n'.join(str(row) for row in level) + '\n')

print_level(level)
print_level(new_level())
``````

• posted
0

Thank you that is very helpful, I will try to use it now ðŸ˜„

Internal error.

Oops! Looks like something went wrong!