Pinball, its physics in Hazel

Hazel activities › Physics simulation · source on GitHub · hazeljs on npm

Ten 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.

⏳ Loading the rules…
0

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…
Pinball the ten boards as data, and a frame of the game: the flippers turning, then in four small steps gravity, the walls, the bumpers, the flippers and the portals; the drain, and the plunger
loading Pinball.hz…

hazeljs-examples · versions · Apache 2.0 (code), CC BY 4.0 (words, the icon) · by Matthew Hammer · an example for hazeljs