0
只是做简单的地图,其中包括到地图使用功能的播放器的位置,但球员没有出现(映射为空)简单的地图功能
这里是我的代码。请帮忙解决。由于
import random
CELLS = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0),
(0, 1), (1, 1), (2, 1), (3, 1), (4, 1),
(0, 2), (1, 2), (2, 2), (3, 2), (4, 2),
(0, 3), (1, 3), (2, 3), (3, 3), (4, 3),
(0, 4), (1, 4), (2, 4), (3, 4), (4, 4)]
def get_locations():
return random.sample(CELLS, 1)
player = get_locations()
def draw_map(player):
print(" _" * 5)
tile = "|{}"
for cell in CELLS:
x, y = cell
if x < 4:
line_end = ""
if cell == player:
output = tile.format("X")
else:
output = tile.format("_")
else:
line_end = "\n"
if cell == player:
output = tile.format("X|")
else:
output = tile.format("_|")
print(output, end=line_end)
draw_map(player)
非常感谢,注意到。非常感谢一次 –