Options
All
  • Public
  • Public/Protected
  • All
Menu

Dedicated enemy class for other players. Provides all methods the game uses to display competitors on the playfield.

Hierarchy

Index

Constructors

constructor

Properties

Protected angle

angle: number

Direction the sprite is facing in radiants.

Private deathSprite

deathSprite: Image2D

What sprite to show when this enemy is dead

Private distanceToPlayer

distanceToPlayer: number

The distance from the player.

Private hasShot

hasShot: boolean

Determines if the enemy has shot recently.

Private idleSprites

idleSprites: Image2D[]

Array of idling sprites of the enemy. (Front / Back / Left / Right)

Private isWalking

isWalking: boolean

Determines if the enemy is currently walking.

lastPlayerViewingAngle

lastPlayerViewingAngle: number

Last angle this sprite was viewed from the perspective of the player.

Private playerInfo

playerInfo: PlayerInfo

All player informaton of the enemy. See PlayerInfo

Protected position

position: Vec2D

Position on the map.

Private shootingSprites

shootingSprites: Image2D[]

Array of shooting sprites of the enemy. (Front / Back / Left / Right)

Private spriteMap

spriteMap: Map<EnemySpriteState, Image2D[]>

Map collection of all sprites of the enemy. Makes organizing and loading the correct sprite for the situation easier.

Private spriteState

spriteState: EnemySpriteState

Current walking state of the enemy. See {@link EnemySpriteState}

Private timeElapsedSinceStartedWalking

timeElapsedSinceStartedWalking: number

Time that has passed since the player started walking. Needed for walking animation.

Private timeSinceShotInterval

timeSinceShotInterval: number

Time that passes between shooting animation intervals. Needed for shooting animation.

Private timeSinceWalkInterval

timeSinceWalkInterval: number

Time that passes between walking animation intervals. Needed for walking animation.

Private walkAnimationCounter

walkAnimationCounter: number

Counter of the walking animation. Needed for walking animation. Needed for counting until the next animation is triggered.

Private walkSprites1

walkSprites1: Image2D[]

Array of left stepping walking sprites of the enemy. (Front / Back / Left / Right)

Private walkSprites2

walkSprites2: Image2D[]

Array of right stepping walking sprites of the enemy. (Front / Back / Left / Right)

Static Private Readonly ENEMY_HEIGHT

ENEMY_HEIGHT: 2048 = 2048

Height of enemy sprite.

Static Private Readonly ENEMY_SCALING

ENEMY_SCALING: 0.4 = 0.4

Scaling of enemy sprite (relative to the walls)

Static Private Readonly ENEMY_WIDTH

ENEMY_WIDTH: 1024 = 1024

Width of enemy sprite.

Static Readonly STEP_SOUND_DIVIDER

STEP_SOUND_DIVIDER: 2 = 2

Determines by which divisor the step sound volume is calculated.

Static Private Readonly WALKING_CYCLE

WALKING_CYCLE: EnemySpriteState[] = ...

Fixed array that defines the order of the walking animation.

Static Private Readonly WALK_COOLDOWN

WALK_COOLDOWN: 0.5 = 0.5

Time in [seconds] how long the walking animation cooldown lasts.

Static Readonly WALK_INTERVAL

WALK_INTERVAL: 0.2 = 0.2

Time in [seconds] how long the walking animation interval lasts.

Accessors

getAngle

  • get getAngle(): number

getPlayerInfo

getPosition

  • get getPosition(): Vec2D

getShot

  • get getShot(): boolean
  • Getter for has shot

    Returns boolean

    true if the player has just shot his gun

setAngle

  • set setAngle(angle: number): void
  • Setter for the looking angle

    Parameters

    • angle: number

      angle the entity's looking at

    Returns void

setPlayerInfo

setPosition

  • set setPosition(position: Vec2D): void

Methods

cycleSpriteState

  • cycleSpriteState(): void

getSprite

shoot

  • shoot(playerPosition: Vec2D): void
  • Triggers shooting animation.

    Parameters

    • playerPosition: Vec2D

      The position from which the player has shot his gun

    Returns void

update

  • update(time: number): void
  • Update method for walking animation.

    This is mainly a finite state machine cycling between animations until the time has run out.

    Parameters

    • time: number

      how much time has passed. [seconds]

    Returns void

updateDistanceToPlayer

  • updateDistanceToPlayer(playerPosition: Vec2D): void

walk

  • walk(): void

Generated using TypeDoc