我已经做了下面的代码来使用贴图来渲染地图,它通过文件循环并将字母翻译成瓷砖(矩形)。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