i programing at the moment a rpg but the animation is not working becous i get this error
here is the code:
class Attack(pygame.sprite.Sprite):
def __init__(self, game, x, y,):
self.game = game
self._layer = PLAYER_LAYER
self.groups = self.game.all_sprites, self.game.attacks
pygame.sprite.Sprite.__init__(self, self.groups)
self.x = x
self.y = y
self.width = TILESIZE
self.height = TILESIZE
self.animation_loop2 = 0
self.image = self.game.attack_spritesheet.get_sprite(0, 0, self.width, self.height)
self.rect = self.image.get_rect()
self.rect.x = self.x
self.rect.y = self.y
def colide(self):
hits = pygame.sprite.spritecollide(self, self.game.enemies, True)
def update(self):
self.animate()
self.colide()
def animate(self):
diretion = self.game.player.facing
right_animations = [self.game.attack_spritesheet.get_sprite(0, 64, self.width, self.height),
self.game.attack_spritesheet.get_sprite(32, 64, self.width, self.height),
self.game.attack_spritesheet.get_sprite(64, 64, self.width, self.height),
self.game.attack_spritesheet.get_sprite(96, 64, self.width, self.height),
self.game.attack_spritesheet.get_sprite(128, 64, self.width, self.height)]
down_animations = [self.game.attack_spritesheet.get_sprite(0, 32, self.width, self.height),
self.game.attack_spritesheet.get_sprite(32, 32, self.width, self.height),
self.game.attack_spritesheet.get_sprite(64, 32, self.width, self.height),
self.game.attack_spritesheet.get_sprite(96, 32, self.width, self.height),
self.game.attack_spritesheet.get_sprite(128, 32, self.width, self.height)]
left_animations = [self.game.attack_spritesheet.get_sprite(0, 96, self.width, self.height),
self.game.attack_spritesheet.get_sprite(32, 96, self.width, self.height),
self.game.attack_spritesheet.get_sprite(64, 96, self.width, self.height),
self.game.attack_spritesheet.get_sprite(96, 96, self.width, self.height),
self.game.attack_spritesheet.get_sprite(128, 96, self.width, self.height)]
up_animations = [self.game.attack_spritesheet.get_sprite(0, 0, self.width, self.height),
self.game.attack_spritesheet.get_sprite(32, 0, self.width, self.height),
self.game.attack_spritesheet.get_sprite(64, 0, self.width, self.height),
self.game.attack_spritesheet.get_sprite(96, 0, self.width, self.height),
self.game.attack_spritesheet.get_sprite(128, 0, self.width, self.height)]
if diretion =="up":
self.image = up_animations[math.floor(self.animation_loop2)]
self.animation_loop2 += 0.5
if self.animation_loop2 >= 5:
self.kill
if diretion =="down":
self.image = down_animations[math.floor(self.animation_loop2)]
self.animation_loop2 += 0.5
if self.animation_loop2 >= 5:
self.kill
if diretion =="left":
self.image = left_animations[math.floor(self.animation_loop2)]
self.animation_loop2 += 0.5
if self.animation_loop2 >= 5:
self.kill
if diretion =="right":
self.image = right_animations[math.floor(self.animation_loop2)]
self.animation_loop2 += 0.5
if self.animation_loop2 >= 5:
self.kill
if you have any questions just ask