nanopython  /  snake

Snake

Classic Snake driven from main.py. Python owns the game state, draws each frame to a canvas through the ADR-006 js bridge, and reads keydown events via addEventListener. JavaScript only boots the wasm.

Loading…

Score0
High0

Arrow keys or WASD to steer. R to restart after game over.

Notes

Grid is 20×20, cell size 20px. Snake is a Python list of (x, y) tuples, head at index 0. The game loop runs in main.py via js.window.setInterval; each tick computes a new head, checks collisions, then redraws the whole board. High score is persisted in localStorage.