Description
Gameplay
Hardware
Code Overview
AI Pathfinding
Libraries
Attribution
This Zombie survival game is based in a far away, hexagonally shaped world. The objective of the game is to survive long nights and days until help arrives to save you. The player is stranded on an island with lush fields, dense forests and big mountains. There are resources to be mined and fortifications to be built. But watch out, at night, the undead come out of the ground and try to eat you.
The game is completely written in Python, utilizing the PyGame library. The player can be controlled via the mouse or by using the external Nunchuck controller which integrates a LED clock, see below.
- To move your hero around the island, you either use your mouse or the joystick to select adjacent tiles, then press the left mouse button or the Z-key on the nunchuck to move.
- If you want to perform an action, select a tile and press the right mouse button or the C-key on the nunchuck. Depending on the tile, you will either gain resources, build a wall (that becomes very useful against the nightly invaders) or destroy a wall.
- During the night, creepy undead beings will spawn from the ground and try to devour you! Avoid their bites by running away or building barricades to exhaust them.
- The end...? If you manage to survive on this deserted island long enough, a search party will come to your rescue. For now though .. good luck!
For added fun, the game can be played with an external LED clock and Nintendo Wii Nunchuck. The LED clock displays the current time of the day as well as your remaining health. The Nunchuck provides an ergonomic and intuitive gaming interface to play HexZomb. In the images below, the LEDs are blown out, however the day cycle should contain blue skies and a yellow sun, while the night sky has a faint blue glow with a full white moon.
Below you can find a class reference diagram which explains the relations between all classes.
Since the main objective of this project was to incorporate the Algorithms and Artificial Intelligence learned
in the AI Programming course. It was decided to integrate the A* pathfinding algorithm into the Enemy class,
to make them intelligent in following the player.
The algorithm utilizes the distance to the player, the terrain type and possibly the time it takes to destroy obstacles
(such as walls placed by the player) to calculate the most optimal route. Every type of tile has a specific walking speed,
which contributes to the total movement cost of each step. The enemy re-calculates the optimal route at every game tick (movement or action).
Below, the calculated scores of each explored cell can be seen, as well as the final chosen route.
The terrain is generated by utilizing the Perlin Noise library. The communication with the arduino that drives the LED clock and controller is accompliced by using the PySerial library and a custom communication protocol. The Random library is used for randomisation of spawn and animations. Math helps with some of the tougher calculations by having loads of standard functions. The Time library is used for keeping track of game time, as well as calculations regarding the flow of animation frames and updating of the screen. Numpy is used for some heavier calculations and functions that the normal math library does not include. Lastly, the Bisect library is used for some array transformations and sorting.
For this game, the following art and graphics were used:
- Hexagonal tiles: Fantasy Hex tiles by CuddlyClover
- Player and Enemy sprites: Dungeon tileset II by 0x72
- Wood sprite: 16x16 RPG items by Joey de Jong
- Color palette: Linear 8-bit palette by GrafxKid
- Athelas font: Adobe fonts