Options
All
  • Public
  • Public/Protected
  • All
Menu

Sound class. Makes it easy to play sound.

This class is implemented using the Singleton Pattern. See https://en.wikipedia.org/wiki/Singleton_pattern

Hierarchy

  • Sound

Index

Constructors

Private constructor

Properties

Private audioMap

audioMap: Map<SoundType, HTMLAudioElement>

Map of audio files.

Private stepSounds

stepSounds: HTMLAudioElement[]

Array of footstep sound {@link HTMLAudioElement} instances.

Static Readonly STEP_MAX_VOLUME

STEP_MAX_VOLUME: 0.25 = 0.25

Maximum volume of steps. Ranges between 0 and 1.

Static Private Readonly VOLUME_CUTOFF

VOLUME_CUTOFF: 20 = 20

Determines after which distance the sound is dampened completely.

Static Private instance

instance: Sound

Singleton instance

Accessors

Static get

Methods

distanceToVolume

  • distanceToVolume(distance: number): number
  • Calculates an ideal volume curve for sounds that have been triggered somewhere else on the map.

    Parameters

    • distance: number

      Amount of distance between Player and Enemy.

    Returns number

    Volume,ranging between 0 and 1.

play

  • play(type: SoundType, volume: number): void
  • Plays the shoot sound effect.

    Parameters

    • type: SoundType

      what type of sound are we playing

    • volume: number

      how loud the sound plays. Ranges from 0 to 1.

    Returns void

Generated using TypeDoc