refactor(runtime,packages,examples): named constants, package enums, idiom sweep

- runtime: HEADLESS_FRAME_PATH, STICK_DEADZONE / STICK_LEFT_X/Y, key and
  byte codes as char literals throughout (`k == 'w'`, `fill(rt_map, ' ', …)`)
- ludic.gameplay/stats: drop the duplicate `stat_field` (it answered "atk"
  for every build stat); Stats.base uses stats_field_name
- ludic.shooter: compare aim modes and fire patterns with AimMode.* and
  WeaponPattern.* instead of raw ints; STICK_RIGHT_X/Y
- ludic.npcai: DecisionMade / brain_set_state use AiState.*
- examples/games/menu.ludic uses Font.load / Ui.* with FONT_PATH and
  BACKDROP named; strings.ludic header says what it prints
- whole tree: `x = x + 1` → `x += 1` (single-term right-hand sides only),
  `0 - x` → `-x`, ASCII codes → char literals; every .ludic and every
  ```ludic fence reformatted with the fixed formatter (whitespace only)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-05 01:12:26 +03:00
parent e3e1bc7784
commit bf36bc8a8f
103 changed files with 1256 additions and 1252 deletions

View file

@ -59,6 +59,6 @@ program AnimEcs {
# run the Update phase n times; the engine systems advance one tick each call.
function tick_n(n: int) -> void {
var i = 0
while i < n { tick_fixed(); i = i + 1 }
while i < n { tick_fixed(); i += 1 }
}
}

View file

@ -16,7 +16,7 @@ program AnimSugar {
model Sprite { SpriteAnim }
model Mover { Motion }
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i = i + 1 } }
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i += 1 } }
function bi(b: bool) -> int { if b { return 1 }; return 0 }
entry {

View file

@ -25,7 +25,7 @@ program AtlasDemo {
let d = Sprite.define("hero", sheet, 2, 3) # name a cell
print(bi(Sprite.named("hero") == d)) # 1 — looked up by name
print(bi(Assets.get("hero") == d)) # 1 — Assets.get is the same lookup
print(bi(Sprite.named("nope") == (0 - 1))) # 1 — an unknown name is -1
print(bi(Sprite.named("nope") == (-1))) # 1 — an unknown name is -1
let whole = Assets.image("assets/kenney/tiny-dungeon/Tiles/tile_0096.png")
print(Sprite.width(whole)) # 16 — a whole tile as one sprite
@ -34,7 +34,7 @@ program AtlasDemo {
Screen.clear(0)
Sprite.draw(whole, 10, 10)
var n = 0
for yy in 10 .. 26 { for xx in 10 .. 26 { if Screen.pixel(xx, yy) != 0 { n = n + 1 } } }
for yy in 10 .. 26 { for xx in 10 .. 26 { if Screen.pixel(xx, yy) != 0 { n += 1 } } }
print(bi(n > 0)) # 1 — the sprite drew content
}
}

View file

@ -19,7 +19,7 @@ program Combat {
@export function damage(attack: int, armour: int, roll: int) -> int {
var raw = attack - armour
if raw < 1 { raw = 1 }
if roll == 20 { raw = raw * CRIT_MULT }
if roll == 20 { raw *= CRIT_MULT }
return raw
}
@ -29,8 +29,8 @@ program Combat {
var left = hp
var n = 0
while left > 0 {
left = left - damage(attack, armour, 0)
n = n + 1
left -= damage(attack, armour, 0)
n += 1
}
return n
}

View file

@ -30,7 +30,7 @@ program ComponentAccess {
Hero.of(player).iframes -= 5
print(Hero.of(player).iframes) # 15
let hero = Hero.of(player)
hero.roll_frames = hero.roll_frames + 1
hero.roll_frames += 1
print(Hero.of(player).roll_frames) # 10
print(Position.of(player).x + Position.of(1).x) # 33
print(Hero.has(player)) # 1

View file

@ -12,7 +12,7 @@ program Containers {
if Dict.get(bank, "gold") == 150 { print(1) }
if Dict.get(bank, "wood") == 50 { print(2) }
if Dict.get(bank, "stone") == 0 { print(3) } # absent -> 0
if Dict.get_or(bank, "stone", 0 - 1) == 0 - 1 { print(4) }
if Dict.get_or(bank, "stone", -1) == -1 { print(4) }
if Dict.has(bank, "wood") { print(5) }
if Dict.size(bank) == 2 { print(6) }
Dict.remove(bank, "wood")
@ -21,7 +21,7 @@ program Containers {
# grow past the initial capacity, then read back
var i = 0
while i < 100 { Dict.set(bank, "k" + string(i), i * 2); i = i + 1 }
while i < 100 { Dict.set(bank, "k" + string(i), i * 2); i += 1 }
if Dict.get(bank, "k42") == 84 { print(9) }
if Dict.size(bank) == 101 { print(10) } # gold + k0..k99
if len(Dict.keys(bank)) == 101 { print(11) }

View file

@ -14,7 +14,7 @@ program CoreComponents {
# subclassing, just another property on the same model.
property Health { hp: int = 0 }
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i = i + 1 } }
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i += 1 } }
entry {
let pp = World.prop_id("Position")

View file

@ -16,7 +16,7 @@ program CoverageSpec {
return 1
}
if n < 0 {
return 0 - 1
return -1
}
return 0
}
@ -35,7 +35,7 @@ program CoverageSpec {
test "sign covers every branch" {
expect_eq(sign(7), 1)
expect_eq(sign(0 - 3), 0 - 1)
expect_eq(sign(-3), -1)
expect_eq(sign(0), 0)
}

View file

@ -21,7 +21,7 @@ program Errors {
entry {
print(checked_div(10, 2)) # 5
print(clampi(15, 0, 10)) # 10 (above hi)
print(clampi(0 - 3, 0, 10)) # 0 (below lo)
print(clampi(-3, 0, 10)) # 0 (below lo)
print(clampi(7, 0, 10)) # 7 (in range)
print(1) # reached: every assertion held
}

View file

@ -24,9 +24,9 @@ program GameplayFoundation {
}
var deaths: int = 0
@On(Died) handler Tally { deaths = deaths + 1 }
@On(Died) handler Tally { deaths += 1 }
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i = i + 1 } }
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i += 1 } }
function bi(b: bool) -> int { if b { return 1 }; return 0 }
entry {
@ -74,7 +74,7 @@ program GameplayFoundation {
# finish it off with sub-100 hits so the veto never blocks the kill
var guard = 0
while (World.get(t, PS, fhp) > 0) and (guard < 100) { Combat.damage(t, a, 90); guard = guard + 1 }
while (World.get(t, PS, fhp) > 0) and (guard < 100) { Combat.damage(t, a, 90); guard += 1 }
print(deaths) # 1
quit()

View file

@ -45,12 +45,12 @@ program Grid {
let dx = p[i].x - p[i - 1].x
let dy = p[i].y - p[i - 1].y
var ad = dx
if ad < 0 { ad = 0 - ad }
if ad < 0 { ad = -ad }
var ay = dy
if ay < 0 { ay = 0 - ay }
if ay < 0 { ay = -ay }
if ad + ay != 1 { ok = false }
if Grid.blocked(p[i].x, p[i].y, '#') { ok = false }
i = i + 1
i += 1
}
if ok { print(9) }
@ -58,7 +58,7 @@ program Grid {
if len(Grid.a_star(1, 1, 3, 2, '#')) == 0 { print(10) } # (3,2) is a wall
if Grid.blocked(3, 2, '#') { print(11) }
if not Grid.blocked(1, 1, '#') { print(12) }
if Grid.blocked(0 - 1, 0, '#') { print(13) } # out of bounds
if Grid.blocked(-1, 0, '#') { print(13) } # out of bounds
}
handler Run phase Update { quit() }

View file

@ -15,6 +15,6 @@ program InputAuto {
var hits: int = 0
@OnStart handler Boot { Input.action("go", 'l') } # 'l' == 108
handler Sense phase Update { if Input.active("go") { hits = hits + 1 } }
handler Sense phase Update { if Input.active("go") { hits += 1 } }
@OnQuit handler Report { print(hits) }
}

View file

@ -19,9 +19,9 @@ program InputEdge {
handler In phase Update {
var v = 0
if Input.key_down('k') { v = v + 1 } # held
if Input.key_pressed('k') { v = v + 10 } # went down this frame
if Input.key_released('k') { v = v + 100 } # went up this frame
if Input.key_down('k') { v += 1 } # held
if Input.key_pressed('k') { v += 10 } # went down this frame
if Input.key_released('k') { v += 100 } # went up this frame
print(v)
}
}

View file

@ -69,7 +69,7 @@ program LightTiers {
dark()
Light.clear_normals()
Light.normal(18, 30, 8, 8, 0.7, 0.0) # this patch faces right (toward the light)
Light.normal(46, 30, 8, 8, 0.0 - 0.7, 0.0) # this patch faces left (away)
Light.normal(46, 30, 8, 8, 0.0 - 0.7, 0.0) # this patch faces left (away)
Light.point(32, 34, 44, 16777215, 1.0) # a light centred between the patches
let toward = lum(22, 34) # patch facing the light
let away = lum(48, 34) # patch facing away

View file

@ -14,7 +14,7 @@ program Numeric {
if Huge.str(Huge.add(Huge.from(1000000000), Huge.from(1))) == "1.00e9" { print(6) } # +1 negligible
if Huge.cmp(Huge.from(1000000000), Huge.from(1000000)) == 1 { print(7) }
if Huge.exp(Huge.mul(Huge.from(1000000), Huge.from(1000000))) == 12 { print(8) }
if Huge.str(Huge.from(0 - 42)) == "-4.20e1" { print(9) }
if Huge.str(Huge.from(-42)) == "-4.20e1" { print(9) }
if Huge.str(Huge.from(0)) == "0" { print(10) }
# --- Angle: wrapping radians (built on the deterministic Math.*) ---

View file

@ -12,7 +12,7 @@ program OptionResult {
}
# a fallible parse — a value or a message
function to_digit(c: int) -> result {
if c >= 48 and c <= 57 { return ok(c - 48) } # '0'..'9'
if c >= '0' and c <= '9' { return ok(c - 48) } # '0'..'9'
return err("not a digit")
}
entry {
@ -20,20 +20,20 @@ program OptionResult {
let a = some(42)
if is_some(a) { print(1) }
if not is_none(a) { print(2) }
if unwrap_or(a, 0 - 1) == 42 { print(3) }
if unwrap_or(a, -1) == 42 { print(3) }
let b = none()
if is_none(b) { print(4) }
if unwrap_or(b, 0 - 1) == 0 - 1 { print(5) }
if unwrap_or(b, -1) == -1 { print(5) }
if unwrap_or(slot_of(5), 0) == 50 { print(6) }
if is_none(slot_of(0 - 1)) { print(7) }
if is_none(slot_of(-1)) { print(7) }
# --- result + try/else ---
if is_ok(to_digit(55)) { print(8) }
if is_err(to_digit(120)) { print(9) }
let d = try to_digit(55) else { 0 } # '7' -> 7
if d == 7 { print(10) }
let bad = try to_digit(120) else { 0 - 1 } # not a digit -> fallback
if bad == 0 - 1 { print(11) }
let bad = try to_digit(120) else { -1 } # not a digit -> fallback
if bad == -1 { print(11) }
let msg = try to_digit(120) else { print(12); 0 } # else binds `error`
}
}

View file

@ -20,7 +20,7 @@ program Physics {
hit: int = 0, entered: int = 0, exited: int = 0
}
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i = i + 1 } }
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i += 1 } }
function bi(b: bool) -> int { if b { return 1 }; return 0 }
# despawn every live entity carrying a property, so each scenario starts clean.
@ -65,7 +65,7 @@ program Physics {
# re-apply the run velocity each frame, the way a controller drives it from
# held input — so hit_wall stays asserted while pressed against the wall.
var bi2 = 0
while bi2 < 80 { World.set(a, pb, f_vx, fixed(4)); tick_fixed(); bi2 = bi2 + 1 }
while bi2 < 80 { World.set(a, pb, f_vx, fixed(4)); tick_fixed(); bi2 += 1 }
print(World.get(a, pp, f_x)) # 284 — right edge stops at the wall (300)
print(World.get(a, pb, f_hw)) # 1 — hit_wall while pressed
print(bi(World.get(a, pb, f_vx) == 0)) # 1 — the sweep zeroed it this frame
@ -93,7 +93,7 @@ program Physics {
spawn Plat { Position { x: 400, y: 150 }, Collider { w: 64, h: 8, one_way: 1 } }
spawn Runner { Position { x: 405, y: 60 }, Body { gravity: fixed(1), max_fall: fixed(6) }, Collider { w: 16, h: 16 } }
let e1 = World.query_next(pb, 0)
spawn Riser { Position { x: 430, y: 200 }, Body { vy: fixed(0 - 4), policy: 1 }, Collider { w: 16, h: 16 } }
spawn Riser { Position { x: 430, y: 200 }, Body { vy: fixed(-4), policy: 1 }, Collider { w: 16, h: 16 } }
var e2 = World.query_next(pb, 0)
if e2 == e1 { e2 = World.query_next(pb, e1 + 1) }
tick_n(20)

View file

@ -49,7 +49,7 @@ program PhysicsTiles {
spawn Runner { Position { x: 32, y: 16 }, Body { gravity: fixed(1), max_fall: fixed(6) }, Collider { w: 16, h: 16 } }
var a = World.query_next(pb, 0)
var i = 0
while i < 80 { tick_fixed(); i = i + 1 }
while i < 80 { tick_fixed(); i += 1 }
print(World.get(a, pp, f_y)) # 112 — feet rest on the tile floor top (128)
print(World.get(a, pb, f_grd)) # 1
@ -58,7 +58,7 @@ program PhysicsTiles {
spawn Runner { Position { x: 16, y: 112 }, Body { gravity: fixed(1), max_fall: fixed(6) }, Collider { w: 16, h: 16 } }
a = World.query_next(pb, 0)
i = 0
while i < 60 { World.set(a, pb, f_vx, fixed(4)); tick_fixed(); i = i + 1 }
while i < 60 { World.set(a, pb, f_vx, fixed(4)); tick_fixed(); i += 1 }
print(World.get(a, pp, f_x)) # 80 — right edge stops at the wall column (96)
print(World.get(a, pb, f_hw)) # 1
@ -67,16 +67,16 @@ program PhysicsTiles {
spawn Runner { Position { x: 176, y: 16 }, Body { gravity: fixed(1), max_fall: fixed(6) }, Collider { w: 16, h: 16 } }
a = World.query_next(pb, 0)
i = 0
while i < 40 { tick_fixed(); i = i + 1 }
while i < 40 { tick_fixed(); i += 1 }
print(World.get(a, pp, f_y)) # 48 — feet on the one-way top (64)
print(World.get(a, pb, f_grd)) # 1
# ---- T3b. rise straight up through the one-way tile --------------------
clear()
spawn Riser { Position { x: 176, y: 120 }, Body { vy: fixed(0 - 4), policy: 1 }, Collider { w: 16, h: 16 } }
spawn Riser { Position { x: 176, y: 120 }, Body { vy: fixed(-4), policy: 1 }, Collider { w: 16, h: 16 } }
a = World.query_next(pb, 0)
i = 0
while i < 15 { tick_fixed(); i = i + 1 }
while i < 15 { tick_fixed(); i += 1 }
print(World.get(a, pp, f_y)) # 60 — passed through (120 - 4*15), above the platform
quit()

View file

@ -52,7 +52,7 @@ program Query {
let near0 = Query.within(P, P, 0, 0, 0, cx, cy)
if len(near0) == 1 { print(14) } # only e0 at (0,0)
if World.get(near0[0], P, cx) == 0 { print(15) } # and it is e0
if len(Query.within(G, P, 0, 0, 100, cx, cy)) == 0 { print(16) } # empty
if len(Query.within(G, P, 0, 0, 100, cx, cy)) == 0 { print(16) } # empty
if len(Query.within(K, P, 0, 0, 6, cx, cy)) == 2 { print(17) } # Mobs e0, e2 (filter K, pos P)
if World.get(Query.nearest(P, P, cx, cy, 20, 20), P, cx) == 20 { print(18) } # e4

View file

@ -52,11 +52,11 @@ program Reflect {
let fc = Reflect.field_count(p)
var f = 0
while f < fc {
total = total + Reflect.get(e, p, f)
f = f + 1
total += Reflect.get(e, p, f)
f += 1
}
}
p = p + 1
p += 1
}
if total == 327697 { print(17) } # 7 + 10 + 131072 + 196608

View file

@ -42,7 +42,7 @@ program Regex {
var tags = ""
var cur = Regex.exec("#a #bb #ccc", re)
while Regex.ok(cur) {
tags = tags + Regex.group(cur, 1)
tags += Regex.group(cur, 1)
cur = Regex.next("#a #bb #ccc", re, Regex.end(cur, 0))
}
if tags == "abbccc" { print(16) }

View file

@ -32,7 +32,7 @@ program TestingSpec {
test "loops and locals work in a test" {
var sum = 0
for i in 0 .. 5 { sum = sum + i } # 0+1+2+3+4 = 10
for i in 0 .. 5 { sum += i } # 0+1+2+3+4 = 10
expect_eq(sum, 10)
}

View file

@ -26,7 +26,7 @@ program TiledP05 {
# --- four layers, every encoding decodes to the SAME 16-GID array ---
let layers = Value.get(m, "layers")
if Value.count(layers) == 4 { print(8) }
let FLIP = 0 - 2147483647 # 0x80000001 as i32
let FLIP = -2147483647 # 0x80000001 as i32
var same = 1
var li = 0
while li < 4 {
@ -35,7 +35,7 @@ program TiledP05 {
if Value.as_int(Value.at(data, 0)) != 1 { same = 0 }
if Value.as_int(Value.at(data, 14)) != 15 { same = 0 }
if Value.as_int(Value.at(data, 15)) != FLIP { same = 0 }
li = li + 1
li += 1
}
if same == 1 { print(9) }
# the CSV path and the gzip path agree on the flip-flagged GID
@ -61,9 +61,9 @@ program TiledP05 {
var gi = 0
while gi < 16 {
if Value.as_int(Value.at(jdata, gi)) != Value.as_int(Value.at(csvdata, gi)) { jsame = 0 }
gi = gi + 1
gi += 1
}
jli = jli + 1
jli += 1
}
if jsame == 1 { print(16) }

View file

@ -18,9 +18,9 @@ program TiledP1 {
var x = 0
while x < 320 {
h = h * 31 + rt_get_px(x, y)
x = x + 4
x += 4
}
y = y + 4
y += 4
}
return h
}
@ -56,7 +56,7 @@ program TiledP1 {
# --- flips draw with the correct orientation ---
# find a horizontally-asymmetric tile so the mirror test is meaningful
var chosen = 0 - 1
var chosen = -1
var t = 0
while t < 132 {
rt_clear(0)
@ -67,12 +67,12 @@ program TiledP1 {
var xx = 0
while xx < 8 {
if rt_get_px(xx, yy) != rt_get_px(15 - xx, yy) { asym = 1 }
xx = xx + 1
xx += 1
}
yy = yy + 1
yy += 1
}
if asym == 1 and chosen < 0 { chosen = t }
t = t + 1
t += 1
}
if chosen >= 0 { print(12) }
@ -88,9 +88,9 @@ program TiledP1 {
while xx2 < 16 {
if rt_get_px(xx2, yy2) != rt_get_px(31 - xx2, yy2) { mirror = 0 } # H-flip mirrors
if rt_get_px(xx2, yy2) != rt_get_px(15 - xx2, yy2) { diff = 1 } # the tile isn't symmetric
xx2 = xx2 + 1
xx2 += 1
}
yy2 = yy2 + 1
yy2 += 1
}
if mirror == 1 { print(13) }
if diff == 1 { print(14) }

View file

@ -23,16 +23,16 @@ program TiledP2 {
var n = 0
var y = 0
while y < 10 { var x = 0
while x < 16 { if rt_tile(x, y) == 35 { n = n + 1 }; x = x + 1 }
y = y + 1 }
while x < 16 { if rt_tile(x, y) == 35 { n += 1 }; x += 1 }
y += 1 }
return n
}
function grid_hash() -> int {
var h = 0
var y = 0
while y < 10 { var x = 0
while x < 16 { h = h * 31 + rt_tile(x, y); x = x + 1 }
y = y + 1 }
while x < 16 { h = h * 31 + rt_tile(x, y); x += 1 }
y += 1 }
return h
}
@ -75,7 +75,7 @@ program TiledP2 {
let f_grd = World.field_id(pb, "on_ground")
let a = World.query_next(pb, 0)
var i = 0
while i < 80 { tick_fixed(); i = i + 1 }
while i < 80 { tick_fixed(); i += 1 }
if World.get(a, pp, f_y) == 112 { print(13) } # feet rest on the tile floor top (128)
if World.get(a, pb, f_grd) == 1 { print(14) }
}

View file

@ -13,8 +13,8 @@ program TiledP3 {
var h = 0
var y = 0
while y < 64 { var x = 0
while x < 64 { h = h * 31 + rt_get_px(x, y); x = x + 2 }
y = y + 2 }
while x < 64 { h = h * 31 + rt_get_px(x, y); x += 2 }
y += 2 }
return h
}
@ -38,13 +38,13 @@ program TiledP3 {
# --- tile object parsed from the object layer ---
let tree = Tiled.tree(m)
var oglayer = Value.null()
var oglayer = Value.null ()
let layers = Value.get(tree, "layers")
var li = 0
while li < Value.count(layers) {
let L = Value.at(layers, li)
if Value.as_str(Value.get(L, "type")) == "objectgroup" { oglayer = L }
li = li + 1
li += 1
}
let objs = Value.get(oglayer, "objects")
if Value.count(objs) == 1 { print(8) }
@ -62,7 +62,7 @@ program TiledP3 {
# --- tile objects draw with correct GID flips (mirror test) ---
# find an asymmetric tile, draw it normal vs H-flipped as a tile object
var chosen = 0 - 1
var chosen = -1
var t = 0
while t < 132 {
rt_clear(0)
@ -70,10 +70,10 @@ program TiledP3 {
var asym = 0
var yy = 0
while yy < 16 { var xx = 0
while xx < 8 { if rt_get_px(xx, yy) != rt_get_px(15 - xx, yy) { asym = 1 }; xx = xx + 1 }
yy = yy + 1 }
while xx < 8 { if rt_get_px(xx, yy) != rt_get_px(15 - xx, yy) { asym = 1 }; xx += 1 }
yy += 1 }
if asym == 1 and chosen < 0 { chosen = t }
t = t + 1
t += 1
}
rt_clear(0)
tmap_draw_gid(m, 1 + chosen, 0, 0)
@ -81,8 +81,8 @@ program TiledP3 {
var mirror = 1
var yy2 = 0
while yy2 < 16 { var xx2 = 0
while xx2 < 16 { if rt_get_px(xx2, yy2) != rt_get_px(31 - xx2, yy2) { mirror = 0 }; xx2 = xx2 + 1 }
yy2 = yy2 + 1 }
while xx2 < 16 { if rt_get_px(xx2, yy2) != rt_get_px(31 - xx2, yy2) { mirror = 0 }; xx2 += 1 }
yy2 += 1 }
if mirror == 1 and chosen >= 0 { print(12) }
# --- the design's named fixture: rpg/beach_tileset.tsx (33 animations) ---
@ -94,8 +94,8 @@ program TiledP3 {
while ti < Value.count(tiles) {
let tt = Value.at(tiles, ti)
let an = Value.get(tt, "animation")
if Value.count(an) > 0 { nanim = nanim + 1; nframes = nframes + Value.count(an) }
ti = ti + 1
if Value.count(an) > 0 { nanim += 1; nframes += Value.count(an) }
ti += 1
}
if nanim == 33 { print(13) }
if nframes == 131 { print(14) }

View file

@ -51,11 +51,11 @@ program TiledP4 {
# --- the design's named fixture: orthogonal-outside.tmx object shapes ---
let og = Tiled.load("assets/tiled-fixtures/orthogonal-outside.tmx")
var olayer = 0 - 1
var olayer = -1
var oli = 0
while oli < Tiled.layer_count(og) {
if Tiled.object_count(og, oli) > 0 { olayer = oli }
oli = oli + 1
oli += 1
}
var nell = 0
var npt = 0
@ -64,11 +64,11 @@ program TiledP4 {
var oi = 0
while oi < Tiled.object_count(og, olayer) {
let sh = Tiled.object_shape(Tiled.object(og, olayer, oi))
if sh == "ellipse" { nell = nell + 1 }
if sh == "point" { npt = npt + 1 }
if sh == "polygon" { npg = npg + 1 }
if sh == "polyline" { npl = npl + 1 }
oi = oi + 1
if sh == "ellipse" { nell += 1 }
if sh == "point" { npt += 1 }
if sh == "polygon" { npg += 1 }
if sh == "polyline" { npl += 1 }
oi += 1
}
if nell == 1 and npt == 1 and npg == 1 { print(17) }
if npl == 2 { print(18) }

View file

@ -13,7 +13,7 @@ program TiledP5 {
let iso = Tiled.load("assets/tiled-fixtures/isometric_grass_and_water.tmx")
if Value.as_str(Value.get(Tiled.tree(iso), "orientation")) == "isometric" { print(1) }
if Tiled.cell_x(iso, 1, 0) == 32 { print(2) } # (1-0)*64/2
if Tiled.cell_x(iso, 0, 1) == 0 - 32 { print(3) } # (0-1)*64/2
if Tiled.cell_x(iso, 0, 1) == -32 { print(3) } # (0-1)*64/2
if Tiled.cell_y(iso, 1, 1) == 32 { print(4) } # (1+1)*32/2
if Tiled.cell_y(iso, 2, 0) == 32 { print(5) } # (2+0)*32/2
@ -23,8 +23,8 @@ program TiledP5 {
var cy = 0
while cy < Tiled.height(iso) and g == 0 {
var cx = 0
while cx < Tiled.width(iso) and g == 0 { g = Tiled.gid(iso, 0, cx, cy); cx = cx + 1 }
cy = cy + 1
while cx < Tiled.width(iso) and g == 0 { g = Tiled.gid(iso, 0, cx, cy); cx += 1 }
cy += 1
}
let r = Tiled.resolve(iso, g)
if r.tileset == 0 and r.local >= 0 { print(6) }
@ -48,8 +48,8 @@ program TiledP5 {
var yy = 0
while yy < 32 and painted == 0 {
var xx = 0
while xx < 32 and painted == 0 { if rt_get_px(xx, yy) != 0 { painted = 1 }; xx = xx + 1 }
yy = yy + 1
while xx < 32 and painted == 0 { if rt_get_px(xx, yy) != 0 { painted = 1 }; xx += 1 }
yy += 1
}
if painted == 1 { print(14) }
}

View file

@ -40,7 +40,7 @@ program TiledP6 {
var i = 0
while i < Value.count(csv) {
if Value.as_int(Value.at(csv, i)) != Value.as_int(Value.at(zstd, i)) { same = 0 }
i = i + 1
i += 1
}
if same == 1 { print(12) }
}

View file

@ -8,7 +8,7 @@
program WorldBounds {
import "ludic.core/components.ludic"
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i = i + 1 } }
function tick_n(n: int) -> void { var i = 0; while i < n { tick_fixed(); i += 1 } }
function bi(b: bool) -> int { if b { return 1 }; return 0 }
function clear_all() -> void {
@ -57,7 +57,7 @@ program WorldBounds {
tick_n(1)
var live = 0
var q = World.query_next(PBody, 0)
while q >= 0 { live = live + 1; q = World.query_next(PBody, q + 1) }
while q >= 0 { live += 1; q = World.query_next(PBody, q + 1) }
print(live) # 0 — the out-of-bounds body was killed
}
}