point limit parametrized

This commit is contained in:
sm
2013-11-29 01:10:49 -07:00
parent 33aea792ed
commit 3bb710dd9c
5 changed files with 39 additions and 32 deletions
+16 -13
View File
@@ -17,18 +17,27 @@ type Config struct {
Width int `json:"width"`
Height int `json:"height"`
Obstacles int `json:"obstacles"`
MaxPoints int `json:"max_points"`
}
const (
TICK = 60
TIMESCALE = 1.0
WIDTH = 800
HEIGHT = 550
OBSTACLES = 5
TICK = 60
TIMESCALE = 1.0
WIDTH = 800
HEIGHT = 550
OBSTACLES = 5
MAX_POINTS = 500 // allowing for 50 pts in every category
)
func loadConfig(filename string) (Config, error) {
c := Config{}
c := Config{
Tick: TICK,
Timescale: TIMESCALE,
Width: WIDTH,
Height: HEIGHT,
Obstacles: OBSTACLES,
MaxPoints: MAX_POINTS,
}
u, err := user.Current()
if err != nil {
return c, err
@@ -38,13 +47,6 @@ func loadConfig(filename string) (Config, error) {
}
if _, err := os.Stat(filename); os.IsNotExist(err) {
log.Printf("%+v not found, using defaults", filename)
return Config{
Tick: TICK,
Timescale: TIMESCALE,
Width: WIDTH,
Height: HEIGHT,
Obstacles: OBSTACLES,
}, nil
} else {
log.Printf("found config file: %s", filename)
f, err := ioutil.ReadFile(filename)
@@ -56,5 +58,6 @@ func loadConfig(filename string) (Config, error) {
return c, errors.New(fmt.Sprintf("config parse error: %s", err))
}
}
log.Printf("final config: %+v", c)
return c, nil
}