diff --git a/TODO.md b/TODO.md index 7a26f07..d7279c3 100644 --- a/TODO.md +++ b/TODO.md @@ -9,3 +9,8 @@ - looks like a race condition - obviously with K there are more loops before actually switching scenes, which doesn't happen with ESC + + +- if grid lines is disabled, they appear anyway in the first frame (then disappear) + +- changing options mid-game has no effect in most cases, even after a restart diff --git a/game.go b/game.go index a7f72e0..bf601cf 100644 --- a/game.go +++ b/game.go @@ -53,22 +53,26 @@ func (game *Game) Update() error { scene := game.GetCurrentScene() scene.Update() - next := scene.GetNext() - - if next != game.CurrentScene { - // make sure we stay on the selected scene - scene.ResetNext() - - // finally switch - game.CurrentScene = next - } - fmt.Printf("Clear Screen: %t\n", ebiten.IsScreenClearedEveryFrame()) return nil } func (game *Game) Draw(screen *ebiten.Image) { + var nextscene Scene scene := game.GetCurrentScene() + + next := scene.GetNext() + if next != game.CurrentScene { + scene.ResetNext() + game.CurrentScene = next + nextscene = game.GetCurrentScene() + ebiten.SetScreenClearedEveryFrame(nextscene.Clearscreen()) + } + scene.Draw(screen) + + if nextscene != nil { + nextscene.Draw(screen) + } } diff --git a/scene-menu.go b/scene-menu.go index 935c8b4..3beb8fa 100644 --- a/scene-menu.go +++ b/scene-menu.go @@ -62,7 +62,6 @@ func (scene *SceneMenu) Update() error { } func (scene *SceneMenu) Draw(screen *ebiten.Image) { - ebiten.SetScreenClearedEveryFrame(false) scene.Ui.Draw(screen) } @@ -82,6 +81,7 @@ func (scene *SceneMenu) Init() { random := NewMenuButton("Start with random patterns", func(args *widget.ButtonClickedEventArgs) { + scene.Config.Empty = false scene.Config.Restart = true scene.Leave() }) diff --git a/scene-options.go b/scene-options.go index 67c7e39..5ee1a8b 100644 --- a/scene-options.go +++ b/scene-options.go @@ -60,7 +60,6 @@ func (scene *SceneOptions) Update() error { } func (scene *SceneOptions) Draw(screen *ebiten.Image) { - ebiten.SetScreenClearedEveryFrame(false) scene.Ui.Draw(screen) } diff --git a/scene-play.go b/scene-play.go index 8266e5b..12c665b 100644 --- a/scene-play.go +++ b/scene-play.go @@ -403,8 +403,6 @@ func (scene *ScenePlay) ToggleCellOnCursorPos(alive int64) { // draw the new grid state func (scene *ScenePlay) Draw(screen *ebiten.Image) { - ebiten.SetScreenClearedEveryFrame(true) - // we fill the whole screen with a background color, the cells // themselfes will be 1px smaller as their nominal size, producing // a nice grey grid with grid lines