vehicles: a kind's numbers are a VehicleSpec the game hands over (vehicles_spec), not constants

The seat height, the horse's walk, gallop, acceleration and turn (VE_HORSE_*), its stamina (a gallop
over 6 m/s spends 6 a second, a walk gives back 3, 5 needed to gallop) and hay (0.02 a metre,
VEHICLE_HAY_MIN), the boat's stroke, turn and wind (VE_ROW, VE_ROW_TURN, VE_WIND) and where a rider
gets off (the horse's 1.2 m flank, the boat's 1.25 m wade) move into VehicleSpec (spec.ludic), held
per kind in VehiclesState.ve_specs and kept across a reset. vehicles_spec(kind, spec) sets one,
vehicle_spec(kind) asks it; a kind with no spec cannot be called. VEHICLE_HORSE and VEHICLE_BOAT stay
the kinds. The tests hand Maroon Lake's numbers in, and a new one holds a spec's walk and seat_h.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 20:17:31 +03:00
parent a87f20c66e
commit 668a9ecf69
10 changed files with 137 additions and 34 deletions

View file

@ -1,9 +1,6 @@
# ride.ludic - the rider's stick steers what they are on: a horse walks, canters on stamina and
# stops at water, a slope or a trunk; a boat is rowed - a stroke and a turn handed to its hull,
# which the water floats, the wind drifts and the lake bed stops
const VE_ROW: float = 630.0 # N: a full stroke forward, about 3 m/s on Maroon Lake's hull
const VE_ROW_TURN: float = 270.0 # N.m: the oars pulled against each other, about 1.1 rad/s
const VE_WIND: float = 70.0 # N on a boat in a full wind
export function vehicle_update(vehicles_st: mut VehiclesState, ix: float, iz: float, run: bool, dt: float) -> void {
let v = vehicles_st.ve_cur
@ -18,7 +15,8 @@ export function vehicle_update(vehicles_st: mut VehiclesState, ix: float, iz: fl
function ve_row(vehicles_st: mut VehiclesState, v: Vehicle, ix: float, iz: float, dt: float) -> void {
ve_hull_read(v)
let take = ve_swell(vehicles_st, v, iz, dt)
VehicleHull.row(v.nid, iz * VE_ROW * (1.0 - take), -ix * VE_ROW_TURN)
let sp = vehicle_spec(vehicles_st, v.kind)
VehicleHull.row(v.nid, iz * sp.row * (1.0 - take), -ix * sp.row_turn)
let d = Math.abs(v.speed) * dt
if d > 0.0 { ve_moved_add(vehicles_st, v, d) }
}
@ -55,13 +53,14 @@ function ve_swell(vehicles_st: mut VehiclesState, v: Vehicle, iz: float, dt: flo
# called or left, its hull read back and held there
export function vehicles_tick(vehicles_st: VehiclesState, dt: float) -> void {
let l = ve_all(vehicles_st)
let w = VehicleWorld.wind() * VE_WIND
let w = VehicleWorld.wind()
let wy = VehicleWorld.wind_yaw()
for i in 0 .. len(l) {
let v = l[i]
if v.kind != VEHICLE_BOAT { continue }
if v.rider >= 0 {
if w > 0.0 { VehicleHull.drift(v.nid, -Math.sin(wy) * w, -Math.cos(wy) * w) }
let f = w * vehicle_spec(vehicles_st, v.kind).wind
if f > 0.0 { VehicleHull.drift(v.nid, -Math.sin(wy) * f, -Math.cos(wy) * f) }
continue
}
if not VehicleWorld.active(v.x, v.z) { continue } # outside every zone: left where it lies