-
Notifications
You must be signed in to change notification settings - Fork 0
Introduction
NtinosTheGamer2324 edited this page Mar 7, 2026
·
1 revision
Blit Engine is a simple but powerful 2D game framework for ModuOS. It's designed to make game development fun and accessible, even for beginners!
Blit Engine is a game development framework that sits on top of NodGL (ModuOS's graphics API). While NodGL gives you low-level control over graphics, Blit Engine provides high-level game-making tools:
- 🎮 Entity System - Easy game object management
- 🎨 Sprite System - Simple image/texture handling
- 🕹️ Input System - Mouse & keyboard made easy
- 💥 Collision Detection - Built-in collision helpers
- 🧮 Math Utilities - Common game math functions
- ⚡ Performance - Uses NodGL's GPU acceleration
// Lots of setup code
NodGL_Device device;
NodGL_Context ctx;
NodGL_CreateDevice(NodGL_FEATURE_LEVEL_1_0, &device, &ctx, NULL);
// Manual input handling
int queue_fd = open("/dev/event0", 0);
event_t ev;
// ... dozens of lines of event processing ...
// Manual sprite creation
NodGL_TextureDesc desc = {0};
desc.width = 32;
desc.height = 32;
// ... more setup ...
NodGL_Texture tex;
NodGL_CreateTexture(device, &desc, &tex);// Simple setup
Blit Engine engine;
blit_init(&engine);
// Easy input
blit_update_input(&engine);
if (blit_key_down(&engine, KEY_SPACE)) { jump(); }
// Simple sprites
Sprite *player = blit_sprite_create_circle(&engine, 16, 0xFF00FF00);
blit_sprite_draw(&engine, player, x, y);Blit Engine lets you focus on making your game fun, not fighting with APIs!
| Feature | NodGL | Blit Engine |
|---|---|---|
| Purpose | Low-level graphics API | High-level game framework |
| Learning Curve | Moderate | Easy |
| Control | Full control over graphics | Game-focused abstractions |
| Best For | Graphics apps, advanced rendering | Games, quick prototypes |
| Uses | Direct GPU access | Built on top of NodGL |
Think of it this way:
- NodGL = Like DirectX or OpenGL (graphics API)
- Blit Engine = Like Unity 2D or GameMaker (game framework)
Here's a complete bouncing ball game in Blit Engine:
#include "Blit Engine.h"
#include "libc.h"
int md_main(long argc, char **argv) {
Blit Engine engine;
blit_init(&engine);
// Create ball sprite
Sprite *ball = blit_sprite_create_circle(&engine, 20, 0xFFFF0000);
// Ball physics
float x = 100, y = 100;
float vx = 3, vy = 2;
while (blit_is_running(&engine)) {
blit_update_input(&engine);
// Update
x += vx;
y += vy;
// Bounce
if (x < 0 || x > engine.screen_width - 40) vx = -vx;
if (y < 0 || y > engine.screen_height - 40) vy = -vy;
// Draw
blit_begin_frame(&engine, 0xFF000000);
blit_sprite_draw(&engine, ball, (int)x, (int)y);
blit_end_frame(&engine);
}
blit_sprite_free(&engine, ball);
blit_shutdown(&engine);
return 0;
}Just 30 lines for a complete game!
With Blit Engine, you can create:
- Arcade Games - Pong, Breakout, Space Invaders
- Platformers - Mario-style jumping games
- Puzzle Games - Match-3, Tetris, Minesweeper
- Shoot 'em ups - Top-down or side-scrolling shooters
- Strategy Games - Turn-based tactics, tower defense
- Educational Apps - Interactive tutorials, simulations
// Create sprites from colors or pixel data
Sprite *red_square = blit_sprite_create_color(&engine, 32, 32, 0xFFFF0000);
Sprite *blue_ball = blit_sprite_create_circle(&engine, 16, 0xFF0000FF);
// Draw anywhere
blit_sprite_draw(&engine, red_square, 100, 100);// Game objects with position, velocity, and collision
Entity *player = blit_entity_create(100, 100, 32, 32, player_sprite);
player->vx = 5; // Set velocity
blit_entity_update(player); // Auto-moves using velocity
// Easy collision
if (blit_entity_collides(player, enemy)) {
printf("Hit!\n");
}// Keyboard
if (blit_key_pressed(&engine, KEY_SPACE)) fire_weapon();
if (blit_key_down(&engine, KEY_W)) move_up();
// Mouse
int mx = engine.input.mouse_x;
int my = engine.input.mouse_y;
if (blit_mouse_clicked(&engine, MOUSE_LEFT)) shoot();// Shapes
blit_draw_rect(&engine, 10, 10, 100, 50, 0xFFFF0000);
blit_draw_circle(&engine, 200, 200, 30, 0xFF00FF00);
blit_draw_line(&engine, 0, 0, 100, 100, 0xFFFFFFFF, 3);
// Text
blit_draw_text(&engine, "Score: 100", 10, 10, 0xFFFFFFFF);// Rectangle overlap
if (star_rects_overlap(x1, y1, w1, h1, x2, y2, w2, h2)) { /* hit */ }
// Point in rectangle
if (star_point_in_rect(mx, my, button_x, button_y, 100, 50)) { /* clicked */ }// Random numbers
int dice = blit_random_int(1, 6);
float chance = blit_random_float(); // 0.0 to 1.0
// Utilities
float dist = star_distance(x1, y1, x2, y2);
float clamped = star_clamp(value, 0, 100);Ready to make games? Here's your path:
- Getting Started - Your first Blit Engine program
- Core Concepts - Understand the framework
- Tutorial: Catch the Stars - Build your first game
- API Reference - Complete function documentation
- Example Games - Learn from complete games
- ModuOS with NodGL support
- Basic C programming knowledge
- Enthusiasm for making games! 🎮
Blit Engine is part of the ModuOS project and is licensed under GPL v2.0.
Let's make some games! 🚀
Next: Getting Started →