probe result

This commit is contained in:
Fraser Graham 2013-11-07 08:41:39 -08:00 committed by Fraser Graham
parent 829ba83f41
commit eabc1ebb41
2 changed files with 4 additions and 2 deletions

View File

@ -66,6 +66,7 @@ func (p *player) recv() {
if msg.Probe != nil { if msg.Probe != nil {
p.Robot.Probe = msg.Probe p.Robot.Probe = msg.Probe
p.Robot.ProbeResult = nil
} else { } else {
p.Robot.Probe = nil p.Robot.Probe = nil
} }
@ -204,11 +205,11 @@ func (p *player) Tick(g *game) {
} }
} }
if p.Robot.Probe != nil { if p.Robot.Probe != nil && p.Robot.ProbeResult == nil {
probe_vector := p.Robot.Probe.Sub(p.Robot.Position) probe_vector := p.Robot.Probe.Sub(p.Robot.Position)
coll, pos, _ := p.checkCollisions(g, probe_vector) coll, pos, _ := p.checkCollisions(g, probe_vector)
if coll { if coll {
p.Robot.Probe = &pos p.Robot.ProbeResult = &pos
} }
} }
} }

View File

@ -21,6 +21,7 @@ type Robot struct {
Collision bool `json:"collision"` Collision bool `json:"collision"`
Hit bool `json:"hit"` Hit bool `json:"hit"`
Probe *v.Point2d `json:"probe"` Probe *v.Point2d `json:"probe"`
ProbeResult *v.Point2d `json:"probe_result"`
} }
// This is the subset of data we send to players about robots // This is the subset of data we send to players about robots