Fairy2D is a highly modularised 2.5-dimensional game engine written in C++. It was my MSc degree's final project, and still living...

Fairy2D Project

Fairy2D Game Engine Logo

The Fairy2D Game Engine

Fairy2D is a highly modularised 2.5-dimensional game engine written in C++.

Since I finished the module “Games Software Engineering”, I found that there is a lot of fun to develop a game engine of my own. I can try different structures and design patterns to build the engine. The Fairy2D project was the “Project and Dissertation” of my master degree.

Currently, this project is still underdevelopment.

 

Key Features

1. Using Sprite Sheets

The game engine using sprite sheets for animated sprites. A sprite sheet and its describing file generate by TexturePacker. The game engine will load the texture and read each frame’s coordinate data as a single frame. And then the user will be able to group those frames into an animation sequence which the animated sprite need to play by.

The Sprite Sheet looks like this:

Sprite sheet example (Megaman Zero)

And the description file looks like this (it published as an XML file):

<SubTexture name="zero_idle_loop_00" x="36" y="108" width="36" height="42" frameX="-49" frameY="-42" frameWidth="128" frameHeight="128"/>
<SubTexture name="zero_idle_loop_01" x="0" y="108" width="36" height="42" frameX="-49" frameY="-42" frameWidth="128" frameHeight="128"/>
<SubTexture name="zero_idle_loop_02" x="448" y="78" width="36" height="42" frameX="-49" frameY="-42" frameWidth="128" frameHeight="128"/>
...

2. Automatic Memory Management

There is many useful “tools” come with the game engine. Normally, users just need to invoke the singleton of each tools to help their game development, such as “Scene Manager”, “Texture Manager”, “Physics Manager” and so on.

Some of those managers have resources management functions. For example, the “Texture Manager” can automatically release all loaded textures when the engine shut down; the “Actor Manager” (for tweening animation controlling and  management) will destroy unused actors automatically.

 

3. Embedded Box2D Physics Engine

In Box2D engine, a physics object contains several components. Basically, A physics object created by the Box2D “World” and stored as a “Body” which may contains a number of “Fixtures”, and each “Fixture” has its own “Shape” and relationships with other “Fixtures”.

The game engine managing Box2D physics components for each physics object into one single object, and it also has some useful stuff such as “Debug Draw” within. The “Physics Manager” will manage those for users, just easy and clear.

 

4. Tweening (Animating) Objects

For each supported type of nodes, such as “Sprites” and “Solid Colour”, contains a pointer for a Tweening object names “Actor”. By using “Actor Manager” you can assign an “Actor” for a supported node. You can also assign multiple nodes into a single “Actor” to animate all of them with same animation, for example, group fade in/fade out.

Here is an example of tweening:

An example of tweening animation

By setting this animation, all you need to do is:

1. Assign an “Actor” for this sprite “Star” using “Actor Manager”;

2. Order the actor do alpha changing from 0.5f to 1.0f, in 1.0f second;

3. Order the actor move from (0.0f, 0.0f, 0.0f) to (5.0f, 0.0f, 1.0f), in 1.0f second;

4. Order the actor rotate from (0.0f, 0.0f, 0.0f) to (0.0f, 0.0f, 360.0f), in 1.0f second;

5. Let the actor play.

It will then playing the animation just like the figure above (in 6 fps). It depends on how fast your application is going to run — faster, more update steps, and much more smooth animation.

 

SDKs

I used a number of SDKs for Fairy2D game engine. These awesome SDKs provide a faster and better development environment. Here is the list of used SDKs:

OpenGL (for graphics rendering);

SDL (Simple DirectMedia Layer, for timer/user input/window events);

Box2D (as physics engine);

FreeImage (dealing compressed images);

FreeType 2 (as font engine, rendering TrueType fonts);

irrKlang (as sound engine);

TinyXML (as XML parser).

 

Structures

Currently I just got an out-of-date figure shown below. However, it pointed out some of my idea to build this engine. I might re-design a new figure if I got time — the engine now has been slightly changed.

Fairy2D System Structure

Games built on Fairy2D

Depends on the feedback of the game built on that engine, it has many possible ways to improve the engine. We can find problems and improvement possibilities from instances.

Recently, I just rebuilt my previous project on Fairy2D with huge amount improvements. Currently, it has a playable tutorial level to introduce the game and demonstrate the engine. I uploaded both the game program and an demonstration video. You can whatever downloading to play it, or just watch the video I provided. Personally, I suggest watch the video first, because it has an audio commentary which explained a lot of features; and then download the program and try this game out. I hope you guys will enjoy it!

 

Introduction Video (with audio commentary)

This is Fairy2D Game Engine Demonstration on YouTube (720p HD available):

This is Fairy2D Game Engine Demonstration on Vimeo (720p HD available):

I also uploaded the video to my website, you can download it by right click –> save to/save as/download linked file/etc.
Fairy2D Game Engine Demonstration (1280 x 720 HD, 121 MB)

(It was encoded in H.264, if your cannot play it on your computer, you might try to download the encoder from http://www.h264info.com/downloads.html)

Download Fairy2D Game Demo (Win32)

Local (rolloliu.com): Fairy2D_Game_Demo.zip