Pause/unpause sound added. Minor audio tweaks. Cleanup.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"mover/gamedata"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
"github.com/hajimehoshi/ebiten/v2/audio"
|
||||
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
||||
"github.com/hajimehoshi/ebiten/v2/text"
|
||||
)
|
||||
@@ -20,6 +21,7 @@ type StartScreen struct {
|
||||
targetreached bool
|
||||
audioplayed bool
|
||||
cycle int
|
||||
audioplayer *audio.Player
|
||||
}
|
||||
|
||||
func NewStartScreen() *StartScreen {
|
||||
@@ -39,11 +41,14 @@ func (s *StartScreen) Update() error {
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyEnter) ||
|
||||
ebiten.IsStandardGamepadButtonPressed(0, ebiten.StandardGamepadButtonCenterRight) {
|
||||
s.eHandler[EventCompleted]()
|
||||
if s.audioplayer.IsPlaying() {
|
||||
s.audioplayer.Close()
|
||||
}
|
||||
}
|
||||
|
||||
if !s.audioplayed {
|
||||
player := audioContext.NewPlayerFromBytes(assets.Survive)
|
||||
player.Play()
|
||||
s.audioplayer = audioContext.NewPlayerFromBytes(assets.Survive)
|
||||
s.audioplayer.Play()
|
||||
s.audioplayed = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user