v0.6: real PNG textures (head with eyes, scaled body, corners, tapering tails, apple, board); renderPieces classifier + tests

This commit is contained in:
2026-09-09 22:06:09 +01:00
parent 4e39e1912a
commit eacad97240
24 changed files with 179 additions and 30 deletions
+9 -5
View File
@@ -25,10 +25,11 @@ function mk() {
let c = mk();
assert.equal(c.model.length, 3, 'initialized to length 3');
assert.equal(c.snake.length, 3, 'rendered 3 segments');
assert.equal(c.snake[0].cls, 'seg head', 'head flagged');
assert.equal(c.snake[1].cls, 'seg', 'body flagged');
assert.match(c.snake[0].src, /head_e\.png$/, 'head texture');
assert.match(c.snake[1].src, /body_h\.png$/, 'body texture');
assert.match(c.snake[2].src, /tail_w\.png$/, 'tail texture');
assert.equal(c.scoreText, 'SCORE 0');
assert.equal(c.snake[0].left, (73 + 6 * 20 + 1) + 'px', 'head x mapped to px');
assert.equal(c.snake[0].left, (73 + 6 * 20) + 'px', 'head x mapped to px');
for (let i = 0; i < 5; i++) c.tick();
assert.equal(c.model[0].x, 11, 'head moved right 5 steps from x=6');
@@ -39,6 +40,7 @@ c.tick();
assert.equal(c.dir.x, 0, 'dir x');
assert.equal(c.dir.y, 1, 'direction turned down');
assert.equal(c.model[0].y, 8, 'head moved down');
assert.match(c.snake[0].src, /head_s\.png$/, 'head faces south after turn');
c.onSwipe({ direction: 'up' });
c.tick();
@@ -57,11 +59,13 @@ assert.equal(c.over, false);
assert.equal(c.model.length, 3);
assert.equal(c.scoreText, 'SCORE 0');
// template uses documented directives/events, no transforms, no crown remnants
// template uses image components for textures + documented directives/events
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.doesNotMatch(ux, /crownrotationchanged/i);
assert.doesNotMatch(ux, /transform\s*:/);
console.log('PAGE WIRING PASS (movement, turn, reversal, game over, restart, directives)');
console.log('PAGE WIRING PASS (textures, movement, turn, reversal, game over, restart, directives)');