Pong - first to seven
One board, two paddles, one ball. You against the machine: return the ball, outlast the AI, and take seven points first. Easy, medium and hard set the pace. The whole game is one compiled island.
The game is one compiled island - a signal-positioned paddle on each side, a ball that bounces off walls and paddles, and a loop started by the space bar or a tap on the court. Open it in the playground: it loads as a sample, compiles on the server, and runs in a sandboxed preview.
One board, pure signals
No game engine, no effects, no lifecycle. The AI paddle is a pure function of the ball's position - and the whole game is an ordinary marisjs island.
signal() positions
Each paddle and the ball is a plain signal; one repaint per frame updates only the elements that moved.
Handler-started loop
requestAnimationFrame begins on the space bar or a tap on the court, with separate timers for the ball and the AI paddle.
Buffered input
W/S or arrows on a keyboard, swipes on the board - every input writes to the same signal.
A reactive opponent
The AI paddle tracks the ball at a speed set by the level - easy, medium, or hard. Nothing else changes.
Competitive by design
You race a live opponent on one shared board. First to seven points wins the match - level sets the pace.
Fair failures
No random deaths. You lose a point when the ball passes you - then the rally restarts with the space bar.
Runs inside the playground
Load it as a sample: the workbench compiles it on the server and runs it in a sandboxed iframe - source to live game, with fullscreen.
No framework on the page
One 5 KB runtime, inlined at compile time. The game is an island - the rest of the page stays static HTML.