game params
This commit is contained in:
parent
b01654ec76
commit
3d0eb16f91
6
game.go
6
game.go
@ -93,6 +93,8 @@ type game struct {
|
|||||||
sregister chan *Spectator
|
sregister chan *Spectator
|
||||||
sunregister chan *Spectator
|
sunregister chan *Spectator
|
||||||
kill chan bool
|
kill chan bool
|
||||||
|
repair_hp int
|
||||||
|
repair_rate float32
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGame(id string, width, height float32) *game {
|
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),
|
unregister: make(chan *player, maxPlayer),
|
||||||
projectiles: make(map[*Projectile]bool),
|
projectiles: make(map[*Projectile]bool),
|
||||||
splosions: make(map[*Splosion]bool),
|
splosions: make(map[*Splosion]bool),
|
||||||
obstacles: GenerateObstacles(5, width, height),
|
obstacles: GenerateObstacles(*obstacle_count, width, height),
|
||||||
players: make(map[*player]bool),
|
players: make(map[*player]bool),
|
||||||
turn: 0,
|
turn: 0,
|
||||||
width: width,
|
width: width,
|
||||||
@ -111,6 +113,8 @@ func NewGame(id string, width, height float32) *game {
|
|||||||
sregister: make(chan *Spectator),
|
sregister: make(chan *Spectator),
|
||||||
sunregister: make(chan *Spectator),
|
sunregister: make(chan *Spectator),
|
||||||
kill: make(chan bool, maxPlayer),
|
kill: make(chan bool, maxPlayer),
|
||||||
|
repair_hp: 5,
|
||||||
|
repair_rate: 3.0,
|
||||||
}
|
}
|
||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
|
1
main.go
1
main.go
@ -18,6 +18,7 @@ var timescale = flag.Float64("timescale", 1, "time scale factor")
|
|||||||
var verbose = flag.Bool("verbose", false, "")
|
var verbose = flag.Bool("verbose", false, "")
|
||||||
var width = flag.Float64("width", 800, "width of field")
|
var width = flag.Float64("width", 800, "width of field")
|
||||||
var height = flag.Float64("height", 550, "height 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 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 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")
|
var debug = flag.Bool("debug", false, "automatically create games if they don't exist")
|
||||||
|
@ -194,8 +194,8 @@ func (p *player) Tick(g *game) {
|
|||||||
if math.Abs(float64(p.Robot.Speed)) < v.Epsilon && p.Robot.RepairCounter > 0 {
|
if math.Abs(float64(p.Robot.Speed)) < v.Epsilon && p.Robot.RepairCounter > 0 {
|
||||||
p.Robot.RepairCounter -= delta
|
p.Robot.RepairCounter -= delta
|
||||||
if p.Robot.RepairCounter < 0 {
|
if p.Robot.RepairCounter < 0 {
|
||||||
p.Robot.Health += 5
|
p.Robot.Health += g.repair_hp
|
||||||
p.Robot.RepairCounter = 3.0
|
p.Robot.RepairCounter = g.repair_rate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user