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,17 +1,17 @@
|
|||
# near.ludic - the world asks who is nearest, never "the player": an animal notices whoever is
|
||||
# closest, a camper keeps clear of everyone
|
||||
export function ply_near_d2(x: float, z: float) -> float {
|
||||
session__near_i = 0
|
||||
export function ply_near_d2(session_st: mut SessionState, x: float, z: float) -> float {
|
||||
session_st.session__near_i = 0
|
||||
var best = 0.0
|
||||
var first = true
|
||||
for p in 0 .. PLY_MAX {
|
||||
if not ply_on(p) { continue }
|
||||
let dx = x - ply_x(p)
|
||||
let dz = z - ply_z(p)
|
||||
if not ply_on(session_st, p) { continue }
|
||||
let dx = x - ply_x(session_st, p)
|
||||
let dz = z - ply_z(session_st, p)
|
||||
let d2 = dx * dx + dz * dz
|
||||
if first or d2 < best {
|
||||
best = d2
|
||||
session__near_i = p
|
||||
session_st.session__near_i = p
|
||||
first = false
|
||||
}
|
||||
}
|
||||
|
|
@ -19,12 +19,12 @@ export function ply_near_d2(x: float, z: float) -> float {
|
|||
}
|
||||
|
||||
# the distance to the nearest player, in metres; ply_near_i() says which
|
||||
export function ply_near(x: float, z: float) -> float { return Math.sqrt(ply_near_d2(x, z)) }
|
||||
export function ply_near(session_st: mut SessionState, x: float, z: float) -> float { return Math.sqrt(ply_near_d2(session_st, x, z)) }
|
||||
|
||||
export function ply_near_i() -> int { return session__near_i }
|
||||
export function ply_near_i(session_st: SessionState) -> int { return session_st.session__near_i }
|
||||
|
||||
export function ply_dist(p: int, x: float, z: float) -> float {
|
||||
let dx = x - ply_x(p)
|
||||
let dz = z - ply_z(p)
|
||||
export function ply_dist(session_st: SessionState, p: int, x: float, z: float) -> float {
|
||||
let dx = x - ply_x(session_st, p)
|
||||
let dz = z - ply_z(session_st, p)
|
||||
return Math.sqrt(dx * dx + dz * dz)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue