wip(0.S3): packages and examples migrated in one run - ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d490d4f9f1
commit
3eda72e8c2
172 changed files with 3094 additions and 2966 deletions
|
|
@ -3,13 +3,15 @@
|
|||
# Running it prints: 1 2 3 4 5 6 7 8 9 10 11 12
|
||||
program Floats {
|
||||
const HALF: float = 0.5
|
||||
var g_gravity: float = -9.81
|
||||
state FloatsState {
|
||||
g_gravity: float = -9.81
|
||||
}
|
||||
|
||||
property Body { x: float = 1.25, vy: float, mass: double = 70.5 }
|
||||
|
||||
function lerp(a: float, b: float, t: float) -> float { return a + (b - a) * t }
|
||||
|
||||
entry {
|
||||
entry (floats_st: FloatsState) {
|
||||
let a: float = 0.1
|
||||
if a * 3 > 0.29 and a * 3 < 0.31 { print(1) } # the int 3 promotes
|
||||
if lerp(0, 10, 0.25) == 2.5 { print(2) } # ints and literals as floats
|
||||
|
|
@ -18,7 +20,7 @@ program Floats {
|
|||
if string(a + 0.2) == "0.3" { print(4) } # shortest text that reads back
|
||||
|
||||
let b = new Body
|
||||
b.vy = b.vy + g_gravity * HALF
|
||||
b.vy = b.vy + floats_st.g_gravity * HALF
|
||||
if b.vy < -4.9 and b.vy > -4.91 and b.mass == 70.5 { print(5) }
|
||||
|
||||
let v = floats(3)
|
||||
|
|
|
|||
|
|
@ -5,12 +5,14 @@
|
|||
# Running it prints: 4294967295 3988292384 -4294967296 1099511627776 -3750763034362895579 -1 1
|
||||
program LongLiterals {
|
||||
const MASK: long = 4294967295
|
||||
var poly: long = 3988292384
|
||||
state LongliteralsState {
|
||||
poly: long = 3988292384
|
||||
}
|
||||
function neg() -> long { return -4294967296 }
|
||||
entry {
|
||||
entry (longliterals_st: LongliteralsState) {
|
||||
let big = 0x10000000000
|
||||
let fnv = 0xcbf29ce484222325
|
||||
let small = 0xFFFFFFFF
|
||||
print(`{MASK} {poly} {neg()} {big} {fnv} {small} {MASK > long(2147483647)}`)
|
||||
print(`{MASK} {longliterals_st.poly} {neg()} {big} {fnv} {small} {MASK > long(2147483647)}`)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,30 +15,32 @@
|
|||
# bin/ludic-dev game-build bin/ludicc examples/lang/scenes.ludic /tmp/scenes
|
||||
# printf 'aaaa' | /tmp/scenes
|
||||
program SceneDemo {
|
||||
var counter: int = 0
|
||||
state ScenedemoState {
|
||||
counter: int = 0
|
||||
}
|
||||
|
||||
handler Boot phase Start { counter = 0; print(1000) }
|
||||
handler Boot(scenedemo_st: mut ScenedemoState) phase Start { scenedemo_st.counter = 0; print(1000) }
|
||||
|
||||
scene Title start {
|
||||
on enter { print(1) }
|
||||
on exit { print(2) }
|
||||
layer Main {
|
||||
handler Tick phase Update {
|
||||
counter += 1
|
||||
print(100 + counter)
|
||||
if counter >= 2 { become Play }
|
||||
handler Tick(scenedemo_st: mut ScenedemoState) phase Update {
|
||||
scenedemo_st.counter += 1
|
||||
print(100 + scenedemo_st.counter)
|
||||
if scenedemo_st.counter >= 2 { become Play }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scene Play {
|
||||
on enter { print(3); counter = 0 }
|
||||
on enter (scenedemo_st: mut ScenedemoState) { print(3); scenedemo_st.counter = 0 }
|
||||
on exit { print(4) }
|
||||
layer World {
|
||||
handler Step phase Update {
|
||||
counter += 1
|
||||
print(200 + counter)
|
||||
if counter >= 2 { quit() }
|
||||
handler Step(scenedemo_st: mut ScenedemoState) phase Update {
|
||||
scenedemo_st.counter += 1
|
||||
print(200 + scenedemo_st.counter)
|
||||
if scenedemo_st.counter >= 2 { quit() }
|
||||
}
|
||||
}
|
||||
layer Hud {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue