mirror of
https://codeberg.org/scip/golsky.git
synced 2025-12-16 20:20:57 +01:00
more zoom/center fixes. RLEs now load centered and visible.
This commit is contained in:
11
TODO.md
11
TODO.md
@@ -2,9 +2,16 @@
|
|||||||
|
|
||||||
- changing options mid-game has no effect in most cases, even after a restart
|
- changing options mid-game has no effect in most cases, even after a restart
|
||||||
|
|
||||||
- RLE file loading works, but if world is larger than screen, center is invisible.
|
|
||||||
|
|
||||||
- Statefile loading does not work correclty anymore. With larger grids
|
- Statefile loading does not work correclty anymore. With larger grids
|
||||||
everything is empty. With square grids part of the grid is cut
|
everything is empty. With square grids part of the grid is cut
|
||||||
off. Smaller grids load though
|
off. Smaller grids load though
|
||||||
|
|
||||||
|
- Also when loading a state file, centering doesn't work anymore, I
|
||||||
|
think the geom calculation is overthrown by the parser func. So, put
|
||||||
|
this calc into its own func and always call. Or - as stated below -
|
||||||
|
put it onto camera.go and call from Init().
|
||||||
|
|
||||||
|
- Zoom 0 on reset only works when world<screen. otherwise zoom would
|
||||||
|
be negative So, on Init() memoize centered camera position or add a
|
||||||
|
Center() function to camera.go. Then on reset calculate the zoom
|
||||||
|
level so that the world fits into the screen.
|
||||||
|
|||||||
10
config.go
10
config.go
@@ -9,7 +9,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alecthomas/repr"
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"github.com/tlinden/golsky/rle"
|
"github.com/tlinden/golsky/rle"
|
||||||
)
|
)
|
||||||
@@ -80,14 +79,15 @@ func (config *Config) ParseGeom(geom string) error {
|
|||||||
// size is smaller than the screen in a centered position, but
|
// size is smaller than the screen in a centered position, but
|
||||||
// it's zero if it's equal or larger than the screen.
|
// it's zero if it's equal or larger than the screen.
|
||||||
config.InitialCamPos = make([]float64, 2)
|
config.InitialCamPos = make([]float64, 2)
|
||||||
if config.Width*config.Cellsize < config.ScreenWidth {
|
|
||||||
config.InitialCamPos[0] = float64(((config.ScreenWidth - (config.Width * config.Cellsize)) / 2) * -1)
|
config.InitialCamPos[0] = float64(((config.ScreenWidth - (config.Width * config.Cellsize)) / 2) * -1)
|
||||||
repr.Println("x", config.InitialCamPos[0])
|
if config.Width*config.Cellsize >= config.ScreenWidth {
|
||||||
|
// must be positive if world wider than screen
|
||||||
|
config.InitialCamPos[0] = math.Abs(config.InitialCamPos[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Height*config.Cellsize > config.ScreenHeight {
|
if config.Height*config.Cellsize > config.ScreenHeight {
|
||||||
config.InitialCamPos[1] = math.Abs(float64(((config.ScreenHeight - (config.Height * config.Cellsize)) / 2)))
|
config.InitialCamPos[1] = math.Abs(float64(((config.ScreenHeight - (config.Height * config.Cellsize)) / 2)))
|
||||||
repr.Println("y", config.InitialCamPos[1])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type Images struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DEBUG_FORMAT = "FPS: %0.2f, TPG: %d, M: %0.2fMB, Generations: %d\nScale: %.02fZoom: %d, Cam: %.02f,%.02f Cursor: %d,%d %s"
|
DEBUG_FORMAT = "FPS: %0.2f, TPG: %d, M: %0.2fMB, Generations: %d\nScale: %.02f, Zoom: %d, Cam: %.02f,%.02f Cursor: %d,%d %s"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScenePlay struct {
|
type ScenePlay struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user