mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 10:42:42 +01:00
parent
a70d6a314e
commit
01a1334639
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user