Author Archives: admin

Devlog – Every Event Needs a Queue

Sow the seeds of an ultimate score rush combo in Flower Plower!

Before adding exciting gameplay features an important question has to be answered:

How do game objects talk to each other?

One of the most important goals of software design is to reduce coupling.

Coupling occurs when the actions of one system depend on the state of another. If two objects are coupled then making changes one could result in a bug in the other. As the game grows in complexity this can lead to frustrating hours reading stack traces.

Ideally the components of the game should know nothing about each other. The tractor should have no idea what a flower is, how gravity ties it to the road or what strange force is compelling it to change direction. The tractor should sit in isolation just doing whatever tractors do.

If all the components are completely separate then how does the system handle interactions between them? How does the tractor tell the game that it just harvested a flower and scored a point if it doesn’t know what a flower is or even that its performance as a tractor is being evaluated?

This is where Software Design Patterns come in handy. This problem of code getting hairy when components meet has been suffered and studied for a long time. Some smart people have identified the problems that happen most frequently and come up with some template solutions that can solve them.

For this project I went with the Event Queue:

The specifics of my Unity implementation are somewhat different but it has the following features:

  • An Event Queue component can be added to any object and stores a list of events that happened on that frame – the list is cleared during LateUpdate (So technically it’s the events that happened last frame).
  • Objects can read or post events using an Event Queue Accessor component. The accessor component stores a reference to the event queue and actively checks rather than being notified by the queue.
  • The Event Queue does not store a reference to Event Accessor components so it will not keep them alive if they are destroyed. The accessors need to have their reference to the queue set when they are cloned at run time.

An example of how I have used it in Flower Plower would be the detection of the tractor colliding with the flower. Both these objects have a parent called ‘Farm’ with an event queue.

When the flower collider detects a collision with a harvester it puts a ‘Flower Harvested’ event on the farm’s queue. The Score and Audio system don’t need to know the specifics of the collision but they can check the farm’s event queue to find out what’s going on on the farm.

It’s a powerful idea that the Flower and Tractor can do their thing without having to report to any component except to say ‘This Happened’ to the event manager it makes it possible to combine modules in various ways. E.g. the same Tractor that is used for player control could be used in a game demo system.

It took a lot of work to prototype this important system but hopefully it will work well throughout the rest of the development.

As a reward for making it through that wall of text here’s a bonus video of some integration tests running!

Just look at those glorious green ticks.

Each test starts the game and goes through the menus before doing their thing so any weird edge-cases will be caught! My last game Spacebomb has some glitches that can make the player totally invincible so I’d like to avoid that this time.

Devlog – Progressive Regression

Flower Plower is an arcade maze runner where you use a tractor to plant and harvest flowers. Score enough points and you can create new areas on the map. Shape the layout of the maze to maximize your combos and achieve high scores. Just don’t run over your sheep!


Progress is coming along nicely on the prototype version of flower plower.

The basic mechanics of driving a tractor around planting and harvesting flowers are in place as this high quality but low file-size webm video will show

Recording videos and producing good quality web-friendly videos has been a learning curve. The current process is as follows:

  1. Record the screen using Open Broadcaster Software
  2. Edit the video using Power Director
  3. Convert to the video to webm using FFMPEG (My version of Power Director does not support webm).

It’s a slow process but it works!

Regression Testing

There’s currently a bug that occurs when the player changes direction when between two tiles.

As part of my new commitment to following some sort of Software Engineering practice I decided to make a test to re-create the bug before even attempting to fix it:

I had to redesign the input handling so that it would be possible to control the tractor via test scripts. The code is a lot stronger as a result!

I used the Command Pattern to encapsulate any calls to Unity’s Input methods. It helps reduce coupling and now it’s possible to create some sort of replay system if I decide to.

Creating a test that recreates the bug before attempting to fix it is a nice way to approach the problem as it gives you a chance to figure out exactly what the problem is before poking in code.

Unity’s Test Runner is great for executing testings from within the editor. It’s satisfying to watch all the tests run…

Devlog – Adventures in Pathfinding

I am currently prototyping a new game that works a lot like Pac Man except you’re a farmer planting and harvesting flowers.

The finer details of the game are still to be worked out. The first prototype had an open grid of squares and the player was able to move freely in any direction.

Flower Plower Prototype

An open grid did not work well with Pac Man style controls.

This approach did not work due to how the movement system works. The player’s tractor moves continuously in a straight line but is only allowed to turn when it is in the centre of a tile. Turning felt unresponsive if the player turned between tiles.

As a solution I decided to try mazes with long corridors. I wanted a maze that would start small but grow into a large maze as the player progressed.

Starting Maze

The maze starts with 1 square and grows as the player scores points.

After dusting of the old Data Structures and Algorithms textbooks I thought that a good approach would be to use a graph data structure. I put together a simple implementation using C# that I’ll share on GitHub in the future.

One constraint on the grid is that there should always be an Euler Cycle available. This means that it should be able to visit every path in the maze without repeats. The player’s score will scale with big combos of flowers so it’d be nice to always have plenty of scope for long chains without repeats.

The easiest way to accomplish this was to make sure that each node in the grid has 2 or 4 paths as continuous graphs where all nodes have an even number of vertices will always have an Euler cycle.

Maze Extension

The results of applying 1 extension to the grid.

The algorithm for extending the maze is as follows:

  1. Select 2 random degree two nodes. (I.e. Nodes with 2 links.)
  2. Add an extra link to each of these nodes so there are 2 nodes in the graph with 1 link.
  3. While there remains an odd node in the graph: Link it to another odd node.

All being well this method can be used to extend the maze while ensuring there’s an Euler cycle.

Big Maze

A large maze created by repeatedly extending the maze with this algorithm.

When the method works it can generate large mazes with Euler cycles very quickly however it has 2 major disadvantages:

  1. It is complex and error prone: On the plus side I now know how to recover Unity from an infinite loop. On the negative side I put Unity into many infinite loops and chased many frustrating bugs trying to get the thing to work. It would be difficult to further tune the algorithm for varied gameplay.
  2. The mazes aren’t that fun: There’s an infinite variety of mazes but they’re all quite ‘samey’. Playing on random mazes doesn’t seem like it will be terribly engaging.

So while the random maze prototype did not completely pan out it wasn’t a total waste of time. I have a decent graph data structure that can be used to represent levels in future version and some path-finding code that can be used for AI.

Scratch Memory Match

Memory match card game tutorial in progress.

In other news I have a Scratch tutorial in progress detailing how a memory match card game could work.

The Scratch code is nearly complete and I’ll be starting the write-up soon.

AirConsole RTS Devlog – Map Generation

I’m working on a Real Time Strategy game for Air Console. I’m working out the gameplay mechanics before deciding on the theme. There will be a map of nodes with links between them on the screen and players will control the nodes with their personal device and use them to attack other player’s nodes. Each player will see the data on the nodes they control on their controller and any ongoing battles will be displayed on the big screen.

My time so far has mostly been spent setting up my development environment and figuring out how to structure the project. I am using Brackets to write my Javascript and Closure to compile it. While Javascript is an interpreted language using this tool from Google will optimize it.

I have started work on the map generation:

RTS map

The map is a set of nodes with links between them. Nodes can attack other nodes if they are linked. Right now 2 planets are linked together if there are no other planets between them. In future versions I will add more complicated rules to link planets and try to position the planets so they look less like they’re on a grid.

Namespaces and classes in Javascript

I am currently working on a game for Air Console. It’s a cool platform for local multiplayer web games.

So far most of my time has been spent experimenting with HTML5 game frameworks. For this project I have settled on the CreateJS suite. It seems to be functional, minimal and up to date.

I have also been learning a bit more about how to organize a HTML/javascript application. Javascript doesn’t have special keywords for ‘class’ or ‘namespace’. Everything is done using functions, which left me scratching my head and wondering how you’re supposed to manage a large codebase without constantly running into name conflicts.

There were two articles I found helpful. The first is a simple rundown of some common ways to use Javascript’s functions like a class:

The second article explains a slightly more complex concept that allows you to create namespaces within Javascript. This allows you to encapsulate all the variables in your app within a single root var, which helps reduce the chance that one of your variables is defined in another module.

The article features my new favourite piece of technical jargon: Self-executing anonymous function. It’s a phrase that would strike terror in a student’s heart if it appeared at the top of a lecture slide.

Experimenting with AirConsole


AirConsole allows for local multi-player in web games. On a big screen you connect your browser to the AirConsole site and then multiple players can connect their phones or tablets and use them as controllers.

I love local multiplayer games and AirConsole makes it really easy to get a party game going as everyone generally has a phone in their pocket to use as a controller. There’s more info on the AirConsole site:

I’ve started work on a project with AirConsole. I’ve set up my dev environment and got a Hello World program created using a tutorial from Phaser:

You can try the Hello World yourself using my site here:

Tutorial – How to Use a USB Xbox 360 Dance Mat with Windows 10

I have written a tutorial that explains how to set up a USB Xbox 360 Dance Mat to work with Windows 10.

Find the tutorial here:

it’s great for games like Step Mania

Konami DDR Mat

A compatible mat would look something like this.

Maybe in future I’ll make a game designed with dance mats in mind!