TileDjinn is an open source, cross-platform 2D graphics engine for creating classic/retro games with tile maps, sprites and palettes. Its unique scanline-based rendering algorithm makes raster effects a core feature, a technique used by many games running on real 2D graphics chips.
- TileDjinn - The 2D retro graphics engine
- Contents
- Features
- Getting binaries
- Documentation
- Editing assets
- Written in portable C (C99)
- MPL 2.0 license: free for any project, including commercial ones, allows 79A0 console development
- Cross platform: available builds for Windows (32/64), Linux PC(32/64), Mac OS X and Raspberry Pi
- High performance: all samples run at 60 fps with CRT emulation enabled on a Raspberry Pi 3
- Streamlined, easy to learn API that requires very little lines of code
- Built-in SDL-based windowing for quick tests
- Integrate inside any existing framework as a slave renderer
- Create or modify graphic assets procedurally at run time
- True raster effects: modify render parameters between scanlines
- Background layer scaling and rotation
- Sprite scaling
- Several blending modes for layers and sprites
- Pixel accurate sprite vs sprite and sprite vs layer collision detection
- Special effects: per-column offset, mosaic, per-pixel displacement, CRT emulation...
A static library for windows MSVC /MDd is provided.
You can also build the library from source. TileDjinn requires SDL2
and libpng
to build, you must provide these libraries yourself depending on your target platform.
Just clone the source. The build uses cmake.
Feel free to submit PR's. I'll try to look at them within 7 days. Please understand that my time for managing this project outside my own use is neither infinite nor funded.
Coming soon..
Call TLN_Init
and TLN_CreateWindow
to initialize the engine.
Create palettes based on your platform's constraints using TLN_CreatePalette
. Create a tileset based on your platform's constraints using TLN_CreateTileset
. Create a tile map per layer using TLN_CreateTilemap
.
For my projects, the TileDjinn port's main loop looks something like this:
TLN_Tilemap *tilemaps;
TLN_Tileset tileset;
int main() {
TLN_Init(WIDTH, HEIGHT, MAX_LAYER, 128);
TLN_CreateWindow(NULL, 0);
{
int i;
for (i = 0; i < NUM_PALETTES; ++i) {
TLN_CreatePalette(i, NUM_PALETTES);
}
}
{
int screen;
tileset = TLN_CreateTileset(MAX_TILES, TILE_WIDTH, TILE_HEIGHT, 0);
for (screen = 0; screen < MAX_LAYER; ++screen) {
tilemaps[screen] = TLN_CreateTilemap(32, 32, 0, 0, tileset);
}
}
/* this is semantically wrong, but is the easiest way to re-order the layers in the right direction.. */
TLN_SetLayerTilemap(SCREEN1, tilemaps[SCREEN2]);
TLN_SetLayerTilemap(SCREEN2, tilemaps[SCREEN1]);
game_init(); /* platform independent game initialization */
/* main loop */
while (TLN_ProcessWindow()) {
game_loop(); /* single iteration of the game loop */
TLN_DrawFrame(0);
TLN_WaitRedraw();
}
/* de-init */
{
int i;
for (i = 0; i < MAX_LAYER; ++i) {
TLN_DeleteTilemap(tilemaps[i]);
}
TLN_DeleteTileset(tileset);
for (i = 0; i < NUM_PALETTES; ++i) {
TLN_DeletePalette(i);
}
}
TLN_DeleteWindow();
TLN_Deinit();
}
TileDjinn is just a programming library that doesn't come with any editor, but the files it loads are made with standard tools. Samples come bundled with several ready-to-use assets.
I recommend these tools for development (not referral links):
- Source code: CLion
- Graphics, tiles, sprites, and maps: Cosmigo Pro Motion