def __init__(self, direction: Vector2):
     sprites = ResourceManagement.get_projectile_fire_ball_sprites()
     sprite = next(iter(sprites.values()))[0]
     Projectile.__init__(self, sprite)
     AnimatedSprite.__init__(self, sprites, 3, ProjectileState.DEFAULT)
     self.__death_time = EnemyProjectile._death_time()
     self._direction = direction
 def __init__(self):
     sprites = ResourceManagement.get_enemy_stone_sprites()
     sprite = next(iter(sprites.values()))[0]
     Enemy.__init__(self, sprite, EnemySettings.HeavyRock.WEIGHT,
                    EnemySettings.HeavyRock.HEALTH_MAX,
                    EnemySettings.HeavyRock.ATTACK_COOLDOWN_S)
     AnimatedSprite.__init__(self, sprites, 2, EnemyState.RUNNING_LEFT)
    def update(self, delta_time: float):
        distance_to_target_sqr = EnemySettings.Ranged.DETECTION_RANGE_SQR + 1 if self._target is None else \
            self.center.distance_squared_to(self._target.center)

        # If too far away, just walk
        if distance_to_target_sqr > EnemySettings.Ranged.DETECTION_RANGE_SQR and self.is_on_ground:
            self.move(EnemySettings.CHILL_WALK_VELOCITY * self._direction *
                      delta_time)
            self._state = (EnemyState.RUNNING_LEFT if self._direction < 0 else
                           EnemyState.RUNNING_RIGHT)

        # If the player is on fear range run in the opposite direction
        elif distance_to_target_sqr < EnemySettings.Ranged.FEAR_RANGE_SQR and self.is_on_ground:
            self.move(EnemySettings.Ranged.FEAR_WALK_VELOCITY *
                      self._target_direction() * delta_time)
            self._state = (EnemyState.RUNNING_LEFT if self._direction < 0 else
                           EnemyState.RUNNING_RIGHT)

        # If in range
        elif time.time() > self.__cooldown_expire:
            self.attack()
            self._state = (EnemyState.ATTACKING_LEFT if self._direction < 0
                           else EnemyState.ATTACKING_RIGHT)

        RigidPhysicsAwareGameObject.update(self, delta_time)
        AnimatedSprite.update(self, delta_time)
    def update(self, delta_time: float):

        # I'am just good guy you kown
        self.move(EnemySettings.HeavyRock.SPEED * self._direction * delta_time)
        self._state = (EnemyState.RUNNING_LEFT
                       if self._direction < 0 else EnemyState.RUNNING_RIGHT)
        RigidPhysicsAwareGameObject.update(self, delta_time)
        AnimatedSprite.update(self, delta_time)
 def __init__(self):
     sprites = ResourceManagement.get_enemy_fire_sprites()
     first_sprite = next(iter(sprites.values()))[0]
     Enemy.__init__(self, first_sprite, EnemySettings.Ranged.WEIGHT,
                    EnemySettings.Ranged.HEALTH_MAX,
                    EnemySettings.Ranged.ATTACK_COOLDOWN_S)
     AnimatedSprite.__init__(self, sprites, 3, EnemyState.RUNNING_LEFT)
     self.__cooldown_expire = 0
Пример #6
0
 def update(self, delta_time: float):
     if self.___death_time <= time.time():
         self.kill()
     else:
         self.center = self._player.center
         self.transform.y = self._player.rect.bottom - self.height / 2
         Projectile.update(self, delta_time)
         AnimatedSprite.update(self, delta_time)
    def update(self, delta_time: float):
        self.is_pressed = False
        RigidPhysicsAwareGameObject.update(self, delta_time)
        AnimatedSprite.update(self, delta_time)
        if self.is_pressed != self.was_pressed:
            self.was_pressed = False

            for handler in self.on_exit:
                handler()
Пример #8
0
 def __init__(self):
     sprites = ResourceManagement.get_enemy_ice_sprites()
     first_sprite = next(iter(sprites.values()))[0]
     Enemy.__init__(self, first_sprite, .5,
                    EnemySettings.HandToHand.HEALTH_MAX,
                    EnemySettings.HandToHand.ATTACK_COOLDOWN_S)
     AnimatedSprite.__init__(self,
                             ResourceManagement.get_enemy_ice_sprites(), 4,
                             EnemyState.RUNNING_RIGHT)
     self.__retreat_distance_sqr: float = 0
Пример #9
0
    def __init__(self, level: int, player: GameObject):
        default_state = (TornadoProjectileState.BIG if level > 1 else TornadoProjectileState.SMALL)
        sprites = ResourceManagement.get_projectile_tornado_sprites()
        first_sprite = sprites[default_state][0]

        Projectile.__init__(self, first_sprite)
        AnimatedSprite.__init__(self, sprites, 3, default_state)
        self.___death_time = time.time() + PlayerSettings.Ability.TornadoJump.TIME_TO_LIVE
        self._player = player
        self.level = level
Пример #10
0
    def update(self, delta_time: float):
        # Update controls
        self.__update_controls(delta_time)

        # Passive mana regeneration
        self.__update_mana_regeneration(delta_time)

        # Finally, apply physics
        RigidPhysicsAwareGameObject.update(self, delta_time)

        # Update the state
        self.__update_state()
        AnimatedSprite.update(self, delta_time)
Пример #11
0
    def __init__(self, weight: float = .5):
        sprites = ResourceManagement.get_player_sprites()
        first_sprite = next(iter(sprites.values()))[0]

        RigidPhysicsAwareGameObject.__init__(self, first_sprite, weight)
        LivingEntity.__init__(self,
                              PlayerSettings.HEALTH_MAX,
                              invincibility_duration=1)
        AnimatedSprite.__init__(self, sprites, 3, PlayerState.IDLE)
        self.ability_tornado_jump = TornadoJumpAbility(1)
        self.ability_gust = GustAbility(0)
        self.ability_slam = SlamAbility(0)
        self.mana: float = PlayerSettings.MANA_MAX
        self._last_direction = 1
Пример #12
0
    def __init__(self, level, strength: Vector2):
        sprites = ResourceManagement.get_projectile_slam_sprites(
            (
                int(PlayerSettings.Ability.Slam.AREA_SIZE[0] * {1: 1, 2: 2, 3: 3.60}[level]),
                PlayerSettings.Ability.Slam.AREA_SIZE[1]
            )
        )
        first_sprite = next(iter(sprites.values()))[0]

        Projectile.__init__(self, first_sprite)
        AnimatedSprite.__init__(self, sprites, 12, ProjectileState.DEFAULT)
        self.strength = strength
        self._level = level
        self.__death_time = self._death_time()
    def __init__(self, on_enter: [Callable[[], None]] = None, on_stay_inside: [Callable[[], None]] = None,
                 on_exit: [Callable[[], None]] = None):
        sprites = ResourceManagement.get_environment_button_sprites()
        first_sprite = next(iter(sprites.values()))[0]

        RigidPhysicsAwareGameObject.__init__(self, first_sprite, 0)
        AnimatedSprite.__init__(self, sprites, 1, ButtonState.OFF)
        self.on_enter = on_enter if on_enter is not None else []
        self.on_enter.append(self.__hide)

        self.during_activation = on_stay_inside if on_stay_inside is not None else []

        self.on_exit = on_exit if on_exit is not None else []
        self.on_exit.append(self.__show)

        self.was_pressed = False
        self.is_pressed = False
    def __init__(self, size: (int, int), direction: Vector2, force: float):
        surface = Surface(size)

        RigidPhysicsAwareGameObject.__init__(self, surface, 0)
        AnimatedSprite.__init__(
            self,
            ResourceManagement.get_environment_wind_stream_sprites(size),
            2, WindDirection.UP)
        self._direction = direction.normalize()
        self._force = force
        if abs(direction.x) > abs(direction.y):
            if direction.x > 0:
                self._state = WindDirection.RIGHT
            else:
                self._state = WindDirection.LEFT
        else:
            if direction.y > 0:
                self._state = WindDirection.DOWN
            else:
                self._state = WindDirection.UP
Пример #15
0
 def update(self, delta_time: float):
     self._update_state()
     Enemy.update(self, delta_time)
     AnimatedSprite.update(self, delta_time)
 def update(self, delta_time: float):
     RigidPhysicsAwareGameObject.update(self, delta_time)
     AnimatedSprite.update(self, delta_time)
Пример #17
0
 def update(self, delta_time: float):
     if self.__death_time <= time.time():
         self.kill()
     else:
         Projectile.update(self, delta_time)
         AnimatedSprite.update(self, delta_time)
Пример #18
0
 def __init__(self):
     sprites = ResourceManagement.get_projectile_gust_sprites()
     first_sprite = next(iter(sprites.values()))[0]
     Projectile.__init__(self, first_sprite)
     AnimatedSprite.__init__(self, sprites, 12, ProjectileState.DEFAULT)
     self.__death_time = time.time() + PlayerSettings.Ability.Gust.TIME_TO_LIVE