slayer_in_the_shadows.sprites.enemy
#
Classes for the various enemy types
Module Contents#
Classes#
- class slayer_in_the_shadows.sprites.enemy.Enemy(bottom: float, left: float, sprite: str, health: int, speed: int, attacks: list[slayer_in_the_shadows.sprites.attacks.AttackSpec], game)[source]#
Bases:
slayer_in_the_shadows.sprites.character.Character
Base enemy class from which the various enemy types are made
- on_update(delta_time: float = 1 / 60)[source]#
Time related cooldowns like attack and invulnerability
- look_for(player, blocks)[source]#
Checks if the player is visible to the enemy.
This method will determine if an enemy can “see” the player. It does this with 3 checks: 1. It checks all the blocks between the player and the enemy and determines if any interfere. 2. It determines if the player is in the field of view. When the enemy is facing right (enemy.direction == 1), its field of view is from 7pi/4 to pi/4. When it’s facing left (enemy.direction == -1), its FOV is modeled by 3pi/4 to 5pi/4. If the angle between the horizontal and the player is in one of those ranges, it moves on. 3. The player isn’t too far away. The distance between the player and the enemy is less than the enemy’s render distance.