Big API refactor

This commit is contained in:
2026-06-28 00:12:52 -05:00
parent db9a5d37b6
commit 9de31d933b
31 changed files with 1036 additions and 1029 deletions
+13 -13
View File
@@ -8,24 +8,24 @@
// can't decide that with `can_shift` alone — `can_shift(j) == false` is ambiguous
// between "j is empty" and "j is a blocked solid" — so we seed with `can_shift`
// and then cascade-demote using `passable` to spot the genuine holes.
fn tick(dt) {
fn tick(me, state, dt) {
// Only start a new rotation when the previous one (and its delay) has drained,
// exactly like the built-in pusher's pacing.
if Queue.length() != 0 { return; }
if me.waiting { return; }
// Direction from the builtin tag; clockwise unless explicitly counter-clockwise.
let cw = !Me.has_tag("BUILTIN_spinner_ccw");
let cw = !me.has_tag("BUILTIN_spinner_ccw");
// The 8 neighbour offsets in clockwise order, starting at North.
let cw_ring = [
[Me.x, Me.y-1], // N
[Me.x+1, Me.y-1], // NE
[Me.x+1, Me.y], // E
[Me.x+1, Me.y+1], // SE
[Me.x, Me.y+1], // S
[Me.x-1, Me.y+1], // SW
[Me.x-1, Me.y], // W
[Me.x-1, Me.y-1], // NW
[me.x, me.y-1], // N
[me.x+1, me.y-1], // NE
[me.x+1, me.y], // E
[me.x+1, me.y+1], // SE
[me.x, me.y+1], // S
[me.x-1, me.y+1], // SW
[me.x-1, me.y], // W
[me.x-1, me.y-1], // NW
];
// For CCW, it's the same list in reverse
@@ -45,10 +45,10 @@ fn tick(dt) {
// line spins '/'-'\'-, slash-swapped for counter-clockwise. Frame state lives in
// the board Registry, keyed per spinner, since script scope resets each tick.
let frames = if cw { [47, 0xc4, 92, 0xb3] } else { [92, 0xc4, 47, 0xb3] };
let fkey = `spin_${Me.id}`;
let fkey = `spin_${me.id}`;
let f = Registry.get_or(fkey, 0);
set_tile(frames[f % 4]);
Registry.set(fkey, (f + 1) % 4);
delay(0.5);
me.delay(0.5);
}