• 7 Day Roguelike 2017: Consumables

    I added many features today, most notably consumable items that can be used while stationary in the field to repair the engine or replace a burst tyre. These items can be bought from the shop in the survivor camp. The shop also sells repairs that happen immediately.

    Zombies are now dumber, and the game can handle many more of them. The game had noticeable delays between turns when there were more than 30 enemies on a map. Profiling revealed most of the time being spent in the zombie pathfinding code. Each zombie was performing a search to find the shortest path to the player. This was wasteful, and could be made much faster using dijkstra maps, where a map describing the shortest path from each cell to the player is computed once, and used by all NPCs. In the interest of time however, I made the zombies simply walk to wards the player if they know where the player is. This means zombies will now bump into obstacles as they move towards the player, which is appropriate behaviour for zombies. The game can now handle hundreds of zombies with no noticeable slowdown.

    Various other minor changes:

    • The contents of the shop is now randomized each time you enter the survivor camp.
    • The chance to encounter the more difficult enemies (cars and bikes) goes up as the game progresses.
    • The current amount of money owned by the player appears on the hud.
    • The hud is now visible in menus in the survivor camp.
    • I added flavour text to the camp explaining that the player is healed and paid when entering the camp. This should also help establish the game's (minimal) story.
    • The message log is now cleared between delivery runs.
    • Driving into barrels causes them to explode.
  • 7 Day Roguelike 2017: Procgen and Explosions

    Today I implemented a procedural generator. Levels are relatively simple, compared to say, dungeons. Levels have a straight road, with acid generated using Perlin Noise, and various enemies, obstacles and items placed randomly, with different probabilities for each entity starting in a cell for road cells and off-road cells.

    Here's a screenshot from a procedurally generated level.


    The other big feature I added today is explosive barrels. Barrels explode when shot, or hit by an explosion from another barrel, allowing chain reactions of barrel explosions.


    Explosive barrels made it possible for characters to die on their turn, by accidentally shooting a barrel which explodes and kills them. This is a case that the turn schedule did not consider, leading to an interesting bug. This was only revealed by a particular sequence of events in a generated level, so reproducing the bug required generating the same level.

    Fortunately, when the game starts it prints its RNG seed, and allows an RNG seed to be specified as a command line argument, so it was easy to repeat the same game while debugging this problem. Thank you past self!

  • 7 Day Roguelike 2017: Mechanics and Descriptions

    Today I implemented lots of small mechanics to add some depth to gameplay. I also added descriptions to many actions which are printed in the message log.


    Health is now broken up into hit points, engine health, tyres and armour. When getting shot, if there is armour, there is a 1/(armour + 1) chance for the armour to deflect the damage. If this check fails, the armour value is decremented. If there's no armour, either the hit points, engine health, or tyres will be decremented. The choice of which of these to decrease is random, with the chance of a stat being decreased depending on the current value of that stat (ie. higher stats are more likely to be decreased than lower stats).

    Driving through acid now has a chance to destroy a tyre. When steering (moving up and down the screen), there's now a chance that it will fail. The more tyres you have, the greater chance of success. If the van has all its tyres, success is guaranteed.

    The maximum speed is half the engine health (rounding up). I'm yet to implement damaging collisions with obstacles. I plan to make these damage the engine. It's possible for your engine to be destroyed and get stuck. To reconcile this I plan on allowing the player to repair the van while it's stopped, and making take several turns, so it won't be done lightly.

    The van can collect letters from the level. Currently this just increments a counter. The plan is for these to increase the reward received upon completing a level.

    I added barrels, but am yet to make them explosive.

    For all combat actions (being shot or rammed by vehicles, or clawed by zombies), I added descriptions which are printed on the message log when the action takes place. I also added some messages when failing to turn, failing to accelerate, and when a tyre is dissolved by acid.

  • 7 Day Roguelike 2017: Vehicles

    Today I added cars and motorbikes. Cars are equipped with shotguns and can shoot to the left and right. Bikes are equipped with a pistol and can shoot in all directions.


    The AI for cars and bikes is relatively simple. On their turn, vehicles try to align themselves with the player, and get within range of the player, so that they can shoot them on their next turn. If a vehicle is already appropriately lined up, then they shoot at the player.

    Navigating around obstacles while also attempting to get within range of the player and line up a shot is a much harder problem. In the interest of time, I allow NPC vehicles to collide with obstacles. When I get around to implementing damaging collisions, I'll give NPC vehicles a chance to avoid damage. Narratively speaking, cars and bikes are much smaller than the delivery van, so they have a chance to stop in time before colliding with an obstacle.

    I also spent some time polishing the UI. I increased the size of tiles, and display fewer tiles. The message log is now just a single line. There are also extra gauges, which replace the health gauge. These are currently just for show, but I plan on implementing engine and tyre health, and armour, which will replace the single health bar for the player.

    The most interesting bug was when an NPC vehicle ran over a zombie, the vehicle would stop forever. They were still taking their turn, but all movement was being cancelled. The culprit was the interaction of two rules:

    • when an entity would start a sequence of moves, begin the moves only if they aren't already performing a sequence of moves
    • when an NPC would move into a cell containing another NPC, cancel the move

    The NPC vehicle moved into a zombie as part of a sequence of moves, which were cancelled because it collided with another NPC. Since the sequence of moves was never completed, the component signifying that a sequence of moves is in progress was never removed from the NPC vehicle, so all subsequent times it attempted a sequence of moves, it never started moving as it still had the previous sequence. The fix involved removing the current sequence of moves when colliding with an NPC, and ignoring any existing sequence of moves when starting a new sequence.