Repo of the Day
spinzed/tpong
Published: Aug 31, 2022
Open repository ↗Pong in the terminal with GO... because why not!
Summary
tpong is a terminal-based remake of the classic Atari Pong game written in Go. It renders the game in a terminal using the tcell library and reads keyboard input via the keylogger package. The project targets Linux only and must be run with superuser privileges.
What it is useful for
This repository is useful for engineers interested in terminal graphics, real-time input handling, or building small games in Go. It is a worked example of combining tcell for terminal rendering with keylogger for low-level keyboard event detection on Linux, because standard terminal input APIs do not expose separate press and release events. Engineers building keyboard-driven TUIs that need press/release semantics can study how this code reads from /dev/input/event*.
The game itself is a small but complete interactive application. The README lists two-player local multiplayer, an AI opponent, multiple themes, a start menu, and round pausing. Engineers learning CLI argument parsing in Go can see how go-flags is wired in, with a single --nobg flag that toggles whether the background is hidden (default false). It is also a concise reference for structuring a Go program that mixes a render loop with an input loop and an event-driven menu.
How engineers can use it
The README documents two ways to run it. The first is to fetch and build with go get github.com/spinzed/tpong, then run sudo tpong. The note in the README is that $GOPATH/bin must be on the path, otherwise the binary is only reachable from inside that directory. The alternative is to clone the repository, enter the directory, and run sudo go run ..
In the menus, Enter selects the highlighted action and the up and down arrows scroll. Player 1 uses W and S; player 2 uses the up and down arrows. Space starts a round, P toggles pause, R restarts the round, A toggles the AI, T switches theme, and B toggles the background. The --nobg flag is passed at launch.
Two documented limitations matter in practice: the game works only on Linux because of platform-dependent key detection, and it requires sudo because keylogger reads from /dev/input/event*. For full configuration details, refer to the project's README.