mirror of
https://codeberg.org/scip/golsky.git
synced 2025-12-16 12:10:58 +01:00
further clear screen debugging
This commit is contained in:
14
TODO.md
14
TODO.md
@@ -1,5 +1,11 @@
|
||||
- add all other options like size etc
|
||||
- clear screen disabled leads to zoom artifacts when zooming out and
|
||||
canvas is smaller than screen workaround: using screen copy in
|
||||
game.Screen. Play copies screen to it and Menu draws it to screen
|
||||
before drawing the menus
|
||||
|
||||
- Clear screen problem:
|
||||
- it works when hitting the K key, immediately
|
||||
- its being turned off correctly when entering menu and on when leaving it
|
||||
- but regardless of the setting, after turning it off, the engine
|
||||
seems to run a couple of ticks with the old setting before switching
|
||||
scenes
|
||||
- looks like a race condition
|
||||
- obviously with K there are more loops before actually switching
|
||||
scenes, which doesn't happen with ESC
|
||||
|
||||
5
game.go
5
game.go
@@ -31,6 +31,7 @@ func NewGame(config *Config, startscene SceneName) *Game {
|
||||
ebiten.SetWindowSize(game.ScreenWidth, game.ScreenHeight)
|
||||
ebiten.SetWindowTitle("golsky - conway's game of life")
|
||||
ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled)
|
||||
ebiten.SetScreenClearedEveryFrame(true)
|
||||
|
||||
game.Screen = ebiten.NewImage(game.ScreenWidth, game.ScreenHeight)
|
||||
return game
|
||||
@@ -50,6 +51,7 @@ func (game *Game) Update() error {
|
||||
scene := game.GetCurrentScene()
|
||||
scene.Update()
|
||||
|
||||
// FIXME: should work, but doesn't
|
||||
//ebiten.SetScreenClearedEveryFrame(scene.Clearscreen())
|
||||
|
||||
next := scene.GetNext()
|
||||
@@ -62,11 +64,12 @@ func (game *Game) Update() error {
|
||||
game.CurrentScene = next
|
||||
}
|
||||
|
||||
//fmt.Printf("Clear Screen: %t\n", ebiten.IsScreenClearedEveryFrame())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (game *Game) Draw(screen *ebiten.Image) {
|
||||
scene := game.GetCurrentScene()
|
||||
ebiten.SetScreenClearedEveryFrame(scene.Clearscreen())
|
||||
scene.Draw(screen)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (scene *SceneMenu) Update() error {
|
||||
scene.Ui.Update()
|
||||
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyEscape) || inpututil.IsKeyJustPressed(ebiten.KeyQ) {
|
||||
scene.SetNext(Play)
|
||||
scene.Leave()
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -62,15 +62,20 @@ func (scene *SceneMenu) Update() error {
|
||||
}
|
||||
|
||||
func (scene *SceneMenu) Draw(screen *ebiten.Image) {
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Reset()
|
||||
op.GeoM.Translate(0, 0)
|
||||
//op := &ebiten.DrawImageOptions{}
|
||||
// op.GeoM.Reset()
|
||||
// op.GeoM.Translate(0, 0)
|
||||
|
||||
screen.DrawImage(scene.Game.Screen, op)
|
||||
// screen.DrawImage(scene.Game.Screen, op)
|
||||
|
||||
scene.Ui.Draw(screen)
|
||||
}
|
||||
|
||||
func (scene *SceneMenu) Leave() {
|
||||
ebiten.SetScreenClearedEveryFrame(true)
|
||||
scene.SetNext(Play)
|
||||
}
|
||||
|
||||
func (scene *SceneMenu) Init() {
|
||||
rowContainer := NewRowContainer("Main Menu")
|
||||
|
||||
@@ -78,20 +83,20 @@ func (scene *SceneMenu) Init() {
|
||||
func(args *widget.ButtonClickedEventArgs) {
|
||||
scene.Config.Empty = true
|
||||
scene.Config.Restart = true
|
||||
scene.SetNext(Play)
|
||||
scene.Leave()
|
||||
})
|
||||
|
||||
random := NewMenuButton("Start with random patterns",
|
||||
func(args *widget.ButtonClickedEventArgs) {
|
||||
scene.Config.Restart = true
|
||||
scene.SetNext(Play)
|
||||
scene.Leave()
|
||||
})
|
||||
|
||||
copy := NewMenuButton("Save Copy as RLE",
|
||||
func(args *widget.ButtonClickedEventArgs) {
|
||||
scene.Config.Markmode = true
|
||||
scene.Config.Paused = true
|
||||
scene.SetNext(Play)
|
||||
scene.Leave()
|
||||
})
|
||||
|
||||
options := NewMenuButton("Options",
|
||||
@@ -105,7 +110,7 @@ func (scene *SceneMenu) Init() {
|
||||
|
||||
cancel := NewMenuButton("Close Window",
|
||||
func(args *widget.ButtonClickedEventArgs) {
|
||||
scene.SetNext(Play)
|
||||
scene.Leave()
|
||||
})
|
||||
|
||||
quit := NewMenuButton("Exit Golsky",
|
||||
|
||||
@@ -24,6 +24,8 @@ type ScenePlay struct {
|
||||
Next SceneName
|
||||
Whoami SceneName
|
||||
|
||||
Clear bool
|
||||
|
||||
Grids []*Grid // 2 grids: one current, one next
|
||||
History *Grid // holds state of past dead cells for evolution traces
|
||||
Index int // points to current grid
|
||||
@@ -156,16 +158,25 @@ 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)
|
||||
}
|
||||
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyC) {
|
||||
fmt.Println("mark mode on")
|
||||
scene.Config.Markmode = true
|
||||
scene.Config.Paused = true
|
||||
}
|
||||
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyEscape) {
|
||||
scene.SetNext(Menu)
|
||||
}
|
||||
|
||||
if scene.Config.Markmode {
|
||||
return
|
||||
}
|
||||
@@ -483,9 +494,9 @@ func (scene *ScenePlay) DrawDebug(screen *ebiten.Image) {
|
||||
}
|
||||
|
||||
debug := fmt.Sprintf(
|
||||
"FPS: %0.2f, TPG: %d, Mem: %0.2fMB, Gen: %d, Scale: %.02f, Z: %d %s",
|
||||
"FPS: %0.2f, TPG: %d, Mem: %0.2fMB, Gen: %d, Scale: %.02f, Z: %d, Clear: %t %s",
|
||||
ebiten.ActualTPS(), scene.TPG, GetMem(), scene.Generations,
|
||||
scene.Game.Scale, scene.Camera.ZoomFactor, paused)
|
||||
scene.Game.Scale, scene.Camera.ZoomFactor, ebiten.IsScreenClearedEveryFrame(), paused)
|
||||
|
||||
FontRenderer.Renderer.SetSizePx(10 + int(scene.Game.Scale*10))
|
||||
FontRenderer.Renderer.SetTarget(screen)
|
||||
|
||||
Reference in New Issue
Block a user