diff --git a/TODO.md b/TODO.md index fa55369..005f412 100644 --- a/TODO.md +++ b/TODO.md @@ -11,4 +11,5 @@ - [ ] Fix z-fighting of monsters. - [ ] Add exploding animation of monsters. - [ ] Add audio settings (music & sound volume). -- [X] Hearts must be saved as well for resume. \ No newline at end of file +- [X] Hearts must be saved as well for resume. +- [ ] Add demo mode. diff --git a/cmd/tins2021/app.go b/cmd/tins2021/app.go index 2fb9ea9..b8981d1 100644 --- a/cmd/tins2021/app.go +++ b/cmd/tins2021/app.go @@ -1,6 +1,8 @@ package main import ( + "log" + "opslag.de/schobers/tins2021" "opslag.de/schobers/zntg/play" "opslag.de/schobers/zntg/ui" @@ -73,7 +75,7 @@ func (a *app) Init(ctx ui.Context) error { "player_move.mp3", ) if err != nil { - return err + log.Printf("failed to load samples; %v\n", err) } return nil diff --git a/cmd/tins2021/audio.go b/cmd/tins2021/audio.go index 9f268dc..859d648 100644 --- a/cmd/tins2021/audio.go +++ b/cmd/tins2021/audio.go @@ -9,6 +9,8 @@ import ( "github.com/faiface/beep/effects" "github.com/faiface/beep/mp3" "github.com/faiface/beep/speaker" + "github.com/pkg/errors" + "opslag.de/schobers/ut" "opslag.de/schobers/zntg/ui" ) @@ -39,12 +41,16 @@ func NewAudioPlayer(resources ui.Resources, prefix string) *AudioPlayer { } func (p *AudioPlayer) LoadSample(name ...string) error { + var all error for _, name := range name { if _, err := p.openSample(name); err != nil { - return err + all = ut.ErrCombine(all, errors.Wrap(err, "failed to open sample")) } } - return nil + if all == nil { + return nil + } + return errors.WithMessage(all, "failed to open one or more samples") } func (p *AudioPlayer) openSample(name string) (Sample, error) {