projectiles should have their own ID
This commit is contained in:
parent
bad900997f
commit
545b68d1d7
@ -215,7 +215,7 @@ func (p *player) fire(projectiles map[*Projectile]bool, turn int) *Projectile {
|
|||||||
p.Robot.LastFired = turn
|
p.Robot.LastFired = turn
|
||||||
|
|
||||||
return &Projectile{
|
return &Projectile{
|
||||||
Id: p.Robot.Id,
|
Id: idg.Hash(),
|
||||||
Position: p.Robot.Position,
|
Position: p.Robot.Position,
|
||||||
MoveTo: *p.Robot.FireAt,
|
MoveTo: *p.Robot.FireAt,
|
||||||
Damage: 10,
|
Damage: 10,
|
||||||
|
@ -8,7 +8,7 @@ type Projectile struct {
|
|||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Position v.Point2d `json:"position"`
|
Position v.Point2d `json:"position"`
|
||||||
MoveTo v.Point2d `json:"-"`
|
MoveTo v.Point2d `json:"-"`
|
||||||
Radius int `json:"radius"`
|
Radius int `json:"-"`
|
||||||
Speed float32 `json:"-"`
|
Speed float32 `json:"-"`
|
||||||
Damage int `json:"-"`
|
Damage int `json:"-"`
|
||||||
Owner *player `json:"-"`
|
Owner *player `json:"-"`
|
||||||
@ -22,7 +22,7 @@ func (p *Projectile) Tick(g *game) {
|
|||||||
|
|
||||||
hit_player := false
|
hit_player := false
|
||||||
for player := range g.players {
|
for player := range g.players {
|
||||||
if player.Robot.Id == p.Id {
|
if player == p.Owner {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dist := v.Distance(player.Robot.Position, p.Position)
|
dist := v.Distance(player.Robot.Position, p.Position)
|
||||||
|
Loading…
Reference in New Issue
Block a user