def throw_fireball(self, screen, settings, fireball_group, map_group): if self.facing_left: f = Fireball(screen, settings, self.rect.left, self.rect.centery) f.facing_left = True f.add(map_group, fireball_group) else: f = Fireball(screen, settings, self.rect.right, self.rect.centery) f.facing_left = False f.add(map_group, fireball_group) self.fireball = False
def animate(self, dt): if pygame.time.get_ticks() - self.time >= self.tmp: if self.jump_animation: if self.key == self.jump_sheet.get_nb_sprites() - 1: self.jump() elif self.moving_right: self.key += 1 self.image = self.jump_right_sprites[self.key][0] else: self.key += 1 self.image = self.jump_left_sprites[self.key][0] self.tmp = self.jump_left_sprites[self.key][1] elif self.ulti: if self.key == self.ultimate_sheet.get_nb_sprites() - 1: self.ulti = False self.change_animation() elif self.key == self.ultimate_sheet.get_nb_sprites() - 2: laser = Laser_Beam(self.W, self.H, self.ulti_pos) self.laser_beam.add(laser) self.key += 1 self.ulti_prev_surf_alpha = 5 self.ulti_prev_surf.fill( (0, 0, 0, self.ulti_prev_surf_alpha)) self.ulti_temp_time = pygame.time.get_ticks() self.ulti_time_seconds = 5 else: self.ulti_prev_surf_alpha += 15 self.ulti_prev_surf.fill( (0, 0, 0, self.ulti_prev_surf_alpha)) if self.moving_right: self.key += 1 self.image = self.ultimate_right_sprites[self.key][0] else: self.key += 1 self.image = self.ultimate_left_sprites[self.key][0] self.tmp = self.ultimate_left_sprites[self.key][1] elif self.spelling: if self.key == self.spell_sheet.get_nb_sprites() - 1: self.spelling = False if self.moving_right: fireball = Fireball( (self.rect.right, self.rect.centery), 1) else: fireball = Fireball( (self.rect.left, self.rect.centery), -1) fireball.add(self.fireballs) self.change_animation() elif self.moving_right: self.key += 1 self.image = self.spell_right_sprites[self.key][0] else: self.key += 1 self.image = self.spell_left_sprites[self.key][0] self.tmp = self.spell_left_sprites[self.key][1] elif not self.moving: self.key = (self.key + 1) % self.idle_sheet.get_nb_sprites() self.tmp = self.idle_right_sprites[self.key][1] if self.moving_right: self.image = self.idle_right_sprites[self.key][0] else: self.image = self.idle_left_sprites[self.key][0] else: self.key = (self.key + 1) % self.move_sheet.get_nb_sprites() self.tmp = self.move_right_sprites[self.key][1] if not self.moving_right: self.image = self.move_left_sprites[self.key][0] else: self.image = self.move_right_sprites[self.key][0] x, bottom = self.rect.x, self.rect.bottom self.rect = self.image.get_rect(x=x, bottom=bottom) self.time = pygame.time.get_ticks()