Tilengine-PSP is the PSP port of Tilengine.
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.
Thanks megamarc for writing such a portable and easy to read code.
- Tilengine-PSP - The 2D retro graphics engine
- Contents
- Features
- Getting binaries
- Running the samples
- The tilengine window
- Creating your first program
- Documentation
- Editing assets
- Creating packages
- Bindings
- Contributors
- Written in portable C (C99)
- MPL 2.0 license: free for any project, including commercial ones, allows 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
- Loads assets from open standard standard file formats
- 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...- Supports packaged assets with optional AES-128 encryption
- offload math tasks to vfpu
- add the special effects (per-column offset, mosaic, per-pixel displacement, CRT emulation)
- change graphics renderer from SDL1.2 to sceGU
You can also build the library from source. Tilengine-PSP requires SDL1.2
and libpng
to build.
make -f Makefile.psp
C samples for the PSP are located in Tilengine/psp_samples
folder. To build them you need the pspsdk.
Once installed, open a console window in the C samples folder and type
> make
The following section shows how to create from scratch and execute a simple tilengine application that does the following:
- Setup the PSP exit callback.
- Reference the inclusion of Tilengine module
- Initialize the engine with a resolution of 480x272, one layer, no sprites and no palette animations
- Load a tilemap, the asset that contains background layer data
- Attach the loaded tilemap to the allocated background layer
- Create a display window with default parameters
- Run the window loop, updating the display at each iteration until the window is closed
- Release allocated resources
Create a file called test.c
in Tilengine/psp_samples
folder, and type the following code:
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <pspgu.h>
#include <pspgum.h>
#include <pspge.h>
#include "Tilengine.h"
PSP_MODULE_INFO("Example", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
int main(int argc, char* argv[])
{
setupExitCallback ();
TLN_Tilemap foreground;
TLN_Init (480, 272, 1, 0, 0);
TLN_SetLoadPath ("assets/sonic");
foreground = TLN_LoadTilemap ("assets/sonic/Sonic_md_fg1.tmx", NULL);
TLN_SetLayerTilemap (0, foreground);
TLN_CreateWindow (NULL, 0);
while (isRunning ())
{
TLN_DrawFrame (0);
}
TLN_DeleteTilemap (foreground);
TLN_Deinit ();
sceKernelExitGame ();
return 0;
}
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:
- Source code: VSCode, Notepad++...
- Graphics, tiles & sprites: Aseprite, Piskel, Grafx2...
- Maps: Tiled Map Editor
These people 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
This repository contains sprites from the Mario and Sonic series for use in its examples. The use of these sprites is strictly intended for educational purposes, and no infringement is intended upon the original copyright holders. If the use of these sprites is in violation of the copyright holders' wishes, we will remove any offending assets upon request.