From 545b68d1d743ee4f0352a253cb0c92f7eb4405f2 Mon Sep 17 00:00:00 2001 From: Fraser Graham Date: Wed, 6 Nov 2013 20:32:56 -0800 Subject: [PATCH] projectiles should have their own ID --- player.go | 2 +- projectile.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/player.go b/player.go index 08b8d3e..1780a5c 100644 --- a/player.go +++ b/player.go @@ -215,7 +215,7 @@ func (p *player) fire(projectiles map[*Projectile]bool, turn int) *Projectile { p.Robot.LastFired = turn return &Projectile{ - Id: p.Robot.Id, + Id: idg.Hash(), Position: p.Robot.Position, MoveTo: *p.Robot.FireAt, Damage: 10, diff --git a/projectile.go b/projectile.go index 3515525..9df160a 100644 --- a/projectile.go +++ b/projectile.go @@ -8,7 +8,7 @@ type Projectile struct { Id string `json:"id"` Position v.Point2d `json:"position"` MoveTo v.Point2d `json:"-"` - Radius int `json:"radius"` + Radius int `json:"-"` Speed float32 `json:"-"` Damage int `json:"-"` Owner *player `json:"-"` @@ -22,7 +22,7 @@ func (p *Projectile) Tick(g *game) { hit_player := false for player := range g.players { - if player.Robot.Id == p.Id { + if player == p.Owner { continue } dist := v.Distance(player.Robot.Position, p.Position)