From 01a1334639002700faddf237c4fa8cdd0fa9aaca Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 1 Apr 2020 15:57:47 +0900 Subject: [PATCH] examples/blocks: Use RunGame Updates #1111 --- examples/blocks/blocks/game.go | 15 +++++++++------ examples/blocks/main.go | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/blocks/blocks/game.go b/examples/blocks/blocks/game.go index e40550e27..11d55620e 100644 --- a/examples/blocks/blocks/game.go +++ b/examples/blocks/blocks/game.go @@ -28,7 +28,11 @@ type Game struct { input Input } -func (g *Game) Update(r *ebiten.Image) error { +func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) { + return ScreenWidth, ScreenHeight +} + +func (g *Game) Update(*ebiten.Image) error { if g.sceneManager == nil { g.sceneManager = &SceneManager{} g.sceneManager.GoTo(&TitleScene{}) @@ -38,10 +42,9 @@ func (g *Game) Update(r *ebiten.Image) error { if err := g.sceneManager.Update(&g.input); err != nil { return err } - if ebiten.IsDrawingSkipped() { - return nil - } - - g.sceneManager.Draw(r) return nil } + +func (g *Game) Draw(screen *ebiten.Image) { + g.sceneManager.Draw(screen) +} diff --git a/examples/blocks/main.go b/examples/blocks/main.go index 1ebb4dd3e..b07f17a0c 100644 --- a/examples/blocks/main.go +++ b/examples/blocks/main.go @@ -41,9 +41,9 @@ func main() { defer pprof.StopCPUProfile() } - game := &blocks.Game{} - update := game.Update - if err := ebiten.Run(update, blocks.ScreenWidth, blocks.ScreenHeight, 2, "Blocks (Ebiten Demo)"); err != nil { + ebiten.SetWindowSize(blocks.ScreenWidth*2, blocks.ScreenHeight*2) + ebiten.SetWindowTitle("Blocks (Ebiten Demo)") + if err := ebiten.RunGame(&blocks.Game{}); err != nil { log.Fatal(err) } }