Skip to content

Single-header 2D game framework for C. Zero dependencies, instant setup - just copy piper.h and start coding. Complete graphics, input, math & asset loading in one 1.2MB file.

License

Notifications You must be signed in to change notification settings

Rottenbff/piper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Piper - Single-Header 2D Game Framework

The simplest way to make 2D games in C - Just ONE header file!

Version License Platform Size

The Ultimate Simple Framework

  • ONE File - Just copy piper.h to your project
  • Zero Dependencies - Everything embedded (Windowing, Graphics, Math, Audio, etc.)
  • Instant Setup - Drop and code
  • Full Featured - Everything you need for 2D games

Quickest Start Ever

1. Copy ONE File

Download piper.h and put it in your project folder. That's it!

2. Write Code

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;
}

3. Compile

gcc main.c -o game.exe -lgdi32 -lopengl32 -lwinmm
./game.exe

That's it! No build systems, no package managers, no dependency hell.

Features

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.h embedded)
    • Vector2/3/4 operations
    • Matrix transformations
    • Transform2D helpers
  • Time

    • Delta time for frame-independence
    • Smooth 60 FPS rendering

Learn More

Example Games Included

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!

Why Piper?

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

Quick Examples

Drawing Shapes

ClearBackground(MakeColor(20, 20, 40, 255));

SetDrawColor(COLOR_RED);
DrawCircle(400, 300, 50);

SetDrawColor(COLOR_YELLOW);
DrawRectangle(200, 150, 100, 75);

Handling Input

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);

Using Textures

Texture* player = LoadTexture("player.png");
DrawTexture(player, x, y);
DrawTextureEx(player, x, y, 64, 64, rotation, COLOR_WHITE);

Vector Math

Vector2 pos, vel;
Vector2Make(pos, 100, 100);
Vector2Make(vel, 5, 0);

vec2_add(pos, pos, vel);
float dist = Vector2Distance(pos, target);

Technical Details

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!

License

MIT License - see embedded component licenses in piper.h

  • WebAssembly: Port to Emscripten for web builds.
  • Hardware Rendering: Optional OpenGL backend for performance.

About

Single-header 2D game framework for C. Zero dependencies, instant setup - just copy piper.h and start coding. Complete graphics, input, math & asset loading in one 1.2MB file.

Topics

Resources

License

Stars

Watchers

Forks

Languages