ichigo/engine/game.go

26 lines
592 B
Go
Raw Normal View History

2021-07-23 13:12:54 +10:00
package engine
import "github.com/hajimehoshi/ebiten/v2"
2021-07-23 13:12:54 +10:00
// Game implements the ebiten methods using a collection of components.
type Game struct {
2021-07-23 13:13:50 +10:00
ScreenWidth int
ScreenHeight int
2021-07-30 14:25:32 +10:00
Scene *Scene
2021-07-23 13:12:54 +10:00
}
// Draw draws the entire thing.
2021-07-23 13:12:54 +10:00
func (g *Game) Draw(screen *ebiten.Image) {
2021-07-30 14:25:32 +10:00
g.Scene.Draw(screen, ebiten.GeoM{})
2021-07-23 13:12:54 +10:00
}
// Layout returns the configured screen width/height.
func (g *Game) Layout(outsideWidth, outsideHeight int) (w, h int) {
return g.ScreenWidth, g.ScreenHeight
}
2021-07-23 13:46:19 +10:00
// Update just passes the call onto Layers.
func (g *Game) Update() error {
2021-07-30 14:25:32 +10:00
return g.Scene.Update()
2021-07-23 13:46:19 +10:00
}