func (p *Physics) DamageBase(b *state.Bullet, base *state.Base) bool { base.CurrentHealth -= p.BulletDamage b.ShouldRemove = true if base.CurrentHealth <= 0 { base.CurrentHealth = 0 return true } return false }
func (p *Physics) DamageShieldGenerator(b *state.Bullet, s *state.ShieldGenerator) bool { s.CurrentHealth -= p.BulletDamage b.ShouldRemove = true if s.CurrentHealth <= 0 { s.Shield.IsEnabled = false s.CurrentHealth = 0 return true } return false }
func TestBox2dBullet(t *testing.T) { bullet := state.Bullet{ Point: state.Point{X: 10, Y: 20}, Sized: state.Sized{Width: 15, Height: 40}, Angle: 3} Convey("Proper Box Bullet", t, func() { So(bullet.AngleDegrees(), ShouldAlmostEqual, bullet.Angle, .001) x, y := bullet.Position() w, h := bullet.Size() So(x, ShouldAlmostEqual, bullet.X, .001) So(y, ShouldAlmostEqual, bullet.Y, .001) So(w, ShouldAlmostEqual, bullet.Height, .001) So(h, ShouldAlmostEqual, bullet.Width, .001) }) }
func (p *Physics) BoundBullet(b *state.Bullet) { if !p.inBounds(b.X, b.Y) { b.ShouldRemove = true } }
func (p *Physics) DamageVehicle(v *state.Vehicle, b *state.Bullet) bool { b.ShouldRemove = true return p.damageVehicle(v, p.BulletDamage) }
func (p *Physics) MoveBullet(bullet *state.Bullet, duration time.Duration) { x, y := p.move2d(bullet.X, bullet.Y, bullet.Angle, bullet.Velocity, duration) bullet.X = x bullet.Y = y }