What it is
A battle scene printed with letters and symbols. A red, winged dragon of the European kind hovers beside a hill. On the hilltop a knight sits on his horse under a banner, with foot soldiers and their spears spread down the slope. The whole scene is a small 3D model that turns slowly, and every part of it is drawn as text: # and @ for the dragon’s lit scales, / and X for its wing membranes, ^ for grass and spear points.
The dragon is alive in the model, not a fixed picture. Its wings beat, its tail and neck sway, and its head drops to aim when it breathes.
It reacts to you
| What you do | What happens |
|---|---|
| Click or tap the dragon | It lowers its head, opens its jaw and sweeps a stream of fire from one side of the hill to the other and back. The soldiers duck. |
| Click or tap the knight, the banner or a soldier | The army shouts “HOLD THE HILL!”, the soldiers jump and shake their spears, and a volley of arrows flies at the dragon. |
| Drag left or right | The scene turns, with a little momentum. |
| Do nothing | The dragon breathes fire by itself every 12 to 22 seconds. |
| Press Sound | Turns on a roar for the fire and two horn notes for the war cry (off by default). |
The two buttons under the scene, Dragon fire and War cry, do the same as the clicks.
How the clicks know what you hit
While the page prints the characters, it also notes for every cell what is drawn there: nothing, the army or the dragon. A click looks up that note for the cell under the pointer and its neighbours. Because the note is made after depth sorting, you can only hit what you can actually see: if the dragon’s wing is in front of the banner, the click goes to the dragon.
How to take it
Press Download the HTML file above to get ascii-dragon-battle.html, or press Copy the code and save it as a file ending in .html. It is one file with no libraries and works offline.
View the code
Loading…Embed it on your page
<iframe src="https://aspect.tools/ascii-dragon" style="border:0;width:100%;max-width:860px;aspect-ratio:860/830" title="The Dragon and the Hill in ASCII" loading="lazy"></iframe>
License and credit
The Dragon and the Hill in ASCII, 2026 series, by aspect.tools (https://aspect.tools/ascii-dragon-battle), MIT License
A visible credit is appreciated but not required.
How to change it
| What to change | Where | Example |
|---|---|---|
| The words on screen | BANNER and CRY | var CRY = 'H O L D T H E H I L L !'; |
| Dragon colours and characters | the mat('dragon'...), mat('wing'...) and mat('belly'...) lines | mat('dragon', 60, 160, 90) for a green dragon |
| Where the dragon hovers | DR: x, height, z | DR = { x: 22, y: 26, z: 0 } |
| The knight | the KNIGHT text picture: each letter is one block | '.....rkkl....' |
| Number and place of soldiers | the SOLDIERS list of positions | [-4, 7] |
| Shape of the hill | hillY | 12 * Math.exp(...) |
| Length and width of the fire sweep | BREATH (seconds) and SWEEP (how far to each side) | BREATH = 3.2, SWEEP = 26 |
| How often the dragon attacks by itself | the line that sets nextBreath | 12 + Math.random() * 10 |
Questions
What can I click?
Click the dragon to make it breathe fire. Click the knight, the banner or any soldier to make the army shout and shoot arrows.
Is the dragon a fixed drawing?
No. It is a 3D model rebuilt on every frame, so the wings beat, the tail sways and the head moves, and it looks right from every side.
Can I change the dragon to another colour?
Yes. Change the red, green and blue numbers on the dragon, wing and belly lines near the top of the script.
Can I use it in my own project?
Yes. It is under the MIT License for personal and commercial use. Keep the license notice inside the file.
Does it work on phones?
Yes. Tap instead of clicking, and drag with a finger to turn the scene.