因此,我尝试打印此连接四块板,并显示一个控制台板和一个pygame板。我想使用while循环检查控制台,以查看玩家是否去过某个地方,然后相应地更新pygame面板。尽管while循环检查了此错误,但一直给我错误“ TypeError:'printBoardPG'对象不支持索引”。有人可以帮我解决这个麻烦吗?
谢谢:)
class printBoardPG:
M = makeBoard()
board = M.boardMake()
def boardPG(board):
pygame.init()
while True:
x = 0
y = 0
while WIDTH >= x:
while HEIGHT >= y:
if board[x][y] == "X":
tilemap[x][y].RED
y += 1
x += 1
screen = pygame.display.set_mode((mapwidth * tilesize, mapheight * tilesize))
for row in range(mapheight):
for column in range(mapwidth):
backdrop1 = pygame.draw.rect(screen, colours[tilemap[row][column]],
(column * tilesize, row * tilesize, tilesize, tilesize))
pygame.display.update()
clock.tick(60)
printBoard()
printBoardPG()。boardPG()