Snake 0.9: crown control via scroll-delta turns (firmware-derived)
This commit is contained in:
+20
-2
@@ -64,8 +64,26 @@ assert.match(ux, /<image class="board" src="\/common\/tex\/board\.png"[^>]*>/);
|
||||
assert.match(ux, /<image class="seg" src="\{\{ seg\.src \}\}"/);
|
||||
assert.match(ux, /for="\{\{ seg in snake \}\}"/);
|
||||
assert.match(ux, /show="\{\{ over \}\}"/);
|
||||
assert.match(ux, /onswipe="onSwipe"/);
|
||||
assert.match(ux, /onscroll="onCrownScroll"/, 'scroll container wired for crown deltas');
|
||||
assert.match(ux, /<scroll id="scroller"/, 'scroller element present for re-centering');
|
||||
assert.doesNotMatch(ux, /crownrotationchanged/i);
|
||||
assert.doesNotMatch(ux, /transform\s*:/);
|
||||
|
||||
console.log('PAGE WIRING PASS (textures, movement, turn, reversal, game over, restart, directives)');
|
||||
// crown path: scroll deltas become queued 90° turns, board stays centered
|
||||
c = mk();
|
||||
c.visible = true;
|
||||
c.crownAnchor = 466;
|
||||
c.onCrownScroll({ scrollTop: 466 + 40 }); // one notch "down"
|
||||
c.onCrownScroll({ scrollTop: 466 });
|
||||
assert.equal(c.queue.length, 1, 'one turn queued after one crown notch');
|
||||
assert.equal(c.crownAnchor, 466, 'scroller re-centered');
|
||||
assert.equal(JSON.stringify(c.queue[0]), JSON.stringify({ x: 0, y: 1 }), 'right-facing snake turned clockwise = down');
|
||||
c.onCrownScroll({ scrollTop: 466 - 120 }); // three notches back
|
||||
assert.equal(c.queue.length, 2, 'queue capped at 2');
|
||||
assert.equal(c.dir.x, 1, 'no reversal emitted, x unchanged');
|
||||
assert.equal(c.dir.y, 0, 'no reversal emitted, y unchanged');
|
||||
c.onCrownScroll({ scrollTop: 466 });
|
||||
c.tick();
|
||||
assert.equal(JSON.stringify(c.dir), JSON.stringify({ x: 0, y: 1 }), 'first queued turn consumed');
|
||||
|
||||
console.log('PAGE WIRING PASS (textures, movement, turn, reversal, game over, restart, directives, crown scroll)');
|
||||
|
||||
Reference in New Issue
Block a user