another try, but fails as well + added todos

This commit is contained in:
2024-06-01 00:33:40 +02:00
parent 507ac18853
commit 9f1bdfd2af
5 changed files with 20 additions and 14 deletions

View File

@@ -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

24
game.go
View File

@@ -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)
}
}

View File

@@ -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()
})

View File

@@ -60,7 +60,6 @@ func (scene *SceneOptions) Update() error {
}
func (scene *SceneOptions) Draw(screen *ebiten.Image) {
ebiten.SetScreenClearedEveryFrame(false)
scene.Ui.Draw(screen)
}

View File

@@ -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