func (p *Physics) VehicleBounding(v *state.Vehicle) { shouldStop := v.X < 0 if shouldStop { v.X = 2 } if v.Y < 0 { shouldStop = true v.Y = 2 } if v.Y > p.WorldHeight { shouldStop = true v.Y = p.WorldHeight - 2 } if v.X > p.WorldWidth { shouldStop = true v.X = p.WorldWidth - 2 } if shouldStop { v.Velocity = 0 } }
func (p *Physics) RespawnVehicle(v *state.Vehicle, g state.GameState) bool { if !v.IsAlive { if time.Now().After(v.TimeDestroyed.Add(p.VehicleRespawn)) { v.IsAlive = true loc := p.findSpace(v.Sized, g) v.Y = loc.Y v.X = loc.X v.Angle = 0 v.CurrentHealth = v.MaxHealth v.ActivePowerup = NO_POWERUP v.StoredPowerup = NO_POWERUP } } return false }
func (p *Physics) MoveVehicle(vehicle *state.Vehicle, duration time.Duration) { x, y := p.move2d(vehicle.X, vehicle.Y, vehicle.Angle, vehicle.Velocity, duration) vehicle.X = x vehicle.Y = y }