mirror of
https://codeberg.org/scip/golsky.git
synced 2025-12-16 20:20:57 +01:00
fixed exit function with q, added evolution trace to options fixed inverse
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ bak
|
|||||||
dump*
|
dump*
|
||||||
rect*
|
rect*
|
||||||
*profile
|
*profile
|
||||||
|
*prof
|
||||||
|
|||||||
@@ -267,3 +267,7 @@ func (config *Config) ToggleGridlines() {
|
|||||||
config.ShowGrid = !config.ShowGrid
|
config.ShowGrid = !config.ShowGrid
|
||||||
config.RestartCache = true
|
config.RestartCache = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (config *Config) ToggleEvolution() {
|
||||||
|
config.ShowEvolution = !config.ShowEvolution
|
||||||
|
}
|
||||||
|
|||||||
5
game.go
5
game.go
@@ -49,7 +49,10 @@ func (game *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
|||||||
|
|
||||||
func (game *Game) Update() error {
|
func (game *Game) Update() error {
|
||||||
scene := game.GetCurrentScene()
|
scene := game.GetCurrentScene()
|
||||||
scene.Update()
|
|
||||||
|
if quit := scene.Update(); quit != nil {
|
||||||
|
return quit
|
||||||
|
}
|
||||||
|
|
||||||
next := scene.GetNext()
|
next := scene.GetNext()
|
||||||
if next != game.CurrentScene {
|
if next != game.CurrentScene {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ func (scene *SceneOptions) Init() {
|
|||||||
|
|
||||||
invert := NewCheckbox("Invert",
|
invert := NewCheckbox("Invert",
|
||||||
func(args *widget.CheckboxChangedEventArgs) {
|
func(args *widget.CheckboxChangedEventArgs) {
|
||||||
scene.Config.Invert = true
|
scene.Config.ToggleInvert()
|
||||||
})
|
})
|
||||||
scene.SetInitialValue(invert, scene.Config.Invert)
|
scene.SetInitialValue(invert, scene.Config.Invert)
|
||||||
|
|
||||||
@@ -105,6 +105,12 @@ func (scene *SceneOptions) Init() {
|
|||||||
})
|
})
|
||||||
scene.SetInitialValue(gridlines, scene.Config.ShowGrid)
|
scene.SetInitialValue(gridlines, scene.Config.ShowGrid)
|
||||||
|
|
||||||
|
evolution := NewCheckbox("Show evolution traces",
|
||||||
|
func(args *widget.CheckboxChangedEventArgs) {
|
||||||
|
scene.Config.ToggleEvolution()
|
||||||
|
})
|
||||||
|
scene.SetInitialValue(evolution, scene.Config.ShowEvolution)
|
||||||
|
|
||||||
separator := NewSeparator(3)
|
separator := NewSeparator(3)
|
||||||
|
|
||||||
cancel := NewMenuButton("Close",
|
cancel := NewMenuButton("Close",
|
||||||
@@ -116,6 +122,7 @@ func (scene *SceneOptions) Init() {
|
|||||||
rowContainer.AddChild(debugging)
|
rowContainer.AddChild(debugging)
|
||||||
rowContainer.AddChild(invert)
|
rowContainer.AddChild(invert)
|
||||||
rowContainer.AddChild(gridlines)
|
rowContainer.AddChild(gridlines)
|
||||||
|
rowContainer.AddChild(evolution)
|
||||||
rowContainer.AddChild(separator)
|
rowContainer.AddChild(separator)
|
||||||
rowContainer.AddChild(cancel)
|
rowContainer.AddChild(cancel)
|
||||||
|
|
||||||
|
|||||||
22
play.go
22
play.go
@@ -5,7 +5,6 @@ import (
|
|||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
||||||
@@ -162,11 +161,15 @@ func (scene *ScenePlay) Reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check user input
|
// check user input
|
||||||
func (scene *ScenePlay) CheckInput() {
|
func (scene *ScenePlay) CheckExit() error {
|
||||||
if inpututil.IsKeyJustPressed(ebiten.KeyQ) {
|
if inpututil.IsKeyJustPressed(ebiten.KeyQ) {
|
||||||
os.Exit(0)
|
return ebiten.Termination
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (scene *ScenePlay) CheckInput() {
|
||||||
if inpututil.IsKeyJustPressed(ebiten.KeyEscape) {
|
if inpututil.IsKeyJustPressed(ebiten.KeyEscape) {
|
||||||
scene.SetNext(Menu)
|
scene.SetNext(Menu)
|
||||||
}
|
}
|
||||||
@@ -176,7 +179,6 @@ func (scene *ScenePlay) CheckInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if inpututil.IsKeyJustPressed(ebiten.KeyC) {
|
if inpututil.IsKeyJustPressed(ebiten.KeyC) {
|
||||||
fmt.Println("mark mode on")
|
|
||||||
scene.Config.Markmode = true
|
scene.Config.Markmode = true
|
||||||
scene.Config.Paused = true
|
scene.Config.Paused = true
|
||||||
}
|
}
|
||||||
@@ -297,6 +299,10 @@ func (scene *ScenePlay) CheckMarkInput() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if inpututil.IsKeyJustPressed(ebiten.KeyEscape) {
|
||||||
|
scene.Config.Markmode = false
|
||||||
|
}
|
||||||
|
|
||||||
if ebiten.IsMouseButtonPressed(ebiten.MouseButton0) {
|
if ebiten.IsMouseButtonPressed(ebiten.MouseButton0) {
|
||||||
if !scene.MarkTaken {
|
if !scene.MarkTaken {
|
||||||
scene.Mark = scene.GetWorldCursorPos()
|
scene.Mark = scene.GetWorldCursorPos()
|
||||||
@@ -391,6 +397,10 @@ func (scene *ScenePlay) Update() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if quit := scene.CheckExit(); quit != nil {
|
||||||
|
return quit
|
||||||
|
}
|
||||||
|
|
||||||
scene.CheckInput()
|
scene.CheckInput()
|
||||||
scene.CheckDraggingInput()
|
scene.CheckDraggingInput()
|
||||||
scene.CheckMarkInput()
|
scene.CheckMarkInput()
|
||||||
@@ -498,6 +508,10 @@ func (scene *ScenePlay) DrawDebug(screen *ebiten.Image) {
|
|||||||
paused = "-- paused --"
|
paused = "-- paused --"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if scene.Config.Markmode {
|
||||||
|
paused = "-- mark --"
|
||||||
|
}
|
||||||
|
|
||||||
x, y := ebiten.CursorPosition()
|
x, y := ebiten.CursorPosition()
|
||||||
debug := fmt.Sprintf(
|
debug := fmt.Sprintf(
|
||||||
DEBUG_FORMAT,
|
DEBUG_FORMAT,
|
||||||
|
|||||||
Reference in New Issue
Block a user