Sunday, June 22, 2014

The Three Stones Game

"The Three Stones" is an OpenGL game I have developed. The player needs to align three tiles of the same color horizontally or vertically to score.
You can download the source code here.
The executable to run the game is Exe\TheThreeStones.exe

The following is a technical description of the game

1- Technical features

The main technical features implemented in the game are:

1-Memory management:
- Overload of new and delete operators (Code\Mem\MemTracker.cpp)
- Overload std::allocator to be used by STL container (Code\Mem\allocator.h)
- Implementation of a memory tracker to detect possible memory leaks (Code\Mem\MemTracker.cpp)
- Use of Boost::smart_ptr library

2-Delayed functions execution:
Some functions should not be executed when they are called. They are registered for later execution. This is implemented through the structure DelayedFunctionInfo (Code\ObjectsManager.h)

3-Vertex animation used in Encouragement class (Code\Graphic\Anim.*)
In the figure below, the Envouragement class is showing the animated “wow” text with the player scoring a high score.

4-The Score class (Code\Score.*) uses interpolation along a quadratic-polynomial-curvy path (inspired from the Uniform B-Spline curve) to move the score from the squares that created it to the score rectangle.
The following figure shows the paths crossed by three scores. 

5-Finite state machine:
Implemented in Game, Board and Tile classes.

2- Overview

Overview of the main elements in the game:

Game class contains the different phases of the game, implemented using finite state machine (see chart below).
It contains and manages a board, a score, a time counter and an encouragement object.

The board class contains 64 tiles. Each tile can be one of 5 types (colors)

ObjectsManager is a class that calls Update and Draw functions of Object class. The main classes of the game are derived from Object class.

Objects contained between and activeobjectstail.prev are updated and drawn.
Those contained between and activeobjects.prev are drawn only. This allows the board, tiles, score and time counter to be drawn in a frozen state when the intro, the count down and the time out objects are in the front.

3- Compiling the game

- Boost library is needed to compile the game.
- The game was compiled and tested in Microsoft VS 2010 Express and VS 2012

4- Class diagrams

4.1- Object class

The following is the class diagram showing the relation between Object class and some main classes in the game :

4.2- Sprite class

The following is the class diagram showing the relation between Object and Sprite classes and some main classes in the game :

5- The Game's finite state machine

The different phases of the game are implemented in the Game class

6- The Board's finite state machine

The board's states are determined by the behavior of the tiles.
Here are the states of the Board object:

7- The Tile's finite state machine

Here are the states of a Tile object :