carotidartillery/audio.go

35 lines
581 B
Go

package main
import (
"github.com/hajimehoshi/ebiten/v2/audio"
"github.com/hajimehoshi/ebiten/v2/audio/wav"
)
const (
SoundGunshot = iota
SoundVampireDie1
SoundVampireDie2
SoundBat
SoundPlayerHurt
SoundPlayerDie
SoundMunch
SoundGib
)
const numSounds = 7 // Must match above size.
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)
}