Pinball, its physics in Hazel
Hazel activities › Physics simulation · source on GitHub · hazeljs on npmTen boards, each a piece of Hazel data: its walls, bumpers, flippers, portals and lamps. Many have chambers with flippers of their own, whose gutters drop to the chamber below: every left flipper moves with ⬅️, every right one with ➡️. Every frame, a Hazel program moves the ball: gravity, then the walls, the bumpers and the flippers it meets, and the portals, which hold it a moment before it comes out. Launch it soft, mid or full (the 1, 2, 3 keys), or hold 🚀 (or ↓) and let go, the longer the harder. The flippers are ⬅️ and ➡️, or the ← and → keys (or Z and /), or a tap on the table: on a paddle, or anywhere on its side. A ball lost within 8 seconds of its launch comes back, once; light every lamp in a row to make it blink. Three balls a game. ⏸ 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 (pinball/rules/preamble.hz). The listings are text, highlighted, until Edit in Hazel opens each in Hazel's own editor; an edit changes the next frame (interpreted, so slower).
loading preamble.hz…
loading Pinball.hz…
hazeljs-examples · versions · Apache 2.0 (code), CC BY 4.0 (words, the icon) · by Matthew Hammer · an example for hazeljs