Free 2D graphics engine with raster effects for retro/classic style game development
Tilengine 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.
The recommended way to get prebuilt binaries ready to install, run and test samples is grabbing them from official itch.io download. Just download the package for your platform, they contain required dependencies to run.
You can also build the library from source. Tilengine requires SDL2
and libpng
to build, you must provide these libraries yourself depending on your target platform.
You must provide development libraries:
Put the following files inside the src
directory:
Path | Files |
---|---|
src\libpng |
libpng headers |
src\libpng\$(Platform) |
libpng.lib import library |
src\sdl\SDL2 |
SDL2 headers |
src\sdl\lib\$(Platform) |
SDL2.lib import library |
NOTE: If you’re having problems setting up these dependencies, you can download them already pre-packaged from itch.io downloads, file is windows_libs.zip
. It contains headers and libraries for both 32 and 64 bit platforms.
Just install standard packages libpng-dev
and libsdl2-dev
Tilengine depends on having SDL2 in Framework format installed on your system. Homebrew port won’t work. Download the latest dmg here: https://github.com/libsdl-org/SDL/releases.
C samples are located in Tilengine/samples
folder. To build them you need the gcc compiler suite, and/or Visual C++ in windows.
Once installed, open a console window in the C samples folder and type the suitable command depending on your platform:
> mingw32-make
> make
The following actions can be done in the created window:
The following section shows how to create from scratch and execute a simple tilengine application that does the following:
Create a file called test.c
in Tilengine/samples
folder, and type the following code:
#include "Tilengine.h"
void main(void) {
TLN_Tilemap foreground;
TLN_Init (400, 240, 1, 0, 0);
foreground = TLN_LoadTilemap ("assets/sonic/Sonic_md_fg1.tmx", NULL);
TLN_SetLayerTilemap (0, foreground);
TLN_CreateWindow (NULL, 0);
while (TLN_ProcessWindow()) {
TLN_DrawFrame (0);
}
TLN_DeleteTilemap (foreground);
TLN_Deinit ();
}
Now the program must be built to produce an executable. Open a console window in the C samples folder and type the suitable command for your platform:
> gcc test.c -o test.exe -I"../include" ../lib/Win32/Tilengine.dll
> test.exe
> gcc test.c -o test -lTilengine -lm
> ./test
> gcc test.c -o test "/usr/local/lib/Tilengine.dylib" -lm
> ./test
Doxygen-based documentation and API reference can be found in the following link:
http://www.tilengine.org/doc
Tilengine is just a programming library that doesn’t come with any editor, but the files it loads are made with standard open-source tools. Samples come bundled with several ready-to-use assets, but these are the tools you’ll need to edit or create new ones:
To create a package with all the assets, the add-on tool ResourcePacker must be used. It’s a Windows command-line tool that creates packages with files keeping the same directory structure. Tilengine has built-in support for loading assets from these packages just as if they still were stand-alone files.
There are bindings to use Tilengine from several programming languages:
Language | Binding |
---|---|
C/C++ | Native support, no binding required |
Python | PyTilengine |
C# | CsTilengine |
C# | CsTilenginePure |
Pascal | PascalTileEngine |
FreeBasic | FBTilengine |
Java | JTilengine |
Rust | tilengine-sys |
LuaJIT | tilengine_libretro (libretro core) |
Ring | RingTilengine |
Nim | nim-tilengine |
V | V-Tilengine |
Go | gotilengine |
Zig | zigtilengine |
D | dtilengine |
Odin | odintilengine |
Odin | odin-tilengine |
These kind users contributed to tilengine:
@turric4an - the Pascal wrapper
@davideGiovannini - help with the Linux-x86_64 port
@shayneoneill - help with the OS X port
@adtennant - provided cmake and pkg-config support
@tvasenin - improved C# binding
@tyoungjr - LUA/FFI binding
@vonhoff - provided CsTilenginePure binding
@system64MC - provided bindings for Nim an V