toggle directly in scene's Draw, but fails too

This commit is contained in:
2024-06-01 00:02:26 +02:00
parent 8e821cbdc5
commit 507ac18853
4 changed files with 7 additions and 20 deletions

View File

@@ -1,6 +1,8 @@
package main
import (
"fmt"
"github.com/hajimehoshi/ebiten/v2"
)
@@ -51,9 +53,6 @@ func (game *Game) Update() error {
scene := game.GetCurrentScene()
scene.Update()
// FIXME: should work, but doesn't
//ebiten.SetScreenClearedEveryFrame(scene.Clearscreen())
next := scene.GetNext()
if next != game.CurrentScene {
@@ -64,7 +63,7 @@ func (game *Game) Update() error {
game.CurrentScene = next
}
//fmt.Printf("Clear Screen: %t\n", ebiten.IsScreenClearedEveryFrame())
fmt.Printf("Clear Screen: %t\n", ebiten.IsScreenClearedEveryFrame())
return nil
}

View File

@@ -62,17 +62,11 @@ func (scene *SceneMenu) Update() error {
}
func (scene *SceneMenu) Draw(screen *ebiten.Image) {
//op := &ebiten.DrawImageOptions{}
// op.GeoM.Reset()
// op.GeoM.Translate(0, 0)
// screen.DrawImage(scene.Game.Screen, op)
ebiten.SetScreenClearedEveryFrame(false)
scene.Ui.Draw(screen)
}
func (scene *SceneMenu) Leave() {
ebiten.SetScreenClearedEveryFrame(true)
scene.SetNext(Play)
}

View File

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

View File

@@ -158,16 +158,7 @@ func (scene *ScenePlay) CheckInput() {
os.Exit(0)
}
// FIXME: works from here
if inpututil.IsKeyJustPressed(ebiten.KeyK) {
scene.Clear = !scene.Clear
fmt.Printf("Clear: %t\n", scene.Clear)
ebiten.SetScreenClearedEveryFrame(scene.Clear)
}
// FIXME: and this does have no effect. WHY?!?!?
if inpututil.IsKeyJustPressed(ebiten.KeyEscape) {
ebiten.SetScreenClearedEveryFrame(false)
scene.SetNext(Menu)
}
@@ -412,6 +403,8 @@ 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