probes!!!! (not anal)

This commit is contained in:
Fraser Graham 2013-11-06 23:26:29 -08:00
parent d2ae3c11d8
commit 829ba83f41
2 changed files with 16 additions and 0 deletions

View File

@ -63,6 +63,12 @@ func (p *player) recv() {
} else { } else {
p.Robot.TargetSpeed = p.Robot.Stats.Speed p.Robot.TargetSpeed = p.Robot.Stats.Speed
} }
if msg.Probe != nil {
p.Robot.Probe = msg.Probe
} else {
p.Robot.Probe = nil
}
} }
} }
@ -197,6 +203,14 @@ func (p *player) Tick(g *game) {
g.projectiles[proj] = true g.projectiles[proj] = true
} }
} }
if p.Robot.Probe != nil {
probe_vector := p.Robot.Probe.Sub(p.Robot.Position)
coll, pos, _ := p.checkCollisions(g, probe_vector)
if coll {
p.Robot.Probe = &pos
}
}
} }
func (p *player) scan(g *game) { func (p *player) scan(g *game) {

View File

@ -20,6 +20,7 @@ type Robot struct {
LastFired int `json:"-"` LastFired int `json:"-"`
Collision bool `json:"collision"` Collision bool `json:"collision"`
Hit bool `json:"hit"` Hit bool `json:"hit"`
Probe *v.Point2d `json:"probe"`
} }
// This is the subset of data we send to players about robots // This is the subset of data we send to players about robots
@ -158,6 +159,7 @@ func (s StatsRequest) Valid() bool {
type Instruction struct { type Instruction struct {
MoveTo *v.Point2d `json:"move_to,omitempty"` MoveTo *v.Point2d `json:"move_to,omitempty"`
FireAt *v.Point2d `json:"fire_at,omitempty"` FireAt *v.Point2d `json:"fire_at,omitempty"`
Probe *v.Point2d `json:"probe,omitempty"`
TargetSpeed *float32 `json:"target_speed,omitempty"` TargetSpeed *float32 `json:"target_speed,omitempty"`
Repair *bool `json:"repair,omitempty"` Repair *bool `json:"repair,omitempty"`
Stats Stats `json:"stats"` Stats Stats `json:"stats"`