From 829ba83f4191408a904113c1da2fe67d148051a4 Mon Sep 17 00:00:00 2001 From: Fraser Graham Date: Wed, 6 Nov 2013 23:26:29 -0800 Subject: [PATCH] probes!!!! (not anal) --- player.go | 14 ++++++++++++++ robot.go | 2 ++ 2 files changed, 16 insertions(+) diff --git a/player.go b/player.go index 60ec46e..5e152cd 100644 --- a/player.go +++ b/player.go @@ -63,6 +63,12 @@ func (p *player) recv() { } else { 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 } } + + 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) { diff --git a/robot.go b/robot.go index e0e9567..bd932b3 100644 --- a/robot.go +++ b/robot.go @@ -20,6 +20,7 @@ type Robot struct { LastFired int `json:"-"` Collision bool `json:"collision"` Hit bool `json:"hit"` + Probe *v.Point2d `json:"probe"` } // This is the subset of data we send to players about robots @@ -158,6 +159,7 @@ func (s StatsRequest) Valid() bool { type Instruction struct { MoveTo *v.Point2d `json:"move_to,omitempty"` FireAt *v.Point2d `json:"fire_at,omitempty"` + Probe *v.Point2d `json:"probe,omitempty"` TargetSpeed *float32 `json:"target_speed,omitempty"` Repair *bool `json:"repair,omitempty"` Stats Stats `json:"stats"`