Damn the Torpedoes, Full Zebulon Ahead

Game development is definitely taking longer than I’d thought.  I’m not even talking about sourcing visual and audio assets, or fighting with the SDK or debugging code; it’s the endless hours that disappear into getting the right working system in place. Coding patterns for is-a subclasses and has-a relationships, interactions and messaging between systems.. and the refactoring everything because it wasn’t the right approach.

And there’s the top-level conceptual questions, ranging from: “is this game even fun?” to “should I keep a few dozen objects in one screen area, or will we have a giant view area you pinch and swipe across?”


Do you accumulate a currency of “power units” or whatever to spend, or are you just struggling to build objects? Should the player control where each object goes, or do they have a mind of their own?

How should we display the build-status of a planet? The energy-status? As two arcs?


Or should energy be a glow (pulse?) that builds up?

I was feeling pretty down last week (which was week #3). My friends gave me a much-appreciated pep talk, and suggested that I do something I should have done when I started: read Ryan and Chris Campbell’s excellent ongoing narrative about their friendly competition to build two games. (Disclaimer: I had the pleasure of meeting these guys while we were at SurveyMonkey).

Beyond the tips and breakdowns they give for their problems and approach,  it’s such a comfort to see that I’m not alone in this, and yes, it’s hard.

So. As I enter week #4, what should I do?

At this point in time, I need to stop refactoring, I need to stop trying out different gameplay ideas. I just need to finish a working first-draft of the game I had originally set out to build: a graph based tower defense game where units are built and then have an autonomous life of their own. Which works on iPhones (4s and newer) and iPads.

I’m sure I’ll have tons of changes and new ideas after this MVP is wrapped up. But rather than constantly building up and tearing down a myriad of ideas and explorations, I should stay the course.

Zebulon Part 2: Status Update

I’ve been focused on writing my game for a week now, and I’m happy to say that I achieved the (modest) goals I set out in my last post. The artificial deadline approach worked as a motivation!

The wise approach would have been to focus on workshopping the gameplay by starting with crappy graphics targeting one particular device, like an iPhone 6. This would have let me figure out what ideas work, and which ones didn’t.

I took the opposite approach, and instead worked top-down on “first impressions” such that the game would look decent on any iOS device, starting with the launch icon and home screen. While these are just placeholder graphics, being able to have something that looks kind of like a game from the start has the important emotional impact of making me feel like I’m making progress.

Simulator Screen Shot Apr 5, 2016, 12.53.39 PM.png

The home screen was adapted from a vintage sci-fi book cover; I’d love to follow this aesthetic if I can.

Simulator Screen Shot Apr 5, 2016, 12.54.52 PM.png

What’s interesting about the home screen is that different iOS devices have much different resolutions and aspect ratios. The above is an iPad air; for an iPhone 4s, the aspect ratio makes this screen look like:

Simulator Screen Shot Apr 5, 2016, 1.03.15 PM.png

From day 1, I’ve worked to ensure that graphics and elements are scaled to work on any device. I’ve avoided making different graphics specific to different aspect ratios, preferring to scale, position, and clip in code.

For the game itself, I abstractly describe objects in a space that is logically 150 x 100 units. There are nodes (planets) and edges (paths between planets). I wrote a layout engine that  dynamically picks the actual size and position of objects based on the device’s screen.

Simulator Screen Shot Apr 5, 2016, 12.52.52 PM.png

Levels are described in a JSON file, using a 150 x 100 unit layout as e.g.:

    "version": 1,
    "name": "Getting Started",
    "nodes": [
        { "id": 1,
          "x": 0,
          "y": 0,
          "neighbors": [2,4],
          "properties": { "role": "colony"}
        { "id": 2,
          "x": 20,
          "y": 50,
          "neighbors": [1,3,4],
          "properties": { "role": "empty"}

JSON parsing in Swift (or Objective-C) is a bit more work than you’d expect, because the language is typed. The code looks like:

let data = JSONData.dataUsingEncoding(NSUTF8StringEncoding)
let json = try NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments) as! [NSObject:AnyObject]
guard let version = json["version"] as? Int,
    let name = json["name"] as? String,
    let nodes = json["nodes"] as? [[NSObject:AnyObject]] else { return level }

Overall, I thought Spritekit does a great job of making it easy to build event-handling (for clicks), object display, and animation effects. Most of my time was spent on asset-wrangling and getting things to display at the right location and size. Weirdly, the one chunk of code that took me hours to get working properly was to display a texture as grayscale (for when a planet object is disabled). There are a variety of approaches; some lost the alpha channel, and others would simply not properly convert between the different image formats. Here’s the final version which works nicely:

func convertToGrayScale(texture: SKTexture) -> SKTexture {
    let originalImage = texture.CGImage()
    let context = CIContext()
    let inputImage = CIImage(CGImage: originalImage)
    let filter:CIFilter = CIFilter(name: "CIPhotoEffectMono", withInputParameters: [kCIInputImageKey : inputImage])!
    let result = context.createCGImage(filter.outputImage!, fromRect: inputImage.extent)
    return SKTexture(CGImage: result)

I plumbed in a dialog which opens when you click on a planet, so you can change its behavior (this is how you play the game). Nothing fancy here aside from a lot of layout work; though I’m still having a devil of a time getting the side-arrow to work uniformly on all devices.

Simulator Screen Shot Apr 5, 2016, 12.58.41 PM.png

And there you have it! A week of progress. Let’s see how the game is looking next week!