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)
非常感謝,注意到。非常感謝一次 –