Creating a video game [Part 2]

After deciding that I wanted to develop around the idea of chain reactions, I started to brainstorm about the different kinds of them which I could use. It needed to be usuable in a space limiting, 2 dimensional game environment and not be overly random. As a long time gamer (pseudo) randomness is something I hate in video games (I will probably dedicate an article to that topic in the future).

Narrowing the range of viable reactions

So reactions modeled after nuclear fission and electron avalanches, which I had in mind originally, were sorted out pretty quickly. I also required a type of reaction which was not limited to one direction on a screen. I took a closer look at Conway's Game of Life and its rules. While they are fairly easy to understand on paper I do believe a huge part of its charme originates from the fact that it's pretty hard for an untrained eye to predict what is going to happen. You also have very little visual feedback to precisely influence it. Changing the set of rules would not sufficiently tackle these fundamental problems (from a game perspective) and even if it would, the result would still just be a clone of Conway's idea.

Termination

Also a big factor for this thought process was to find a reliable way of terminating the reaction. I prefere a recursive implementation for a chain reaction because I'm more flexible and less dependend on timers and loops. Also having the opportunity to track back through the reaction path by just adding one line of code is a nice addition. This does mean though, that every single subreaction will reserve a very tiny bit of memory as a callback to its originating method. So if I created a long and quick enough reaction, I would crash due to memory limitations. Yeah, it would have to be an enormously huge reaction, but since I was still in the planning phase I had to consider it as well.

Rotation it is

Since I needed to find a way to keep the reaction going around the very limited 2D space on a phone screen, I started to meditate about rotations and gears. Rotation seemed to be a pretty easily controllable beast. So what would happen if I placed a bunch of gears in a grid and removed all cogs but one for every direction?

The classic Cog-Block scenario... 😉

Well, nothing, because the gears would all block themselves... But since we are in a game, we can get rid off physical limitations. I let all gears rotate 90° clockwise when they were hit. That way I was stuck with an endless reaction. The next logical step for me was to remove more cogs from the gears. Eventually I was left with 2 cogs placed in a 90° degree angle:

I tried out different designs and decided to stick with a quarter arc of a circle. This is a little video demo of the very first prototype. If you look carefully, you can find some bugs where reactions are skipped, etc. Yet it already was a good proof of concept for my idea: