more gobs and interface cleanup

This commit is contained in:
Josh Deprez 2021-08-05 12:33:23 +10:00 committed by Josh Deprez
parent 66e45e495a
commit c30472c67e
4 changed files with 20 additions and 6 deletions

View file

@ -13,11 +13,6 @@ func init() {
// Thorson-style movement:
// https://maddythorson.medium.com/celeste-and-towerfall-physics-d24bd2ae0fc5
// Collider components have tangible form.
type Collider interface {
CollidesWith(image.Rectangle) bool
}
// Actor handles basic movement.
type Actor struct {
CollisionDomain string

View file

@ -1,6 +1,15 @@
package engine
import "github.com/hajimehoshi/ebiten/v2"
import (
"image"
"github.com/hajimehoshi/ebiten/v2"
)
// Collider components have tangible form.
type Collider interface {
CollidesWith(image.Rectangle) bool
}
// Drawer components can draw themselves. Draw is called often.
// Each component is responsible for calling Draw on its child components.

View file

@ -1,11 +1,16 @@
package engine
import (
"encoding/gob"
"image"
"github.com/hajimehoshi/ebiten/v2"
)
func init() {
gob.Register(Sprite{})
}
// Sprite combines an Actor with the ability to Draw from a single spritesheet.
type Sprite struct {
Actor

View file

@ -1,6 +1,7 @@
package game
import (
"encoding/gob"
"image"
"drjosh.dev/gurgle/engine"
@ -8,6 +9,10 @@ import (
"github.com/hajimehoshi/ebiten/v2/inpututil"
)
func init() {
gob.Register(Awakeman{})
}
type Awakeman struct {
engine.Sprite