Building Pong as a terminal game with Ink featured image

Building Pong as a terminal game with Ink

December 18, 2024 · 3 min read

What I learned building Pong as a terminal game with Ink, and why the terminal turns out to be a surprisingly fun target for a quick game project.

I’d been writing a lot of CLI tooling with Ink and got curious whether the same component model could carry an actual game. Pong is the obvious starting point: two paddles, a ball, simple collision, no scope for feature creep. A good weekend hack.

The result is tpong on GitHub, runnable with npx tpong. Single-player against an AI paddle by default, or two-player on the same keyboard (arrows for the left paddle, W/S for the right) if you’ve got someone next to you. Difficulty scales as the ball speeds up over time.

tPong running in a terminal: two paddles and a ball rendered in ASCII

Why Ink works for this

Ink is React for the terminal. You write components, manage state with hooks, and Ink handles the diffing and the actual ANSI escape sequences that paint the screen. For something like tpong, that means the game loop is just a useEffect with a setInterval, the paddles and ball are components, and input handling is useInput(). There’s no requestAnimationFrame equivalent and you don’t need one – the terminal isn’t a 60fps target anyway.

The thing I appreciated most: I could prototype the layout in JSX and see exactly what would render. None of the cursor-positioning bookkeeping you’d do if you wrote the same game directly against ANSI. That’s worth a lot for a weekend project where I’m not trying to learn terminal escape codes.


Two-player on one keyboard

Stylized concept art for tPong

The thing that turned out to be the most fun: shipping a two-player mode. Run npx tpong --multiplayer and the game uses arrows for the left paddle and W/S for the right – both on the same keyboard. It’s pong for one laptop and two friends, which feels like exactly the right scope for a terminal game.

The default single-player mode plays you against a simple AI paddle. Both modes share a difficulty curve: ball speed ramps up as the rally length grows, so the game eventually gets you no matter how good you are.


Npx as a distribution channel is underrated

The thing I didn’t expect to find delightful: shipping a terminal game as an npm package means the install story is npx tpong. No download. No app store. No platform-specific build. Anyone with Node installed can play it in five seconds, and the source is right there on GitHub if they want to look at how it works.

This combination – free hosting on GitHub, free distribution through npm, runnable with one command – feels under-explored as a target for small games and toys. It’s not going to replace Steam, but for a weekend hack you want to share, the friction is about as low as it gets.

I’ve since pushed this further with a few more terminal games using the same pattern. If you want to try the original, npx tpong in any terminal will get you a paddle and a ball. The full source is at github.com/gfargo/tpong. If you build something similar with Ink, I’d love to see it.

Griffen Fargo headshot

Griffen Fargo

Published

Share
Keep Reading

Discussion

Have thoughts? Drop them in.

Comments are powered by Disqus. Sign in once, comment anywhere.

Loading comments…
Fin.

griffen.codes

made with 💖 and

© 2026all rights reservedupdated 17 seconds ago