Class: SoundManager

SoundManager()

SoundManager Static utility class for managing all game sounds. Handles sound playback, volume settings, and cooldowns to avoid audio spam.

Constructor

new SoundManager()

Source:

Members

BOSS_ATTACK :HTMLAudioElement

Sound played when the boss performs an attack
Type:
  • HTMLAudioElement
Source:

BOSS_DEAD :HTMLAudioElement

Frying sound played when the boss dies
Type:
  • HTMLAudioElement
Source:

BOSS_HURT :HTMLAudioElement

Sound played when the boss takes damage
Type:
  • HTMLAudioElement
Source:

BOSS_HURT_2 :HTMLAudioElement

Sound played when the boss takes damage
Type:
  • HTMLAudioElement
Source:

BOSS_INTRO :HTMLAudioElement

Intro sound played when the boss is triggered
Type:
  • HTMLAudioElement
Source:

BOTTLE_BREAK :HTMLAudioElement

Glass shattering sound played when the character throws a bottle
Type:
  • HTMLAudioElement
Source:

BOTTLE_COLLECT :HTMLAudioElement

Sound played when the player collects a bottle
Type:
  • HTMLAudioElement
Source:

BOTTLE_DROP :HTMLAudioElement

Sound played when a bottle drops into sand
Type:
  • HTMLAudioElement
Source:

CHARACTER_BOUNCE_HIGH :HTMLAudioElement

Sound for high bounce effect
Type:
  • HTMLAudioElement
Source:

CHARACTER_BOUNCE_LOW :HTMLAudioElement

Sound for low bounce effect
Type:
  • HTMLAudioElement
Source:

CHARACTER_DEAD :HTMLAudioElement

Sound when the character dies
Type:
  • HTMLAudioElement
Source:

CHARACTER_HURT :HTMLAudioElement

Sound when the character gets hurt
Type:
  • HTMLAudioElement
Source:

CHARACTER_JUMP :HTMLAudioElement

Sound when the character jumps
Type:
  • HTMLAudioElement
Source:

CHARACTER_LONG_IDLE :HTMLAudioElement

Snoring sound played during a long idle animation
Type:
  • HTMLAudioElement
Source:

CHARACTER_THROW :HTMLAudioElement

Sound played when the character throws a bottle
Type:
  • HTMLAudioElement
Source:

CHARACTER_WALK :HTMLAudioElement

Sound for walking steps
Type:
  • HTMLAudioElement
Source:

CHICKEN_NOISE :HTMLAudioElement

Random chicken clucking sound
Type:
  • HTMLAudioElement
Source:

CHICKEN_SPAWN_1 :HTMLAudioElement

Chicken spawn sound
Type:
  • HTMLAudioElement
Source:

COIN_BAR_FILLED_UP :HTMLAudioElement

Sound played when the coin bar is full and a reward is triggered
Type:
  • HTMLAudioElement
Source:

COIN_COLLECT :HTMLAudioElement

Sound played when the player collects a coin
Type:
  • HTMLAudioElement
Source:

MUSIC_BACKGROUND :HTMLAudioElement

Looping background music for regular gameplay
Type:
  • HTMLAudioElement
Source:

MUSIC_BOSS_FIGHT :HTMLAudioElement

Music played during the boss fight
Type:
  • HTMLAudioElement
Source:

MUSIC_BOSS_INTRO :HTMLAudioElement

Intro music played before the boss fight begins
Type:
  • HTMLAudioElement
Source:

MUSIC_GAME_OVER :HTMLAudioElement

Music played on game over screen
Type:
  • HTMLAudioElement
Source:

MUSIC_GAME_WON :HTMLAudioElement

Music played during game victory screen
Type:
  • HTMLAudioElement
Source:

allSounds :Array.<HTMLAudioElement>

Collection of all defined sound objects in the game. Used for batch operations like muting, unmuting, or pausing all sounds.
Type:
  • Array.<HTMLAudioElement>
Source:

cooldowns :Map.<Audio, number>

Maps sound objects to their individual cooldown timers. Prevents the same sound from being played repeatedly in quick succession.
Type:
  • Map.<Audio, number>
Source:

isMuted :boolean

Indicates whether global sound output is currently muted. Used to toggle playback state for all sounds.
Type:
  • boolean
Source:

volumes :Map.<Audio, number>

Stores individual volume levels for each sound object. Allows for fine-grained volume control.
Type:
  • Map.<Audio, number>
Source:

Methods

(static) configureSound(sound, playbackRate, volume, loop, currentTime)

Applies playback settings to the given sound.
Parameters:
Name Type Description
sound HTMLAudioElement The sound to configure.
playbackRate number Speed at which the sound plays.
volume number Volume level (0.0 to 1.0).
loop boolean Whether the sound should loop.
currentTime number Start time in seconds.
Source:

(static) muteAll()

Mutes all sounds by setting their volume to 0 and storing their current volume in a map for later restoration.
Source:

(static) playOne(sound, playbackRateopt, volumeopt, cooldownopt, loopopt, currentTimeopt)

Plays a sound once with specified settings. Handles playback rate, volume, cooldown prevention, loop state, and starting time. Skips playback if the sound is currently on cooldown. After playback ends, automatically reloads the sound to prepare it for next use. (Fix for Firefox and Safari)
Parameters:
Name Type Attributes Default Description
sound HTMLAudioElement The sound to play.
playbackRate number <optional>
1 Speed multiplier for the sound (e.g. 0.5 = slower, 2 = faster).
volume number <optional>
0.2 Initial volume (0.0 to 1.0).
cooldown number <optional>
0 Time in ms before the sound can be played again.
loop boolean <optional>
false Whether the sound should loop continuously.
currentTime number <optional>
0 Position (in seconds) to start playback from.
Source:

(static) stopAll()

Stops (pauses) all registered sounds in the game. Useful for global pause scenarios or end-of-game transitions.
Source:

(static) stopOne(sound)

Stops (pauses) the given sound. Playback can later be resumed with `.play()` from the current position.
Parameters:
Name Type Description
sound HTMLAudioElement The sound to stop.
Source:

(static) toggleMuteAll()

Toggles the global mute state for all sounds. Mutes or unmutes all sounds depending on the current state, updates the mute button visually, and saves the state to local storage.
Source:

(static) unmuteAll()

Unmutes all sounds by restoring their previous volume from the volume map, if available.
Source: