players can now set target speed in bot code
This commit is contained in:
parent
cd9bb45ddc
commit
e562e2fefb
15
player.go
15
player.go
@ -46,12 +46,9 @@ func (p *player) recv() {
|
||||
p.Robot.FireAt = msg.FireAt
|
||||
}
|
||||
|
||||
p.Robot.TargetSpeed = p.Robot.Stats.Speed
|
||||
|
||||
if msg.Stats.Speed > 0 {
|
||||
p.Robot.Stats = msg.Stats
|
||||
p.Robot.Health = p.Robot.Stats.Hp
|
||||
p.Robot.Speed = 0
|
||||
if msg.TargetSpeed != nil {
|
||||
p.Robot.TargetSpeed = float32(*msg.TargetSpeed)
|
||||
} else {
|
||||
p.Robot.TargetSpeed = p.Robot.Stats.Speed
|
||||
}
|
||||
}
|
||||
@ -102,7 +99,11 @@ func (p *player) Tick(g *game) {
|
||||
// Adjust Speed
|
||||
if p.Robot.Speed < p.Robot.TargetSpeed {
|
||||
p.Robot.Speed += (p.Robot.Stats.Acceleration * delta)
|
||||
} else if (p.Robot.Speed - p.Robot.TargetSpeed) > v.Epsilon {
|
||||
if p.Robot.Speed > p.Robot.TargetSpeed {
|
||||
p.Robot.Speed = p.Robot.TargetSpeed
|
||||
}
|
||||
|
||||
} else if float32(math.Abs(float64(p.Robot.Speed-p.Robot.TargetSpeed))) > v.Epsilon {
|
||||
p.Robot.Speed -= (p.Robot.Stats.Acceleration * delta)
|
||||
} else {
|
||||
p.Robot.Speed = p.Robot.TargetSpeed
|
||||
|
Loading…
Reference in New Issue
Block a user