From e0e9d7f0739fc4c0c0e8cdc8c30ac827715db04b Mon Sep 17 00:00:00 2001 From: davidovski Date: Tue, 23 Apr 2024 16:50:54 +0100 Subject: add voice over --- main.go | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index bfadeb1..22dbed1 100644 --- a/main.go +++ b/main.go @@ -38,7 +38,8 @@ const ( exitTransitionWeight = 0.7 ghostAlpha = 0.5 hightlightBorder = 2 - audioFadeIn = 0.999 + audioFadeIn = 0.99 + musicVolume = 0.3 sampleRate = 44100 shadowOffset = 1 @@ -93,6 +94,21 @@ var ( //go:embed assets/land2.ogg land2Ogg_src []byte + + //go:embed assets/vo/voice1.ogg + voice1Ogg_src []byte + //go:embed assets/vo/voice2.ogg + voice2Ogg_src []byte + //go:embed assets/vo/voice3.ogg + voice3Ogg_src []byte + //go:embed assets/vo/voice4.ogg + voice4Ogg_src []byte + //go:embed assets/vo/voice5.ogg + voice5Ogg_src []byte + //go:embed assets/vo/voice6.ogg + voice6Ogg_src []byte + //go:embed assets/vo/voice7.ogg + voice7Ogg_src []byte ) var ( @@ -136,6 +152,7 @@ type AudioPlayer struct { springAudio *audio.Player jumpAudio []*audio.Player landAudio []*audio.Player + voiceAudio []*audio.Player } type Game struct { @@ -311,7 +328,7 @@ func (g *Game) Update() error { g.audioPlayer.ambientAudio.Play() } volume := g.audioPlayer.ambientAudio.Volume() - volume = 1-((1-volume)*audioFadeIn) + volume = musicVolume-((musicVolume-volume)*audioFadeIn) g.audioPlayer.ambientAudio.SetVolume(volume) } @@ -839,6 +856,16 @@ func (g *Game) LoadAudio() { g.audioPlayer.jumpAudio = loadAudiosVorbis([][]byte{jump1Ogg_src, jump2Ogg_src}, g.audioPlayer.audioContext) g.audioPlayer.landAudio = loadAudiosVorbis([][]byte{land1Ogg_src, land2Ogg_src}, g.audioPlayer.audioContext) + g.audioPlayer.voiceAudio = loadAudiosVorbis([][]byte{ + voice1Ogg_src, + voice2Ogg_src, + voice3Ogg_src, + voice4Ogg_src, + voice5Ogg_src, + voice6Ogg_src, + voice7Ogg_src, + }, g.audioPlayer.audioContext) + } func (g *Game) LoadImages() { -- cgit v1.2.1