Tagasi projektide juurde

Townfall – a City-Builder Game Centered Around a Dynamic World

Töös
computer-graphicsgame
Magister·Projekti algus: 30.09.2024·autor: Karl Suurkaev

Lehed

Failid

Implementing Townfall

Technical Aspects

Townfall was implemented using version 6 of the Unity game engine. The game logic was written in C# which is the primary programming language used by Unity.

The game logic’s structure relies heavily on the singleton design pattern. The use of this pattern was chosen since the game’s design was built on a limited number of underlying systems that benefit from being centralized and having easy access to each other without having to interact with each other’s inner workings.

Grid and tilemap.png A screenshot from the Unity editor showcasing an example scene

The in-game world is represented using Unity’s grid and tilemap systems, creating a discrete and two-dimensional functional space. Data for each grid cell is stored in an associative array, where the key to each cell is a vector based on the cell’s coordinates. An associative array was preferred over an indexed array since irregular terrain shapes and the movement of the world would otherwise create many cell data points with no meaningful data.

Each cell contains data for its terrain type, the type of prop which is placed on it, the generation number of when the tile was created, the resources that the tile contains, and a reference to the structure placed on it.

Structure type data.png A screenshot from the Unity editor showcasing a scriptable object used for defining a structure type.

Gameplay logic for structures are represented using Unity’s gameobjects. To be in line with the terrain’s grid-based tilemap, structures’ visual representations are decoupled from the gameobjects. Instead the structures also use the tilemap to represent their physical appearance in the game world. Each structure contains data about its integrity, location and size, harvestable resources and harvest range, special actions, and related upgrades. The data for each type of structure is stored using Unity’s scriptable objects from which the required properties of a structure are read in upon structure instantiation.

Audiovisual Design

The audiovisual assets of Townfall were all purpose-made for the game. The world sprites, structure sprites, interface icons and elements, logo and font, and sound effects were created by the developer. The sprites and logo were created using the Paint.NET image and photo editing software. Sound effects were recorded and edited using the audio editing software Audacity. The font used within the game was created using pentacom’s bitfontmaker2, an online bitmap font editing tool.

Art assets 1.png Example sprites of the waterbed, rock, and tree tiles found in Townfall.

The visual style of Townfall uses minimalistic pixel-art with one grid cell matching the pixel size of 32x16 pixels. Both the world and structures used limited colour palettes to increase style cohesion.

Colour palette.png

Each colour used for structure sprites were limited to three shades to offer capabilities for shading while keeping cohesion with the artstyle. Structures follow a minimalistic medieval style where foundations are made of stone, walls are made of wood, and roofs are made of thatched hay. Structures use varied silhouettes for easier distinction between different types. Structures that serve a similar purpose, such as resource storage, have sprites of similar size to reinforce their similarities in the player’s mind. Assets created using these principles resulted in a simple yet effective minimalistic artstyle.

Art assets 2.png Silhouettes of the Logging Camp and Mining Outpost (left) and resource storage structures (right) from Townfall.

Sound effects in Townfall were made to match events in the game. Each action taken by the player or by the world needed to have a matching sound effect. Sound effects were recorded through Foley and the developer’s vocalizations. Foley examples include rubbing the cardboard center of a toilet roll against a wooden plate to imitate a handsaw, hitting a metal die against a wooden plate to imitate a hammer, and shaking and bashing rocks together to imitate the rumbling of the ground. Methods for editing the sounds included noise removal, layering, pitch shifting, panning, low- and high-pass filtering, and bitcrushing. This resulted in sound effects that matched the low definition visual style of Townfall.