carotidartillery/audio.go

35 lines
581 B
Go
Raw Normal View History

2021-10-08 02:36:24 +00:00
package main
import (
"github.com/hajimehoshi/ebiten/v2/audio"
"github.com/hajimehoshi/ebiten/v2/audio/wav"
)
const (
SoundGunshot = iota
SoundVampireDie1
SoundVampireDie2
2021-10-11 07:52:48 +00:00
SoundBat
2021-10-08 02:36:24 +00:00
SoundPlayerHurt
SoundPlayerDie
2021-10-12 03:49:45 +00:00
SoundMunch
2021-10-08 02:36:24 +00:00
SoundGib
)
2021-10-12 03:49:45 +00:00
const numSounds = 7 // Must match above size.
2021-10-08 02:36:24 +00:00
func loadWav(context *audio.Context, p string) (*audio.Player, error) {
f, err := assetsFS.Open(p)
if err != nil {
return nil, err
}
defer f.Close()
stream, err := wav.DecodeWithSampleRate(sampleRate, f)
if err != nil {
return nil, err
}
return context.NewPlayer(stream)
}