image ref?
This commit is contained in:
parent
bcad4fcb73
commit
acaa279e05
4 changed files with 33 additions and 0 deletions
16
engine/asset.go
Normal file
16
engine/asset.go
Normal 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
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package engine
|
package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
@ -8,6 +9,10 @@ import (
|
||||||
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
gob.Register(PerfDisplay{})
|
||||||
|
}
|
||||||
|
|
||||||
// PerfDisplay debugprints CurrentTPS and CurrentFPS in the top left.
|
// PerfDisplay debugprints CurrentTPS and CurrentFPS in the top left.
|
||||||
type PerfDisplay struct{}
|
type PerfDisplay struct{}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
package engine
|
package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/gob"
|
||||||
"math"
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
gob.Register(Scene{})
|
||||||
|
}
|
||||||
|
|
||||||
// Drawer is a component that can draw itself. Draw is called often.
|
// Drawer is a component that can draw itself. Draw is called often.
|
||||||
type Drawer interface {
|
type Drawer interface {
|
||||||
Draw(screen *ebiten.Image, geom ebiten.GeoM)
|
Draw(screen *ebiten.Image, geom ebiten.GeoM)
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
package engine
|
package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/gob"
|
||||||
"image"
|
"image"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
gob.Register(AnimatedTile{})
|
||||||
|
gob.Register(StaticTile(0))
|
||||||
|
gob.Register(Tilemap{})
|
||||||
|
}
|
||||||
|
|
||||||
type Tilemap struct {
|
type Tilemap struct {
|
||||||
Map [][]Tile
|
Map [][]Tile
|
||||||
Src *ebiten.Image // must be a horizontal tile set
|
Src *ebiten.Image // must be a horizontal tile set
|
||||||
|
|
Loading…
Reference in a new issue