-
Notifications
You must be signed in to change notification settings - Fork 0
Overview
Blit Engine is a complete 2D game development framework for ModuOS, built on top of NodGL.
Blit is a high-level game framework that makes creating 2D games easy:
- 🎨 Entity/Sprite System - Manage game objects easily
- 🕹️ Input Handling - Simple keyboard and mouse support
- 💥 Collision Detection - Built-in collision helpers
- 🧮 Math Utilities - Random numbers, distance, clamping
- ⚡ GPU Accelerated - Uses NodGL for fast rendering
Blit Engine is located in the EXTERNAL/ directory as an independent project:
EXTERNAL/Blit/
├── include/ - Header files (Blit.h, BlitStudio.h)
├── src/ - Engine source code
├── tools/ - BlitStudio visual editor
├── examples/ - Example games
├── docs/ - Complete documentation
├── build/ - Build output
├── Makefile - Build system
└── build.sh - Build script
cd EXTERNAL/Blit
./build.sh allThis builds:
- libBlit.a - The engine library
- blitstudio.sqr - Visual level editor
- 4 example games - Shooter, Pong, Platformer, Breakout
./build.sh installInstalls Blit system-wide for use in all projects.
#include "Blit.h"
#include "libc.h"
int md_main(long argc, char **argv) {
BlitEngine engine;
blit_init(&engine);
Sprite *player = blit_sprite_create_circle(&engine, 16, 0xFF00FF00);
int x = 100, y = 100;
while (blit_is_running(&engine)) {
blit_update_input(&engine);
if (blit_key_down(&engine, KEY_W)) y -= 3;
if (blit_key_down(&engine, KEY_S)) y += 3;
if (blit_key_down(&engine, KEY_A)) x -= 3;
if (blit_key_down(&engine, KEY_D)) x += 3;
blit_begin_frame(&engine, 0xFF000000);
blit_sprite_draw(&engine, player, x, y);
blit_end_frame(&engine);
}
blit_sprite_free(&engine, player);
blit_shutdown(&engine);
return 0;
}# After installation
gcc -I include -c mygame.c -o mygame.o
ld -T userland/user.ld mygame.o userland/libBlit.a \
userland/lib_NodGL.a userland/libc.a -o mygame.sqr
# Or directly from EXTERNAL
gcc -I EXTERNAL/Blit/include -I include -c mygame.c -o mygame.o
ld -T userland/user.ld mygame.o EXTERNAL/Blit/build/libBlit.a \
userland/lib_NodGL.a userland/libc.a -o mygame.sqrBlitStudio is a visual level editor for creating games without code!
cd EXTERNAL/Blit/build
./blitstudio.sqr- Visual Editing - Click to place, drag to move objects
- Grid System - Snap objects to grid for perfect alignment
- Multiple Modes - SELECT, ENTITY, COLLISION, TEST
- Save/Load - Persistent level files
- Export Code - Generate C code from levels
| Key | Action |
|---|---|
| TAB | Cycle modes |
| F1 | Toggle help |
| G | Toggle grid |
| Ctrl+S | Save level |
| Ctrl+O | Load level |
| Ctrl+E | Export as C |
| DELETE | Delete selected |
| ESC | Exit |
Complete documentation is in EXTERNAL/Blit/docs/:
- README.md - Project overview
- INSTALL.md - Installation guide
- Getting-Started.md - First steps
- Introduction.md - What is Blit?
- Core-Concepts.md - Entities, sprites, game loop
- API-Reference.md - Complete API
- BlitStudio.md - Editor manual
Four complete example games included:
Space shooter with bullets, enemies, and scoring.
Classic pong - player vs CPU with AI.
Jump and run game with platforms and coins.
Brick-breaking paddle game.
All source code in EXTERNAL/Blit/examples/
blit_init(&engine); // Initialize
blit_shutdown(&engine); // Cleanup
blit_update_input(&engine); // Update input
blit_begin_frame(&engine, color); // Start frame
blit_end_frame(&engine); // Present frame
blit_is_running(&engine); // Check if runningSprite* blit_sprite_create_color(&engine, w, h, color);
Sprite* blit_sprite_create_circle(&engine, radius, color);
Sprite* blit_sprite_create(&engine, w, h, pixels);
void blit_sprite_draw(&engine, sprite, x, y);
void blit_sprite_free(&engine, sprite);Entity* blit_entity_create(x, y, w, h, sprite);
void blit_entity_update(entity);
void blit_entity_draw(&engine, entity);
int blit_entity_collides(e1, e2);
int blit_entity_on_screen(&engine, entity);
void blit_entity_clamp_to_screen(&engine, entity);
void blit_entity_free(entity);void blit_draw_rect(&engine, x, y, w, h, color);
void blit_draw_rect_outline(&engine, x, y, w, h, color, thickness);
void blit_draw_line(&engine, x0, y0, x1, y1, color, thickness);
void blit_draw_circle(&engine, cx, cy, radius, color);
void blit_draw_text(&engine, text, x, y, color);int blit_key_down(&engine, KEY_W);
int blit_key_pressed(&engine, KEY_SPACE);
int blit_mouse_down(&engine, MOUSE_LEFT);
int blit_mouse_clicked(&engine, MOUSE_LEFT);int blit_rects_overlap(x1, y1, w1, h1, x2, y2, w2, h2);
int blit_point_in_rect(px, py, rx, ry, rw, rh);
float blit_distance(x1, y1, x2, y2);
float blit_clamp(value, min, max);
int blit_random_int(min, max);
float blit_random_float();To integrate Blit into the main ModuOS build system, add to your main Makefile:
# Build Blit Engine
.PHONY: blit
blit:
$(MAKE) -C EXTERNAL/Blit all
$(MAKE) -C EXTERNAL/Blit install
# Add as dependency to userland apps
userland_apps: blitThen Blit will be built automatically with ModuOS!
- ✅ Make 2D games quickly
- ✅ Use high-level game objects (entities, sprites)
- ✅ Have built-in collision detection
- ✅ Focus on gameplay, not rendering details
- ✅ Prototype games rapidly
- ⚙️ Full control over rendering
- ⚙️ Custom graphics effects
- ⚙️ Non-game graphics applications
- ⚙️ Maximum performance tuning
| Feature | NodGL | Blit Engine |
|---|---|---|
| Level | Low | High |
| Purpose | Graphics API | Game Framework |
| Entities | Manual | Built-in |
| Collision | DIY | Built-in |
| Input | Manual events | Simple functions |
| Learning Curve | Moderate | Easy |
| Best For | Graphics apps | 2D games |
Want to improve Blit Engine?
- Add new features
- Create more examples
- Improve BlitStudio
- Write tutorials
- Report bugs
See EXTERNAL/Blit/README.md for details.
Blit Engine is part of ModuOS and licensed under GPL v2.0.
Ready to make games? Head to EXTERNAL/Blit/ and run ./build.sh all! 🚀
See also:
- NodGL Documentation - The graphics API Blit uses
- Graphics and Games - Complete overview