尝试构建一个包含两种常规类型的变量的类
我对如何执行此操作感到困惑。或者,如果这绝对是正确的方法。
我是菜鸟程序员,正在尝试开发游戏。 这与尝试创建地图有关。
height = 4
width = 3
map = []
class Tile():
# shared variable
def __init__(self, coord, wall, explored, visible, edge, corner):
# runs when class instance is created. edges and corners must be updated in a second pass after walls are placed.
# instanced variables
self.coord = coord
self.wall = wall
self.explored = explored
self.visible = visible
self.edge = edge # position 0,2,4,6
self.corner = corner # positions 1,3,5,7
'''
1 2 3
0 x 4
7 6 5
position map.
'''
def make_map():
for x in range(width):
map.append([])
for y in range(height):
map[x].append(Tile(coord=(x,y)))
make_map()
...... def fill_in_other_variables()