mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-27 04:08:53 +01:00
parent
41213108ba
commit
a70d6a314e
@ -51,8 +51,13 @@ func NewGame() (*Game, error) {
|
|||||||
return g, nil
|
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.
|
// Update updates the current game state.
|
||||||
func (g *Game) Update() error {
|
func (g *Game) Update(*ebiten.Image) error {
|
||||||
g.input.Update()
|
g.input.Update()
|
||||||
if err := g.board.Update(g.input); err != nil {
|
if err := g.board.Update(g.input); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -23,28 +23,14 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/examples/2048/2048"
|
"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() {
|
func main() {
|
||||||
var err error
|
game, err := twenty48.NewGame()
|
||||||
game, err = twenty48.NewGame()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
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)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user