error checks

This commit is contained in:
Josh Deprez 2021-09-16 14:53:23 +10:00
parent ecff7f9850
commit 7af49d0787
2 changed files with 13 additions and 4 deletions

View file

@ -134,6 +134,7 @@ func (aw *Awakeman) realUpdate() error {
{Cell: 4, Duration: 3},
{Cell: 5, Duration: 2},
},
OneShot: true,
},
},
CellSize: image.Pt(8, 8),
@ -141,19 +142,23 @@ func (aw *Awakeman) realUpdate() error {
},
},
}
engine.PreorderWalk(bubble, func(c, _ interface{}) error {
if err := engine.PreorderWalk(bubble, func(c, _ interface{}) error {
if p, ok := c.(engine.Loader); ok {
return p.Load(Assets)
}
return nil
})
}); err != nil {
return err
}
aw.game.Register(bubble, aw.game.Parent(aw))
engine.PreorderWalk(bubble, func(c, _ interface{}) error {
if err := engine.PreorderWalk(bubble, func(c, _ interface{}) error {
if p, ok := c.(engine.Prepper); ok {
return p.Prepare(aw.game)
}
return nil
})
}); err != nil {
return err
}
bubble.Sprite.SetAnim(bubble.Sprite.Sheet.NewAnim("bubble"))
}

View file

@ -1,6 +1,8 @@
package game
import (
"math/rand"
"drjosh.dev/gurgle/engine"
)
@ -25,5 +27,7 @@ func (b *Bubble) Update() error {
if b.Life <= 0 {
b.game.Unregister(b)
}
b.Sprite.Actor.MoveX(float64(rand.Intn(3)-1), nil)
b.Sprite.Actor.MoveY(-1, nil)
return nil
}