Ejemplo n.º 1
0
 def _end_teleport(self):
     self._sprite = AnimatedSprite('ice_demon.png',
                                   Point2D(32, 64),
                                   4,
                                   speed=0.25)
     self.invulnerable = False
     self._can_teleport = True
Ejemplo n.º 2
0
 def _die(self):
     self.health = 1
     self._change_sprite(
         AnimatedSprite('icicle_death.png', Point2D(32, 32), 7, speed=0.25))
     self._dead = True
     self.invulnerable = True
     self.damage = 0
     self.set_timer('despawn', 24, self._despawn)
Ejemplo n.º 3
0
 def _reset(self):
     self._change_sprite(
         AnimatedSprite('final_boss.png', Point2D(144, 108), 32,
                        speed=0.25))
     if self._teleported > 15:
         self.phase = 6
     else:
         self._can_teleport = True
Ejemplo n.º 4
0
 def _reappear(self):
     self._sprite = AnimatedSprite('ice_demon_teleport.png',
                                   Point2D(32, 64),
                                   6,
                                   speed=0.25,
                                   reverse=True)
     self._invisible = False
     self.set_timer('end-teleport', 16, self._end_teleport)
Ejemplo n.º 5
0
 def teleport(self):
     if not self._can_teleport:
         return
     self.invulnerable = True
     self._can_teleport = False
     self._sprite = AnimatedSprite('ice_demon_teleport.png',
                                   Point2D(32, 64),
                                   6,
                                   speed=0.25)
     self.set_timer('disappear', 16, self._disappear)
Ejemplo n.º 6
0
 def __init__(self):
     super().__init__(
         Point2D(WIDTH / 2, PLAYER_SPAWN + 256), 10, True, 0.3,
         AnimatedSprite('player_idle.png', Point2D(25, 44), 3, speed=0.25),
         100, 4)
     self.animation_state = self.PlayerStates.IDLE
     self.fading = False
     self.can_fade = True
     self.swinging = False
     self.can_shoot = True
Ejemplo n.º 7
0
 def __init__(self, x, y):
     super().__init__(Point2D(x, y),
                      5,
                      False,
                      AnimatedSprite('moth.png', Point2D(64, 64), 8),
                      60,
                      25,
                      enemy=True)
     self.moving_random = 0
     self.random_direction = (0, 0)
Ejemplo n.º 8
0
 def __init__(self, x, y, dx, dy, parent):
     super().__init__(AnimatedSprite('fire_ball.png', Point2D(25, 23), 3),
                      x,
                      y,
                      dx,
                      dy,
                      5,
                      50,
                      parent,
                      enemy=True)
Ejemplo n.º 9
0
 def __init__(self, x, y):
     super().__init__(Point2D(x, y),
                      3,
                      False,
                      AnimatedSprite('fire_skull.png',
                                     Point2D(32, 50),
                                     11,
                                     speed=0.25),
                      100,
                      0,
                      enemy=True)
     self._can_fire = True
Ejemplo n.º 10
0
 def __init__(self, x, y, dx, dy, parent):
     super().__init__(AnimatedSprite('icicle.png', Point2D(27, 7), 5),
                      x,
                      y,
                      dx,
                      dy,
                      7,
                      60,
                      parent,
                      enemy=True)
     self.set_timer('die', 1000, self._die)
     self._dead = False
Ejemplo n.º 11
0
 def __init__(self, x, y):
     super().__init__(Point2D(x, y),
                      8,
                      False,
                      0.3,
                      AnimatedSprite('spider_idle.png',
                                     Point2D(32, 32),
                                     2,
                                     speed=0.25),
                      50,
                      20,
                      enemy=True)
     self._midair = False
Ejemplo n.º 12
0
 def __init__(self, x, y):
     super().__init__(Point2D(x, y),
                      5,
                      False,
                      AnimatedSprite('ice_demon.png',
                                     Point2D(32, 64),
                                     4,
                                     speed=0.25),
                      60,
                      10,
                      enemy=True)
     self._can_teleport = True
     self._invisible = False
     self._can_fire = True
Ejemplo n.º 13
0
 def animate(self):
     if self.health == 0:
         am.play_sound('death.ogg', volume=0.2)
         self._change_sprite(Sprite('player_dead.png', Point2D(44, 13)))
     elif self.animation_state == self.PlayerStates.SWINGING:
         self._change_sprite(
             AnimatedSprite('player_swing.png',
                            Point2D(50, 43),
                            5,
                            speed=0.5))
     elif self.animation_state == self.PlayerStates.SWING_RUNNING:
         self._change_sprite(
             AnimatedSprite('player_swing_running.png',
                            Point2D(50, 44),
                            5,
                            speed=0.5))
     elif self.animation_state == self.PlayerStates.SHOOTING:
         self._change_sprite(
             AnimatedSprite('player_shoot.png',
                            Point2D(25, 44),
                            5,
                            speed=0.5))
     elif self.force.y_mag != 0:
         self._change_sprite(Sprite('player_midair.png', Point2D(25, 44)))
         am.stop_sound('running_on_grass.ogg')
     elif self.animation_state == self.PlayerStates.RUNNING:
         self._change_sprite(
             AnimatedSprite('player_running.png', Point2D(25, 44), 7))
         am.play_sound('running_on_grass.ogg')
         self.animation_state = self.PlayerStates.IDLE
     else:
         self._change_sprite(
             AnimatedSprite('player_idle.png',
                            Point2D(25, 44),
                            3,
                            speed=0.25))
         am.stop_sound('running_on_grass.ogg')
Ejemplo n.º 14
0
 def _move(self, player_pos):
     if self._teleported > 15:
         self.position.x = WIDTH // 2 - 72
     elif player_pos.x - 72 < 1:
         self.position.x = 1
     elif player_pos.x - 72 > 572:
         self.position.x = 572
     else:
         self.position.x = player_pos.x - 72
     self._change_sprite(
         AnimatedSprite('final_boss_teleport.png',
                        Point2D(144, 108),
                        7,
                        speed=0.5))
     self.set_timer('reset', 14, self._reset)
Ejemplo n.º 15
0
 def __init__(self, x, y):
     super().__init__(
         Point2D(x, y), 0, False,
         AnimatedSprite('final_boss.png', Point2D(144, 108), 32,
                        speed=0.25), 400, 0, True)
     self.y_offset = 0
     self.start_y = y
     self.downward = False
     self._spawned_moths = 0
     self.phase = 0
     self._spawned_fire_balls = 0
     self._spawned_icicles = 0
     self._teleported = 0
     self._can_teleport = True
     self._set_phase_5_timer = False
     self._can_shoot = True
Ejemplo n.º 16
0
    def update(self, player_pos):
        if self.force.y_mag != 0:
            self._midair = True
            self._change_sprite(Sprite('spider_midair.png', Point2D(32, 32)))
            self.transform(x=1 if player_pos.x > self.position.x else -1,
                           y=1 if player_pos.y > self.position.y else -1)
        else:
            self._change_sprite(
                AnimatedSprite('spider_idle.png',
                               Point2D(32, 32),
                               2,
                               speed=0.25))
            self.should_damage = False
            if randint(0, 10) == 0:
                self._jump()

        super().update()
Ejemplo n.º 17
0
 def __init__(self, x, y, healing):
     super().__init__(
         Point2D(x, y), 0, False,
         AnimatedSprite('heart.png', Point2D(32, 32), 7, speed=0.25), 1, 0)
     self.healing = healing
Ejemplo n.º 18
0
 def __init__(self, x):
     super().__init__(
         Point2D(x, 0), 0, False,
         AnimatedSprite('death_field.png', Point2D(144, 480), 7), 1, 100,
         False)
     self.time_alive = 0
Ejemplo n.º 19
0
    def update(self, player_pos, entities):
        super().update()

        if len(self.children) != 0:
            return
        if self.phase == 0:
            if self._spawned_moths < 2 and randint(0, 40) == 0:
                self.children.append(Moth(self.position.x, self.position.y))
                self._spawned_moths += 1
            elif self._spawned_moths > 1 and len(
                [x for x in entities if isinstance(x, Moth)]) == 0:
                self.children.extend([
                    Icicle(self.position.x, self.position.y, 0, 0, self),
                    Icicle(self.position.x + 72, self.position.y, 0, 0, self),
                    Icicle(self.position.x + 144, self.position.y, 0, 0, self)
                ])
                self.phase = 1
        elif self.phase == 1:
            if len([x for x in entities if isinstance(x, Icicle)]) == 0:
                self.phase = 2
        elif self.phase == 2:
            self._spawn_fire_ball()
            self.phase = 3
        elif self.phase == 4:
            if len([x for x in entities if isinstance(x, Heart)
                    ]) == 0 and not self._set_phase_5_timer:
                self.set_timer('progress-5', 30, self._set_to_5)
                self._set_phase_5_timer = True
        elif self.phase == 5:
            if self._can_teleport and randint(0, 5) == 0:
                self._teleport(player_pos)
        elif self.phase == 6:
            self._spawn_icicle()
            self.phase = 7
        elif self.phase == 8:
            if len([x for x in entities if isinstance(x, Heart)]) == 0:
                self.phase = 9
        elif self.phase == 9:
            if self.position.y > TILE_SIZE * 2:
                self.position.y -= 1
            else:
                self.phase = 10
            return
        elif self.phase == 10:
            if self.health < 50:
                self.invulnerable = True
                self.phase = 11
            elif self._can_shoot:
                self._shoot_fireball(player_pos)
            return
        elif self.phase == 11:
            self._change_sprite(
                AnimatedSprite('final_boss_death.png',
                               Point2D(144, 108),
                               8,
                               speed=0.25))
            self.set_timer('death-timer', 24, self._die)
            self.phase = 12
            return
        else:
            return

        self.position.y = self.start_y + self.y_offset

        if abs(self.y_offset) > 16:
            self.downward = not self.downward
        if self.downward:
            self.y_offset -= 0.25
        else:
            self.y_offset += 0.25