From 3d0eb16f91668b43e22c8aec103e4c3c54e1530d Mon Sep 17 00:00:00 2001 From: Fraser Graham Date: Thu, 7 Nov 2013 21:00:10 -0800 Subject: [PATCH] game params --- game.go | 6 +++++- main.go | 1 + player.go | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/game.go b/game.go index 893a2a6..f6da52d 100644 --- a/game.go +++ b/game.go @@ -93,6 +93,8 @@ type game struct { sregister chan *Spectator sunregister chan *Spectator kill chan bool + repair_hp int + repair_rate float32 } func NewGame(id string, width, height float32) *game { @@ -102,7 +104,7 @@ func NewGame(id string, width, height float32) *game { unregister: make(chan *player, maxPlayer), projectiles: make(map[*Projectile]bool), splosions: make(map[*Splosion]bool), - obstacles: GenerateObstacles(5, width, height), + obstacles: GenerateObstacles(*obstacle_count, width, height), players: make(map[*player]bool), turn: 0, width: width, @@ -111,6 +113,8 @@ func NewGame(id string, width, height float32) *game { sregister: make(chan *Spectator), sunregister: make(chan *Spectator), kill: make(chan bool, maxPlayer), + repair_hp: 5, + repair_rate: 3.0, } return g } diff --git a/main.go b/main.go index 21f81ce..d7bebd3 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ var timescale = flag.Float64("timescale", 1, "time scale factor") var verbose = flag.Bool("verbose", false, "") var width = flag.Float64("width", 800, "width of field") var height = flag.Float64("height", 550, "height of field") +var obstacle_count = flag.Int("obstacles", 5, "how many obstacles") var profile = flag.String("pprof", "", "if specified will run with pprof") var netprofile = flag.Bool("netprof", false, "if specified will run with net/http/pprof") var debug = flag.Bool("debug", false, "automatically create games if they don't exist") diff --git a/player.go b/player.go index f896486..1a270d9 100644 --- a/player.go +++ b/player.go @@ -194,8 +194,8 @@ func (p *player) Tick(g *game) { if math.Abs(float64(p.Robot.Speed)) < v.Epsilon && p.Robot.RepairCounter > 0 { p.Robot.RepairCounter -= delta if p.Robot.RepairCounter < 0 { - p.Robot.Health += 5 - p.Robot.RepairCounter = 3.0 + p.Robot.Health += g.repair_hp + p.Robot.RepairCounter = g.repair_rate } }