slayer_in_the_shadows.sprites.enemy#

Classes for the various enemy types

Module Contents#

Classes#

Enemy

Base enemy class from which the various enemy types are made

DemoEnemy

Example enemy

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.

in_fov(player)[source]#

Check if the player is in the field of view.

notice_player()[source]#

The enemy has detected the player and will now attack.

space_clear(player, blocks)[source]#

Checks if the space is clear between an enemy and the player.

find_new_spot()[source]#

Finds a new spot for the enemy to stand on when it is passive.

generate_available_spaces(sprite_list)[source]#

Generates available spaces

take_damage(damage: int)[source]#

Handles damage taking

class slayer_in_the_shadows.sprites.enemy.DemoEnemy(bottom: float, left: float, game)[source]#

Bases: Enemy

Example enemy