2D Sprite Engine


2D layered sprite engine for a never-finished action RPG. The engine was written in Python with the help of PyGame, and the map editor/animation viewer was written in C#.

The project began as a simple tile-based engine, but a strict grid and tile size felt too restrictive. Since fixed-size tilesets weren't necessary for performance, the engine was rewritten to simply render layers of arbitrarily-sized and placed tiles. The alpha layer for each bitmap contained metadata for collision detection, etc., and the tiles even supported animation (for things like water).

Sample level featuring layered sprites and animated characters

A level editor was written for the game in C#. It was modeled after a basic tile editor, and intended to be intuitive and easy to use for anyone who had worked on a fixed-tile game, but allowed the grid size used for snapping to resized at any time. This allowed multiple tilesets of different sizes to be used seamlessly together in the same scene, and special objects like trees, characters, etc, could be precisely positioned on or off the grid.

Screenshot from level editor

The tiles themselves were described in metadata files which defined "sets" of tiles. Each set could be composed of tiles from one or more images, and after loading only the relevant sections of each referenced image were retained in memory. This ensured that an artist could easily create a "set" of related tiles to be used together without worrying about performance beyond the number of unique tiles in a given set (and the number of sets used in a given map).