Skip to content

Commit

Permalink
Merge pull request #252 from trifle-labs/audio-refactor
Browse files Browse the repository at this point in the history
Audio refactor
  • Loading branch information
okwme authored Aug 12, 2024
2 parents ebfd9ce + 8811ae8 commit 3846d3e
Show file tree
Hide file tree
Showing 34 changed files with 174 additions and 343 deletions.
38 changes: 19 additions & 19 deletions dist/index.html

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions dist/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/module.js.map

Large diffs are not rendered by default.

Binary file added public/sound/ipod/ipod_14_FX.mp3.asd
Binary file not shown.
Binary file added public/sound/ipod/ipod_15_Delay_Reverb.mp3.asd
Binary file not shown.
Binary file added public/sound/ipod/ipod_2_T1.mp3.asd
Binary file not shown.
Binary file added public/sound/ipod/ipod_5_T4.mp3.asd
Binary file not shown.
Binary file added public/sound/ipod/ipod_7_T6.mp3.asd
Binary file not shown.
Binary file added public/sound/ipod/ipod_8_T7.mp3.asd
Binary file not shown.
Binary file added public/sound/ipod/ipod_hiss.mp3.asd
Binary file not shown.
Binary file added public/sound/orbit/orbit_10_DT6.mp3.asd
Binary file not shown.
Binary file added public/sound/orbit/orbit_3-Audio.mp3.asd
Binary file not shown.
Binary file added public/sound/orbit/orbit_8_DT1.mp3.asd
Binary file not shown.
Binary file added public/sound/orbit/orbit_9_DT2.mp3.asd
Binary file not shown.
Binary file added public/sound/tracks/ipod.mp3
Binary file not shown.
Binary file added public/sound/tracks/orbit.mp3
Binary file not shown.
Binary file added public/sound/tracks/whistle.mp3
Binary file not shown.
Binary file added public/sound/tracks/wii_A.mp3
Binary file not shown.
Binary file added public/sound/tracks/wii_B.mp3
Binary file not shown.
Binary file added public/sound/whistle/whistle_12_T11.mp3.asd
Binary file not shown.
Binary file added public/sound/whistle/whistle_12_T11.wav.asd
Binary file not shown.
Binary file added public/sound/whistle/whistle_4_T3.wav.asd
Binary file not shown.
Binary file added public/sound/whistle/whistle_7_T6.wav.asd
Binary file not shown.
Binary file added public/sound/whistle/whistle_8_T7.wav.asd
Binary file not shown.
Binary file added public/sound/whistle/whistle_8_T7_B.mp3.asd
Binary file not shown.
Binary file added public/sound/wii/wii_10_T9.mp3.asd
Binary file not shown.
Binary file added public/sound/wii/wii_12_T11.mp3.asd
Binary file not shown.
Binary file added public/sound/wii/wii_2_T1.mp3.asd
Binary file not shown.
Binary file added public/sound/wii/wii_4_T3.mp3.asd
Binary file not shown.
Binary file added public/sound/wii/wii_T5.mp3.asd
Binary file not shown.
Binary file added public/sound/wii/wii_chord.mp3.asd
Binary file not shown.
30 changes: 21 additions & 9 deletions src/anybody.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,19 @@ export class Anybody extends EventEmitter {
case 'KeyP':
if (!this.gameOver) this.setPause()
break
case 'KeyM':
this.mute = !this.mute
break
}
}

handleGameOver = ({ won }) => {
if (this.handledGameOver) return
this.handledGameOver = true
this.gameoverTickerX = 0
// this.sound?.playGameOver({ won }) // TDDO: improve audio
if (this.level !== 0) {
this.sound?.playGameOver({ won }) // TDDO: improve audio
}
this.gameOver = true
this.won = won
if (this.level !== 0 && !this.won) {
Expand Down Expand Up @@ -483,13 +488,16 @@ export class Anybody extends EventEmitter {
if (options) {
this.setOptions(options)
}
if (this.level !== this.lastLevel) {
// this.starBG = null
}
this.clearValues()
this.sound?.stop()
this.sound?.playStart()
this.sound?.setSong()
if (this.level !== this.lastLevel && this.level !== 1 && this.level !== 0) {
this.sound?.stop()
this.sound?.playStart()
this.sound?.setSong()
this.sound?.resume()
}
if (this.sound?.playbackRate !== 'normal') {
this.sound?.setPlaybackRate('normal')
}
this.init()
this.draw()
if (beginPaused) {
Expand Down Expand Up @@ -523,9 +531,13 @@ export class Anybody extends EventEmitter {

this.emit('paused', newPauseState)
if (newPauseState) {
if (!mute) this.sound?.pause()
if (!mute) {
this.sound?.pause()
}
} else {
if (!mute) this.sound?.resume()
if (!mute) {
this.sound?.resume()
}
}
}

Expand Down
Loading

0 comments on commit 3846d3e

Please sign in to comment.