每当我编译代码时
import pygame,sys
from classes import *
pygame.init()
SCREENWIDTH,SCREENHEIGHT = 640, 360
screen = pygame.display.set_mode ((SCREENWIDTH, SCREENHEIGHT))
clock = pygame.time.Clock()
FPS = 24
bug = Bug(0,100,40,40,"bug.png")
while True:
# PROCESSING
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
#LOGIC
bug.motion()
#LOGIC
#DRAW
screen.fill((0,0,0))
BaseClass.allsprites.draw(screen)
pygame.display.flip()
#DRAW
clock.tick(FPS)
它显示以下错误:
文件" practice.py",第16行 bug.motion() ^ IndentationError:unindent与任何外部缩进级别都不匹配
答案 0 :(得分:0)
sys.exit()
之后的每一行都有五个空格,当它们应该有四个空格时。
import pygame,sys
from classes import *
pygame.init()
SCREENWIDTH,SCREENHEIGHT = 640, 360
screen = pygame.display.set_mode ((SCREENWIDTH, SCREENHEIGHT))
clock = pygame.time.Clock()
FPS = 24
bug = Bug(0,100,40,40,"bug.png")
while True:
# PROCESSING
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
#LOGIC
bug.motion()
#LOGIC
#DRAW
screen.fill((0,0,0))
BaseClass.allsprites.draw(screen)
pygame.display.flip()
#DRAW
clock.tick(FPS)