Added music and sfx.
This commit is contained in:
57
assets/audiobank.go
Normal file
57
assets/audiobank.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package assets
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"log"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/audio/wav"
|
||||
)
|
||||
|
||||
type SndAssetName string
|
||||
|
||||
const (
|
||||
MainLoop SndAssetName = "MainLoop"
|
||||
Explode SndAssetName = "Explode"
|
||||
|
||||
sampleRate = 44100
|
||||
)
|
||||
|
||||
var (
|
||||
SoundBank map[SndAssetName]*wav.Stream
|
||||
|
||||
//go:embed loop.wav
|
||||
mainloop_snd []byte
|
||||
//go:embed explode.wav
|
||||
explode_snd []byte
|
||||
|
||||
//go:embed explode.wav
|
||||
Splode []byte
|
||||
//go:embed hit.wav
|
||||
TargetHit []byte
|
||||
//go:embed herodeath.wav
|
||||
HeroDeath []byte
|
||||
//go:embed shot.wav
|
||||
Shot []byte
|
||||
//go:embed magic.wav
|
||||
Magic []byte
|
||||
//go:embed survive.wav
|
||||
Survive []byte
|
||||
)
|
||||
|
||||
func LoadSounds() {
|
||||
SoundBank = make(map[SndAssetName]*wav.Stream)
|
||||
|
||||
SoundBank[MainLoop] = LoadSoundFatal(sampleRate, mainloop_snd)
|
||||
SoundBank[Explode] = LoadSoundFatal(sampleRate, explode_snd)
|
||||
}
|
||||
|
||||
func LoadSoundFatal(rate int, obj []byte) *wav.Stream {
|
||||
|
||||
stream, err := wav.DecodeWithSampleRate(rate, bytes.NewReader(obj))
|
||||
if err != nil {
|
||||
log.Fatal("dead, jim")
|
||||
}
|
||||
|
||||
return stream
|
||||
}
|
||||
BIN
assets/explode.wav
Normal file
BIN
assets/explode.wav
Normal file
Binary file not shown.
BIN
assets/herodeath.wav
Normal file
BIN
assets/herodeath.wav
Normal file
Binary file not shown.
BIN
assets/hit.wav
Normal file
BIN
assets/hit.wav
Normal file
Binary file not shown.
@@ -10,27 +10,22 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
|
||||
type AssetName string
|
||||
type ImgAssetName string
|
||||
|
||||
const (
|
||||
FlyEyeNormal AssetName = "FlyEyeNormal"
|
||||
FlyEyeDamaged AssetName = "FlyEyeDamaged"
|
||||
FlyEyeDying AssetName = "FlyEyeDying"
|
||||
FlyEyeShadow AssetName = "FlyEyeShadow"
|
||||
HeroNormal AssetName = "HeroNormal"
|
||||
HeroDying AssetName = "HeroDying"
|
||||
TileSet AssetName = "TileSet"
|
||||
Altar AssetName = "Altar"
|
||||
Weapon AssetName = "Weapon"
|
||||
FlyEyeNormal ImgAssetName = "FlyEyeNormal"
|
||||
FlyEyeDamaged ImgAssetName = "FlyEyeDamaged"
|
||||
FlyEyeDying ImgAssetName = "FlyEyeDying"
|
||||
FlyEyeShadow ImgAssetName = "FlyEyeShadow"
|
||||
HeroNormal ImgAssetName = "HeroNormal"
|
||||
HeroDying ImgAssetName = "HeroDying"
|
||||
TileSet ImgAssetName = "TileSet"
|
||||
Altar ImgAssetName = "Altar"
|
||||
Weapon ImgAssetName = "Weapon"
|
||||
)
|
||||
|
||||
var (
|
||||
ImageBank map[AssetName]*ebiten.Image
|
||||
|
||||
flyeyeImage *ebiten.Image
|
||||
flyeyeImage2 *ebiten.Image
|
||||
flyeyeImage3 *ebiten.Image
|
||||
shadow *ebiten.Image
|
||||
ImageBank map[ImgAssetName]*ebiten.Image
|
||||
|
||||
//go:embed fly-eye.png
|
||||
flyeye_img []byte
|
||||
@@ -53,7 +48,7 @@ var (
|
||||
)
|
||||
|
||||
func LoadImages() {
|
||||
ImageBank = make(map[AssetName]*ebiten.Image)
|
||||
ImageBank = make(map[ImgAssetName]*ebiten.Image)
|
||||
|
||||
ImageBank[FlyEyeNormal] = LoadImagesFatal(flyeye_img)
|
||||
ImageBank[FlyEyeDamaged] = LoadImagesFatal(flyeye_img2)
|
||||
|
||||
BIN
assets/loop.wav
Normal file
BIN
assets/loop.wav
Normal file
Binary file not shown.
BIN
assets/magic.wav
Normal file
BIN
assets/magic.wav
Normal file
Binary file not shown.
BIN
assets/shot.wav
Normal file
BIN
assets/shot.wav
Normal file
Binary file not shown.
BIN
assets/survive.wav
Normal file
BIN
assets/survive.wav
Normal file
Binary file not shown.
Reference in New Issue
Block a user