You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
581 B
34 lines
581 B
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) |
|
}
|
|
|