Snake, its rules in Hazel
Hazel activities › One-player games · source on GitHub · hazeljs on npmSteer the snake to the food: the arrow keys (or W A S D), a swipe on the board, or the four buttons. Each meal makes it three cells longer and is 10 points; running into a wall, or into itself, ends the game (unless the walls wrap round, so you come out on the other side). Choose how fast it goes. Each step of the game, and the robot that plays it for you, are Hazel (snake/rules/Snake.hz). ⏸ or the space bar pauses.
This app needs JavaScript, and a page served over http (python3 -m http.server, then localhost).
The vocabulary the module sees (snake/rules/preamble.hz). The listings are text, highlighted, until Edit in Hazel opens each in Hazel's own editor; an edit changes the next step.
loading preamble.hz…
loading Snake.hz…
hazeljs-examples · versions · Apache 2.0 (code), CC BY 4.0 (words, the icon) · by Matthew Hammer · an example for hazeljs