-6

我的 pygame 代码有问题。

import pygame
from pygame.locals import *

ANCHO_MAPA = 800
ALTO_MAPA = 600
pos_x = 0

pygame.init()
screen = pygame.display.set_mode((ANCHO_MAPA, ALTO_MAPA))
pygame.display.set_caption("Gercho")

tile = pygame.image.load('ima/0.png').convert_alpha()

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()

    for x in range(ALTO_MAPA):
        screen.blit(tile, (1, x))


    pygame.display.flip()

当我尝试它时,我得到了这个错误。有什么问题?

4

2 回答 2

1

不要混合制表符和空格。

PEP8

while True:
    for event in pygame.event.get():    # <- tabs
        if event.type == QUIT:
            pygame.quit()

    for x in range(ALTO_MAPA):          # <- spaces
        screen.blit(tile, (1, x))


    pygame.display.flip()
于 2013-02-22T17:56:47.727 回答
0

检查是否有一致的缩进。最常见的问题是缩进和制表符的混合。

于 2013-02-22T17:59:42.293 回答