game params

This commit is contained in:
Fraser Graham 2013-11-07 21:00:10 -08:00
parent b01654ec76
commit 3d0eb16f91
3 changed files with 8 additions and 3 deletions

View File

@ -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
}

View File

@ -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")

View File

@ -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
}
}