Files
vela-snake/README.md
T

4.9 KiB
Raw Blame History

SNAKE — Xiaomi Watch S4

Textured Snake on a 16×16 grid: 20px tiles, 320px board, centered on a round 466px screen. Existing PNG board, directional snake pieces, apple and icon are preserved. Package identity: com.ilias.snake.

Version 0.7 (versionCode 7): locally tested and release-built; the new features still need an on-watch check. Earlier versions rendered and played on the user's Watch S4 41mm. Node tests and numeric layout checks are not device tests.

Play

  • Swipe to steer. A two-turn queue accepts rapid corners, consumes one turn per tick, and rejects duplicate directions and reversals against the last queued direction. Excess inputs are ignored, not allowed to replace a turn.
  • Tap the board, snake or apple to pause. Tap RESUME (or an exposed part of the board) to resume. Pausing clears queued turns.
  • In the pause or game-over panel, select CLASSIC (walls end the run) or WRAP (cross an edge to appear on the opposite edge). Changing mode starts a fresh, paused game; tap RESUME to begin. Selecting the current mode does not reset the run. The current mode is shown below the board.
  • Both modes end on self-collision. Moving into the vacating tail is legal.
  • PLAY AGAIN is a large 216×56px retry target. Retry keeps the selected mode, resets score/speed/queued turns, and starts playing. Filling the board displays YOU WIN and hides the apple safely.
  • Leaving the page pauses it and stops the timer. Returning requires an explicit resume; game-over never resumes automatically. The system back action remains untouched. No crown, rotary, side-button or back interception APIs are used.

Score, speed and persistence

Each apple is one point. The always-visible header shows score and best. One best score is shared across Classic and Wrap, saved through documented @system.storage under snake.best. Mode is session-only; a newly created page defaults to Classic.

The movement interval starts at 300ms, decreases by 10ms per apple, and never goes below 120ms. Only one movement timer runs; none runs while hidden, paused, finished or destroyed. Old timer callbacks are invalidated.

Storage reads merge with the in-memory maximum; writes wait for the initial read and are serialized/coalesced so slow callbacks cannot overwrite a newer record. The coordinator survives page recreation within the module lifetime. Invalid saved values are ignored. Errors/exceptions do not interrupt gameplay: failed reads/writes retry on later apples or page-show activity, without a retry loop. A failed/uncompleted write or immediate app termination may lose the unsaved record. Storage persistence still needs verification on the watch.

Lightweight rendering

Directional PNG tiles use only left/top positioning, no transforms or new art assets. Wrapped neighbors are normalized before classifying seam textures. Food placement takes at most 256 cell checks, including a nearly full board. The HUD, footer, board and overlay fit the circular chord numerically with at least an 8px total horizontal safety allowance.

Build and test

npm ci
npm test
npm run release

npm test runs the original core, piece and page tests, 13 incremental upgrade regressions, the numeric layout suite, and deterministic randomized property tests. Upgrade coverage includes rapid swipes, lifecycle/timer races, storage failures and async ordering, mode changes, all four Wrap edges, seam textures, full-board victory and bounded food spawning. New behaviors were exercised through failing-then-passing test cycles.

Release output: dist/com.ilias.snake.release.0.7.rpk. The locked aiot-toolkit 2.0.5 uses the existing sign/private.pem and sign/certificate.pem; do not regenerate or commit those keys. Release uses plain JS (not JSC/protobuf), matching the previously working toolchain. The dependency lock is unchanged; npm ci currently reports 14 development-toolchain audit findings (3 low, 11 high). No forced toolkit upgrade was applied.

Files

  • src/pages/index/index.ux: round-screen UI, swipe queue, game/lifecycle state.
  • src/common/snake.js: movement, collision, Wrap piece classification, food.
  • src/common/best.js: asynchronous storage coordinator.
  • src/common/tex/: preserved textured artwork.
  • tests/{snake,pieces,page,upgrade,layout,properties}.cjs: Node regression suites.

Install the signed RPK through AstroBox. Source/releases live at https://gitea.oimcloud.myaddr.tools/codex-bot/vela-snake — publication is a separate step after review; a local build is not evidence of a published release.

Earlier versions

  • 0.2/0.3: board played on watch; designWidth 480→466 fixed undersizing.
  • 0.6: directional textured tiles and preserved user-supplied icon.
  • 0.7: queued swipes, live/persisted records, capped acceleration, pause/resume, lifecycle safety, retry/win panels and selectable Classic/Wrap.