{#- The homepage after its features: the rhythm games made with xnano, then the example that runs in the browser, which content.html takes from docs/index.md. -#} {#- Four rhythm games made with xnano, each one a program in examples/, recorded in Kitty by scripts/docs_assets.py. A tab shows each one. #} {%- set rhythm_games = [ {"name": "circles", "title": "Circles", "file": "01_rhythm_circles.py", "play": "Click each ring as the timing ring closes on it.", "alt": "A rhythm game in the terminal: numbered rings appear, a timing ring closes on each one, and each click on the beat scores"}, {"name": "drums", "title": "Drums", "file": "02_rhythm_drums.py", "play": "Press the keys of each note as it reaches the drum.", "alt": "A rhythm game in the terminal: two kinds of notes scroll to a drum on the left, and each key press on the beat scores"}, {"name": "catch", "title": "Catch", "file": "03_rhythm_catch.py", "play": "Move the basket under each note before it lands.", "alt": "A rhythm game in the terminal: notes fall in time with the music, and a basket moves to catch them"}, {"name": "lanes", "title": "Lanes", "file": "04_rhythm_lanes.py", "play": "Press the key of each lane as its note reaches the line.", "alt": "A rhythm game in the terminal: notes fall down four lanes to a line, and each key press on the beat scores"}, ] %}
03 Rhythm games

Four rhythm games. Each game is a program in examples/.

Each game keeps time with the clock of the canvas, reads the keyboard or the mouse, and plays its notes. Select a tab to watch a game.

{%- for game in rhythm_games %} {%- endfor %}
{%- for game in rhythm_games %}
{{ game.alt }} {{ game.alt }}

{{ game.play }} examples/{{ game.file }}

{%- endfor %}
{#- The example of docs/index.md, which runs in the browser: until a visitor runs it, its output panel shows the saved output that data-xn-preview names. #}
04 In your browser

A program you can change and run on this page.

A canvas from xnano.new() draws into memory, so it needs no terminal. This program writes a sparkline and a gauge on a canvas, then prints the frame. It runs the same way in a terminal.

{{ hero_example | safe }}
Change the code, then press Run. The first run loads Python into this page. This takes a few seconds.