🚧
This article is a work-in-progress. If you are interested in more details feel free to contact me at [email protected]

Siege is a tower defense style game. The player is presented with a map which they may modify by placing defensive towers or deploying troops to attack the enemy. The goal of the game is to prevent enemy troops from reaching your castle whilst simultaneously attacking the enemy castle with your troops.

Map Design

LAVA

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

CASTLE

WALL

Tile

TOWER

Tile

Tile

Tile

Tile

TOWER

Tile

CASTLE

WALL

Tile

 

                                PATH

Tile

 

PLAYER

CASTLE

 

Tile

Tile

 

ENEMY

CASTLE

CASTLE

WALL

Tile

Tile

Tile

TOWER

TOWER

Tile

Tile

Tile

CASTLE

WALL

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

Tile

LAVA

Data Serialization

To implement game saving/loading there will need to be an efficient way of serializing dynamic objects. A node-based system will be implemented, an example of how data will be stored can be seen in Figure 15.

Figure 15 - A hierarchical view of a node based file storage system

The way this system works is that objects are broken down into their simplest form and then stored. If a simple value (Such as a string, integer, character, etc.) is being saved it is simply attached to the root node with a variable name it can be accessed through. However, if an object is being serialized, a new ‘child node’ will be created which will contain its data, this allows for the hierarchy of objects to be maintained through serialization allowing them to be reconstructed when loaded. The objects will need to have pre-defined serializers and deserializers for this to be possible.

Pathfinding

Frontier = new PriorityQueue
VisitedTilesFrom = Map[Tile, Tile]
TileTravelCost = Map[Tile, Integer]

VisitedTilesFrom Add [Start, Start]
TileTravelCost Add [Start, 0]
Queue into Frontier Start
While Frontier is not empty
    SearchTile = Dequeue Frontier
    
    If SearchTile is End
       Break
    End If
    
    For Tile from SearchTile Neighbours
        TravelCost = TileTravelCost[SearchTile] + Tile Weight
      
        If TileTravelCost[Tile] not exists 
              OR TravelCost <  TileTravelCost[Tile]
            TileTravelCost[Tile] = TravelCost
            VisitedTilesFrom[Tile] = [SearchTile]
              
            QueuePriority = TravelCost + Distance from Tile to End
            Queue into Frontier Tile
        End If
    End For
End While

From VisitedTilesFrom calculate route from Start to End

Data Structures

Gameplay

Game Screenshots

The game was designed from a functional viewpoint and much time wasn't given to designing and creating visual assets.