image ref?

This commit is contained in:
Josh Deprez 2021-07-30 17:26:23 +10:00 committed by Josh Deprez
parent bcad4fcb73
commit acaa279e05
4 changed files with 33 additions and 0 deletions

16
engine/asset.go Normal file
View file

@ -0,0 +1,16 @@
package engine
import "github.com/hajimehoshi/ebiten/v2"
type ImageRef struct {
Path string
image *ebiten.Image
}
func (r *ImageRef) Image() *ebiten.Image {
if r.image == nil {
// TODO
}
return r.image
}

View file

@ -1,6 +1,7 @@
package engine
import (
"encoding/gob"
"fmt"
"math"
@ -8,6 +9,10 @@ import (
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
)
func init() {
gob.Register(PerfDisplay{})
}
// PerfDisplay debugprints CurrentTPS and CurrentFPS in the top left.
type PerfDisplay struct{}

View file

@ -1,12 +1,17 @@
package engine
import (
"encoding/gob"
"math"
"sort"
"github.com/hajimehoshi/ebiten/v2"
)
func init() {
gob.Register(Scene{})
}
// Drawer is a component that can draw itself. Draw is called often.
type Drawer interface {
Draw(screen *ebiten.Image, geom ebiten.GeoM)

View file

@ -1,11 +1,18 @@
package engine
import (
"encoding/gob"
"image"
"github.com/hajimehoshi/ebiten/v2"
)
func init() {
gob.Register(AnimatedTile{})
gob.Register(StaticTile(0))
gob.Register(Tilemap{})
}
type Tilemap struct {
Map [][]Tile
Src *ebiten.Image // must be a horizontal tile set