Strategic Game of Life: Mobile Edition

Multithreaded JavaScript has been published with O'Reilly!

Play It

android-win
android-win

android-campaign
android-campaign

android-play
android-play

A Simple Port

Strategic Game of Life: Mobile is a port of Strategic Game of Life, a simple game I made two years ago. The original game had 20k players the first weekend it launched, which for being an entirely desktop web based game was rather impressive.

The premise of the game is rather simple; take Conway's Game of Life (a cellular automata simulation) and add gameplay elements. In the original simulation players are typically given an infinitely large playfield and can toggle any cell on and off, pausing and resuming gameplay as desired (depending on the implementation of course).

In my version there are only certain regions which can be altered, cells outside of the playfield will never live (which has interesting side effects; gliders collide and become 2×2 still lifes, spaceships collide and produce gliders!) There are also cells which need to become alive to win, and cells which lose the game if they become alive.

Challenges

Porting a game from desktop to mobile was more than just a technical challenge. It may not be immediately obvious but all the level designs needed to be changed. Originally all levels were 64×64, now they all needed to be smaller than 24x24. Even so, some levels will be difficult to play on smaller phones (such as the iPhone 5).

My biggest goal with this project was to figure out the pipeline for building web-based games which will run everywhere. I used Cordova to build the mobile binaries. Another goal is that the Web/FirefoxOS version doesn't include cordova.js (I wanted them to be pure), so I had to do a few of my own API abstractions.

I also didn't want the app to be too large, so I stripped out jQuery halfway through the development. Ultimately it didn't matter too much as the audio files are ~12MB. Re-learning DOM interaction and breaking a several-year crutch did feel pretty nice though ;)

Earlier versions used Hammer.js for zooming game fields and panning, but this ultimately was difficult to implement and inconsistent between browsers, so I stripped it out and reduced all level sizes.

To Do

This game isn't 100% complete yet. Today I fixed a bug where Analytics weren't being sent off from within Cordova (web versions worked fine).

The audio system needs an overhaul to work with Cordova on iOS. Currently it uses

Once that last bit of functionality has been added I'll clean up the gulp build tasks a bit, polish the application structure, strip out audio, flatten repo, change from the Module pattern to using Browserify, and then open source it! This won't be so much a “library” that you can hook into, but a skeleton you can copy and paste and use as a starting point.

Thomas Hunter II Avatar

Thomas has contributed to dozens of enterprise Node.js services and has worked for a company dedicated to securing Node.js. He has spoken at several conferences on Node.js and JavaScript and is an O'Reilly published author.