The simplest way to make 2D games in C - Just ONE header file!
- ONE File - Just copy
piper.hto your project - Zero Dependencies - Everything embedded (Windowing, Graphics, Math, Audio, etc.)
- Instant Setup - Drop and code
- Full Featured - Everything you need for 2D games
Download piper.h and put it in your project folder. That's it!
Create main.c:
#define PIPER_IMPLEMENTATION // Defines the implementation (do this in ONE file only)
#define RGFWDEF // Required for windowing
#include "piper.h"
int main() {
InitGame(800, 600, "My Game");
while (!GameShouldClose()) {
BeginFrame();
ClearBackground(COLOR_BLACK);
SetDrawColor(COLOR_GREEN);
DrawCircle(400, 300, 50);
EndFrame();
}
CloseGame();
return 0;
}gcc main.c -o game.exe -lgdi32 -lopengl32 -lwinmm
./game.exeThat's it! No build systems, no package managers, no dependency hell.
Everything you need for 2D games is built-in:
-
Graphics
- Shape drawing (rectangles, circles, triangles, polygons)
- Texture loading & rendering (PNG, JPG, BMP, TGA)
- Transformations (rotation, scaling, tinting)
- 2D camera system
-
Text
- TrueType font rendering
- Custom font loading
- Text measurement
-
Input
- Keyboard (down, pressed, released states)
- Mouse (position, buttons)
-
Math
- Full vector math library (
linmath.hembedded) - Vector2/3/4 operations
- Matrix transformations
- Transform2D helpers
- Full vector math library (
-
Time
- Delta time for frame-independence
- Smooth 60 FPS rendering
- Tutorial - Step-by-step guide
- API Reference - Complete function docs
- Examples - Sample games
| Game | Description | LOC |
|---|---|---|
| Snake | Classic grid-based game | ~180 |
| Breakout | Brick-breaking arcade | ~240 |
| Space Shooter | Top-down shooter | ~220 |
All use ONLY piper.h!
Other frameworks:
- ❌ Dozens of dependencies
- ❌ Complex build systems
- ❌ Hours of setup
- ❌ Version conflicts
Piper:
- ✅ One file
- ✅ Copy & paste
- ✅ 30 seconds to first game
- ✅ No dependency management
ClearBackground(MakeColor(20, 20, 40, 255));
SetDrawColor(COLOR_RED);
DrawCircle(400, 300, 50);
SetDrawColor(COLOR_YELLOW);
DrawRectangle(200, 150, 100, 75);if (IsKeyDown(KEY_W)) playerY -= 200 * GetDeltaTime();
if (IsKeyPressed(KEY_SPACE)) Shoot();
int mx, my;
GetMousePosition(&mx, &my);
if (IsMouseButtonPressed(MOUSE_LEFT)) Click(mx, my);Texture* player = LoadTexture("player.png");
DrawTexture(player, x, y);
DrawTextureEx(player, x, y, 64, 64, rotation, COLOR_WHITE);Vector2 pos, vel;
Vector2Make(pos, 100, 100);
Vector2Make(vel, 5, 0);
vec2_add(pos, pos, vel);
float dist = Vector2Distance(pos, target);File Size: 1.2 MB (28k lines)
Embedded Libraries:
- RGFW - Cross-platform windowing
- rlsw - Software renderer
- linmath.h - Linear algebra
- STB Image - Texture loading
- STB TrueType - Font rendering
All pre-integrated and tested - you don't need to know about any of this!
MIT License - see embedded component licenses in piper.h
- WebAssembly: Port to Emscripten for web builds.
- Hardware Rendering: Optional OpenGL backend for performance.