Python 2.7 Python(2.7):缩进的Bug类程序错误

Python 2.7 Python(2.7):缩进的Bug类程序错误,python-2.7,Python 2.7,每当我编译代码时 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: #

每当我编译代码时

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() ^
缩进错误:未缩进与任何外部缩进级别不匹配在
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)

现在它显示了这个错误回溯(最近一次调用最后一次):文件“practice.py”,第16行,在bug.motion()AttributeError中:“bug”对象没有属性“motion”,这个错误可能是因为
bug
对象没有调用
motion
的方法而出现的。很难说如何解决这个问题,因为我不知道你是如何定义
Bug
class.class Bug(BaseClass):List=pygame.sprite.Group()def_uinit_uuu(self,x,y,width,height,image_ustring):BaseClass.u init_u(self,x,y,width,image_ustring)Bug.List.add(self)self.velx=0 def运动的(self):self.rect.x+=self.velx