After working with the Torque and ShiVa engines on learning projects and collaborations, I decided to create my own game from scratch. I decided to make a classic arcade-style game where you have to traverse a randomly created map while avoiding being killed by zombies. The core gameplay is:
- Player moves faster than zombies.
- When you shoot or kick a zombie, there is a chance they will die, but not guaranteed.
- If you shoot at a zombie, there is a chance that one or more zombies will spawn.
- Ammo is limited, but you can find more in houses.
- Houses also contain health kits (heals 10 hp) and survivors (heal to full), but may also contain a new zombie.
- When you reach a new level, zombie speed increases, chance of killing a zombie decreases, and chance of new zombies spawning from a gun shot increases.
While tuning, I altered the relative movement speed and camera distance to increase tension. You don’t move fast, and you cannot see very far away. Zombies off screen will head towards you without you knowing, so you have to keep moving, and don’t get caught in a dead end.
To create the random maps, I created a small fenced in area. At the bottom is the player start area. At the top is the finish area.
Next, I created 7 square tiles which each had different connectivity between sides (barriers prevent or allow you to enter on one side and exit on a different side). 9 of these tiles are placed in the playing area above.
If you place tiles randomly, chances are good (about 90%) that the maze will be unsolvable. To get around this problem, I use a recursive algorithm to walk the maze and ensure it can be solved. To avoid doing lots of computation at run time, which is bad for mobile games, I wrote a Python program to randomly generate mazes and then determine which were solvable. Out of 10,000 mazes, about 1,000 worked. The python code is available. The Python script exported the good mazes in a format that I was able to cut and paste into the ShiVa script.
Once the game creates a maze, it randomly spreads zombies around. Each zombie then places a target at the player location and it starts to pathfind to the target. The target is updated every second or so, which gives them a more natural movement. When they are close to the player, they beeline towards the player. In the video below, you can see the yellow targets appearing at the player’s feet. The video is taken in the editor in order to show the enemy pathfinding.
The controls are simple, WASD to move, click to shoot (you will kick if the zombies are close), and spacebar to heal. Most zombies are the same, but if they walk into a fire area, they change to a flaming zombie. Those will have a chance to die every few seconds, but if you are close, you take extra damage.
The game works as designed, but at the time, I was unable to optimize it to run smoothly on a phone, so I did not release it. I used a web version for testing, but it no longer runs after recent browser changes.