mirror of
https://codeberg.org/scip/golsky.git
synced 2025-12-16 20:20:57 +01:00
fixed centering of squares, but not rectangles yet.
This commit is contained in:
26
config.go
26
config.go
@@ -3,11 +3,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@@ -52,15 +54,6 @@ const (
|
|||||||
|
|
||||||
// parse given window geometry and adjust game settings according to it
|
// parse given window geometry and adjust game settings according to it
|
||||||
func (config *Config) ParseGeom(geom string) error {
|
func (config *Config) ParseGeom(geom string) error {
|
||||||
// if geom == "" {
|
|
||||||
// // config.ScreenWidth = config.Cellsize * config.Width
|
|
||||||
// // config.ScreenHeight = config.Cellsize * config.Height
|
|
||||||
// config.ScreenWidth = DEFAULT_WIDTH
|
|
||||||
// config.ScreenHeight = DEFAULT_HEIGHT
|
|
||||||
// config.Zoomfactor = 0
|
|
||||||
// return nil
|
|
||||||
// }
|
|
||||||
|
|
||||||
// force a geom
|
// force a geom
|
||||||
geometry := strings.Split(geom, "x")
|
geometry := strings.Split(geom, "x")
|
||||||
if len(geometry) != 2 {
|
if len(geometry) != 2 {
|
||||||
@@ -77,15 +70,6 @@ func (config *Config) ParseGeom(geom string) error {
|
|||||||
return errors.New("failed to parse height, expecting integer")
|
return errors.New("failed to parse height, expecting integer")
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// adjust dimensions, account for grid width+height so that cells
|
|
||||||
// fit into window
|
|
||||||
config.ScreenWidth = width - (width % config.Width)
|
|
||||||
config.ScreenHeight = height - (height % config.Height)
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
config.ScreenWidth = width
|
config.ScreenWidth = width
|
||||||
config.ScreenHeight = height
|
config.ScreenHeight = height
|
||||||
|
|
||||||
@@ -98,10 +82,12 @@ func (config *Config) ParseGeom(geom string) error {
|
|||||||
config.InitialCamPos = make([]float64, 2)
|
config.InitialCamPos = make([]float64, 2)
|
||||||
if config.Width*config.Cellsize < config.ScreenWidth {
|
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.Height*config.Cellsize < config.ScreenHeight {
|
if config.Height*config.Cellsize > config.ScreenHeight {
|
||||||
config.InitialCamPos[1] = float64(((config.ScreenHeight - (config.Height * config.Cellsize)) / 2) * -1)
|
config.InitialCamPos[1] = math.Abs(float64(((config.ScreenHeight - (config.Height * config.Cellsize)) / 2)))
|
||||||
|
repr.Println("y", config.InitialCamPos[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user