make projectiles arrive at their destination regardless of tick time
This commit is contained in:
parent
f4e2e84676
commit
e02c5f89fb
16
game.go
16
game.go
@ -193,7 +193,14 @@ func (g *game) nudgeProjectiles() (rprojectiles []Projectile) {
|
||||
}
|
||||
}
|
||||
|
||||
if v.Distance(p.Position, p.MoveTo) < 5 || hit_player {
|
||||
// Are we going to intersect the destination zone in this tick?
|
||||
r_dest := v.Rect2d{
|
||||
A: v.Point2d{X: p.MoveTo.X - 3, Y: p.MoveTo.Y - 3},
|
||||
B: v.Point2d{X: p.MoveTo.X + 3, Y: p.MoveTo.Y + 3}}
|
||||
|
||||
travel := newPos.Sub(p.Position)
|
||||
arrived, _, _ := v.RectIntersection(r_dest, p.Position, travel)
|
||||
if arrived || hit_player {
|
||||
delete(g.projectiles, p)
|
||||
|
||||
// Spawn a splosion
|
||||
@ -219,10 +226,11 @@ func (g *game) nudgeProjectiles() (rprojectiles []Projectile) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p.Position.X = newPos.X
|
||||
p.Position.Y = newPos.Y
|
||||
rprojectiles = append(rprojectiles, *p)
|
||||
}
|
||||
p.Position.X = newPos.X
|
||||
p.Position.Y = newPos.Y
|
||||
rprojectiles = append(rprojectiles, *p)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user