RAT-PONG
I’ve been getting into Rust lately and wanted a small project to get more familiar with the language. I came across ratatui, a terminal UI framework for Rust, and thought it would be fun to build a game with it. Pong seemed like the perfect fit — simple enough to finish in a few sessions, but with enough room to add some polish.
RAT-PONG is a local 2-player Pong game that runs entirely in your terminal. One player uses W/S, the other uses the arrow keys, and you’re off. It runs at 60 FPS so the movement feels smooth, and the play area scales to whatever size your terminal window is.
Features
Beyond the basic Pong gameplay, I added a few visual extras to make it feel a bit more alive:
- Ball trail - a fading trail follows the ball’s path, which can be toggled on and off with T
- Collision sparks - a burst of yellow sparks fires off when the ball hits a paddle
- Render modes - you can switch between block and dot rendering styles on the fly with M
Technical Details
The game is structured into a few modules:
- app.rs handles the main game loop and rendering the UI chrome (score display, borders)
- pong.rs contains all the core game logic — paddle movement, ball physics, collision detection, scoring, and the visual effects
- input.rs maps keyboard events to game actions
The ball physics use simple velocity-based movement, and paddle collisions adjust the ball’s angle based on where it hits the paddle. The spark effects use a TTL (time-to-live) system so they naturally fade out after a short burst.
Cross-platform release builds for Linux, macOS (Intel and Apple Silicon), and Windows are handled automatically via GitHub Actions.