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: // Thorson-style movement:
// https://maddythorson.medium.com/celeste-and-towerfall-physics-d24bd2ae0fc5 // 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. // Actor handles basic movement.
type Actor struct { type Actor struct {
CollisionDomain string CollisionDomain string

View file

@ -1,6 +1,15 @@
package engine 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. // Drawer components can draw themselves. Draw is called often.
// Each component is responsible for calling Draw on its child components. // Each component is responsible for calling Draw on its child components.

View file

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

View file

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