Welcome back to Let’s Reinvent the Wheel. In this project, we bring the iconic “Doom Fire” animation to life using pure C11, the simplest PPM image format, and mpv as our display engine. If you want to make fire on your terminal with zero dependencies beyond your compiler and a media player, this is the perfect starting point.
What You’ll Learn
In this episode, you will:
- Explore the Doom Fire algorithm and how it works
- Implement a full simulation loop in modern C11
- Use the portable PPM (P6) format to output images frame by frame
- Pipe your animation directly into
mpv
to display it (no windowing or GUI required) - Tweak parameters to create pixel perfect retro effects, or scale up for a modern, high resolution blaze
By the end, you’ll have a pixel fire demo that’s blazing on your screen and ready for further hacks (all of that without touching any graphics libraries).
Project Code
You’ll find the complete source code here: doomfire
How it works:
- Simulate a fire buffer where each pixel’s intensity is updated using random decay and spreading.
- Render each frame as a raw PPM (P6) image, writing directly to stdout.
- Display in real time by piping your program’s output to
mpv
, which interprets the image stream as a video.
To run:
|
No graphics dependencies, no window management - only
mpv
as MVP
Tweak and Expand
- Adjust fire size, scaling, and palette to match your aesthetic.
- Overlay fire onto other images, or add simple alpha blending for cool effects.
- Try increasing the scale factor for a more “blocky” fire, or experiment with different color palettes.
External Resources
If you want to dig deeper, check out these resources:
Stay in the Loop
Have questions or ideas for more coding adventures? Drop a comment on the video, or suggest the next project idea you want to reinvent!
Thanks for following along, and until next time. Keep reinventing!