我已經做了下面的代碼來使用貼圖來渲染地圖,它通過文件循環並將字母翻譯成瓷磚(矩形)。PyGame不渲染形狀?
currtile_x = 0
currtile_y = 0
singlerun = 1
if singlerun == 1:
singlerun = 0
with open('townhall.map', 'r') as f:
for line in f:
for character in line:
if character == "\n":
currtile_y += 10
else:
if character == "x":
pygame.draw.rect(screen, (1,2,3), (currtile_x, currtile_y, 10, 10), 0)
currtile_x += 10
else:
if character == "a":
pygame.draw.rect(screen, (0,255,255), (currtile_x, currtile_y, 10, 10), 0)
currtile_x += 10
這裏是townhall.map文件:
xxxxx
xaaax
xaaax
xaaax
xxxxx
你的問題到底是什麼? – Stedy 2012-02-14 22:42:46