ludic/packages/ludic.vehicles/spec.ludic
Orkuncakilkaya 668a9ecf69 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>
2026-09-29 20:22:02 +03:00

40 lines
1.9 KiB
Text

# spec.ludic - a kind's numbers, handed in by the game from its own table before any vehicle of the
# kind is made (vehicles_spec): where the rider sits, its pace, its oars, its hay, where one gets off
export property VehicleSpec {
seat_h: float = 0.0 # m: the rider sits this far above it
walk: float = 0.0 # m/s: a horse's walk
run: float = 0.0 # m/s: its gallop
acc: float = 0.0 # m/s2: how fast it gets there
turn: float = 0.0 # rad/s at a full stick
row: float = 0.0 # N: a full stroke forward
row_turn: float = 0.0 # N.m: the oars pulled against each other
wind: float = 0.0 # N on it in a full wind
hay_per_m: float = 0.0 # hay (0..100) every metre costs
hay_min: float = 0.0 # with less hay than this it will not go
run_min: float = 0.0 # stamina (0..100) a gallop needs
tire_at: float = 0.0 # m/s: faster than this is a gallop, and tires it
tire: float = 0.0 # stamina a second spent at a gallop
rest: float = 0.0 # and given back a second at a walk
off_side: float = 0.0 # m: a rider gets off this far out to its right
off_depth: float = 0.0 # m: the deepest wade a rider gets off into
}
export const VEHICLE_KINDS: int = 8 # kinds a game may give numbers to, 0 .. 7
function ve_specs_new() -> []VehicleSpec {
let l = new []VehicleSpec
for i in 0 .. VEHICLE_KINDS { push(l, null) }
return l
}
# kind's numbers from now on; a kind that has none cannot be called
export function vehicles_spec(vehicles_st: mut VehiclesState, kind: int, spec: VehicleSpec) -> void {
if kind < 0 or kind >= VEHICLE_KINDS { return }
vehicles_st.ve_specs[kind] = spec
}
# a kind's numbers, or null when the game gave it none
export function vehicle_spec(vehicles_st: VehiclesState, kind: int) -> VehicleSpec {
if kind < 0 or kind >= VEHICLE_KINDS { return null }
return vehicles_st.ve_specs[kind]
}