wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run
ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic 1804 vars into 126 states, 64 into lets; 23498 edits in 460 files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5ffe50ed02
commit
19fcf60599
459 changed files with 17862 additions and 17603 deletions
|
|
@ -1,73 +1,73 @@
|
|||
# water.ludic - one axis decides it: how far the bed is below the surface where the body stands.
|
||||
# Under CHAR_WADE_MAX the walk wades; past it the feet leave the bottom. Coming out wants a
|
||||
# shallower bed (CHAR_STAND_UP) than going in did, so a shelving shore does not flicker.
|
||||
function chr_enter_water(x: float, z: float) -> void {
|
||||
if chr_swim { return }
|
||||
chr_swim = true
|
||||
chr_dive = false
|
||||
chr_depth = 0.0
|
||||
chr_breath = body_breath_max()
|
||||
chr_float = 0.0
|
||||
chr_air = false
|
||||
chr_vy = 0.0
|
||||
chr_sit = false
|
||||
chr_x = x
|
||||
chr_z = z
|
||||
chr_water = CharacterGround.water(x, z)
|
||||
chr_y = chr_water - 0.30
|
||||
chr_say(CHAR_STARTED_SWIMMING, 0.0)
|
||||
function chr_enter_water(base_st: mut BaseState, character_st: mut CharacterState, x: float, z: float) -> void {
|
||||
if character_st.chr_swim { return }
|
||||
character_st.chr_swim = true
|
||||
character_st.chr_dive = false
|
||||
character_st.chr_depth = 0.0
|
||||
character_st.chr_breath = body_breath_max()
|
||||
character_st.chr_float = 0.0
|
||||
character_st.chr_air = false
|
||||
character_st.chr_vy = 0.0
|
||||
character_st.chr_sit = false
|
||||
character_st.chr_x = x
|
||||
character_st.chr_z = z
|
||||
character_st.chr_water = CharacterGround.water(x, z)
|
||||
character_st.chr_y = character_st.chr_water - 0.30
|
||||
chr_say(base_st, character_st, CHAR_STARTED_SWIMMING, 0.0)
|
||||
}
|
||||
|
||||
function chr_leave_water() -> void {
|
||||
if not chr_swim { return }
|
||||
chr_swim = false
|
||||
chr_dive = false
|
||||
chr_depth = 0.0
|
||||
chr_y = CharacterGround.height(chr_x, chr_z)
|
||||
chr_speed = Math.min(chr_speed, 1.0)
|
||||
chr_say(CHAR_LEFT_WATER, 0.0)
|
||||
function chr_leave_water(base_st: mut BaseState, character_st: mut CharacterState) -> void {
|
||||
if not character_st.chr_swim { return }
|
||||
character_st.chr_swim = false
|
||||
character_st.chr_dive = false
|
||||
character_st.chr_depth = 0.0
|
||||
character_st.chr_y = CharacterGround.height(character_st.chr_x, character_st.chr_z)
|
||||
character_st.chr_speed = Math.min(character_st.chr_speed, 1.0)
|
||||
chr_say(base_st, character_st, CHAR_LEFT_WATER, 0.0)
|
||||
}
|
||||
|
||||
# the descent: the jump held pushes the body under, letting go floats it back up
|
||||
function chr_dive_tick(jump: bool, dt: float) -> void {
|
||||
let bed = Math.max(chr_bed_depth(chr_x, chr_z), 0.0)
|
||||
function chr_dive_tick(character_st: mut CharacterState, jump: bool, dt: float) -> void {
|
||||
let bed = Math.max(chr_bed_depth(character_st.chr_x, character_st.chr_z), 0.0)
|
||||
let max_d = Math.min(6.0, Math.max(bed - 0.4, 0.0))
|
||||
if jump and max_d > 0.2 {
|
||||
chr_dive = true
|
||||
chr_depth = Math.min(chr_depth + 1.2 * dt, max_d)
|
||||
character_st.chr_dive = true
|
||||
character_st.chr_depth = Math.min(character_st.chr_depth + 1.2 * dt, max_d)
|
||||
} else {
|
||||
chr_depth = Math.max(chr_depth - 1.6 * dt, 0.0)
|
||||
if chr_depth < 0.05 { chr_dive = false }
|
||||
character_st.chr_depth = Math.max(character_st.chr_depth - 1.6 * dt, 0.0)
|
||||
if character_st.chr_depth < 0.05 { character_st.chr_dive = false }
|
||||
}
|
||||
}
|
||||
|
||||
# air is spent only under the surface, and comes back fast at the top
|
||||
function chr_breath_tick(dt: float) -> void {
|
||||
if not (chr_depth > 0.55) {
|
||||
chr_breath = Math.min(chr_breath + dt * 12.0, body_breath_max())
|
||||
function chr_breath_tick(base_st: mut BaseState, character_st: mut CharacterState, dt: float) -> void {
|
||||
if not (character_st.chr_depth > 0.55) {
|
||||
character_st.chr_breath = Math.min(character_st.chr_breath + dt * 12.0, body_breath_max())
|
||||
return
|
||||
}
|
||||
chr_breath = chr_breath - dt
|
||||
if chr_breath < 0.0 {
|
||||
chr_breath = 0.0
|
||||
chr_dive = false
|
||||
chr_depth = Math.max(chr_depth - 3.0 * dt, 0.0)
|
||||
chr_say(CHAR_OUT_OF_AIR, dt)
|
||||
character_st.chr_breath = character_st.chr_breath - dt
|
||||
if character_st.chr_breath < 0.0 {
|
||||
character_st.chr_breath = 0.0
|
||||
character_st.chr_dive = false
|
||||
character_st.chr_depth = Math.max(character_st.chr_depth - 3.0 * dt, 0.0)
|
||||
chr_say(base_st, character_st, CHAR_OUT_OF_AIR, dt)
|
||||
}
|
||||
}
|
||||
|
||||
# The edge of the world is a current, not a wall: it takes the outward part of a stroke, so
|
||||
# turning round always works. Said once every twelve seconds while it is strong.
|
||||
function chr_current_tick(dt: float) -> void {
|
||||
let fx = -Math.sin(chr_yaw)
|
||||
let fz = -Math.cos(chr_yaw)
|
||||
let take = Math.clamp(CharacterGround.current(chr_x, chr_z, fx, fz), 0.0, 1.0)
|
||||
function chr_current_tick(base_st: mut BaseState, character_st: mut CharacterState, dt: float) -> void {
|
||||
let fx = -Math.sin(character_st.chr_yaw)
|
||||
let fz = -Math.cos(character_st.chr_yaw)
|
||||
let take = Math.clamp(CharacterGround.current(character_st.chr_x, character_st.chr_z, fx, fz), 0.0, 1.0)
|
||||
if take > 0.0 {
|
||||
chr_speed = chr_speed * (1.0 - take)
|
||||
if take > 0.55 and chr_edge_said < 0.0 {
|
||||
chr_edge_said = 12.0
|
||||
chr_say(CHAR_CURRENT, take)
|
||||
character_st.chr_speed = character_st.chr_speed * (1.0 - take)
|
||||
if take > 0.55 and character_st.chr_edge_said < 0.0 {
|
||||
character_st.chr_edge_said = 12.0
|
||||
chr_say(base_st, character_st, CHAR_CURRENT, take)
|
||||
}
|
||||
}
|
||||
chr_edge_said = chr_edge_said - dt
|
||||
character_st.chr_edge_said = character_st.chr_edge_said - dt
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue