alert the robot if it's been hit
This commit is contained in:
parent
082b737805
commit
d2ae3c11d8
@ -108,6 +108,7 @@ func (p *player) checkCollisions(g *game, move_vector v.Vector2d) (bool, v.Point
|
|||||||
|
|
||||||
func (p *player) Tick(g *game) {
|
func (p *player) Tick(g *game) {
|
||||||
p.Robot.Collision = false
|
p.Robot.Collision = false
|
||||||
|
p.Robot.Hit = false
|
||||||
p.scan(g)
|
p.scan(g)
|
||||||
|
|
||||||
// Adjust Speed
|
// Adjust Speed
|
||||||
|
@ -37,6 +37,7 @@ func (p *Projectile) Tick(g *game) {
|
|||||||
log.Printf("Direct Hit %v, Dmg:%v", player.Robot.Id, p.Damage)
|
log.Printf("Direct Hit %v, Dmg:%v", player.Robot.Id, p.Damage)
|
||||||
|
|
||||||
player.Robot.Health -= p.Damage
|
player.Robot.Health -= p.Damage
|
||||||
|
player.Robot.Hit = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,12 +75,9 @@ func (p *Projectile) Tick(g *game) {
|
|||||||
for player := range g.players {
|
for player := range g.players {
|
||||||
dist := v.Distance(player.Robot.Position, p.Position)
|
dist := v.Distance(player.Robot.Position, p.Position)
|
||||||
if dist < float32(p.Radius) {
|
if dist < float32(p.Radius) {
|
||||||
|
|
||||||
// TODO map damage Max to Min based on distance from explosion
|
|
||||||
if player.Robot.Health > 0 {
|
if player.Robot.Health > 0 {
|
||||||
player.Robot.Health -= p.Damage
|
player.Robot.Health -= p.Damage
|
||||||
if player.Robot.Health <= 0 {
|
player.Robot.Hit = true
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
robot.go
1
robot.go
@ -19,6 +19,7 @@ type Robot struct {
|
|||||||
Scanners []Scanner `json:"scanners"`
|
Scanners []Scanner `json:"scanners"`
|
||||||
LastFired int `json:"-"`
|
LastFired int `json:"-"`
|
||||||
Collision bool `json:"collision"`
|
Collision bool `json:"collision"`
|
||||||
|
Hit bool `json:"hit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the subset of data we send to players about robots
|
// This is the subset of data we send to players about robots
|
||||||
|
Loading…
Reference in New Issue
Block a user