diff --git a/examples/2048/2048/game.go b/examples/2048/2048/game.go index c193a70aa..f8e5c877c 100644 --- a/examples/2048/2048/game.go +++ b/examples/2048/2048/game.go @@ -51,8 +51,13 @@ func NewGame() (*Game, error) { return g, nil } +// Layout implements ebiten.Game's Layout. +func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) { + return ScreenWidth, ScreenHeight +} + // Update updates the current game state. -func (g *Game) Update() error { +func (g *Game) Update(*ebiten.Image) error { g.input.Update() if err := g.board.Update(g.input); err != nil { return err diff --git a/examples/2048/main.go b/examples/2048/main.go index aae6e14e8..58dc62d12 100644 --- a/examples/2048/main.go +++ b/examples/2048/main.go @@ -23,28 +23,14 @@ import ( "github.com/hajimehoshi/ebiten/examples/2048/2048" ) -var ( - game *twenty48.Game -) - -func update(screen *ebiten.Image) error { - if err := game.Update(); err != nil { - return err - } - if ebiten.IsDrawingSkipped() { - return nil - } - game.Draw(screen) - return nil -} - func main() { - var err error - game, err = twenty48.NewGame() + game, err := twenty48.NewGame() if err != nil { log.Fatal(err) } - if err := ebiten.Run(update, twenty48.ScreenWidth, twenty48.ScreenHeight, 1, "2048 (Ebiten Demo)"); err != nil { + ebiten.SetWindowSize(twenty48.ScreenWidth, twenty48.ScreenHeight) + ebiten.SetWindowTitle("2048 (Ebiten Demo)") + if err := ebiten.RunGame(game); err != nil { log.Fatal(err) } }