Last year, I decided that it was time to build my first video game. While I have a ton of experience building websites, a video game was an entirely different beast. The challenges are considerably different. Instead of browser compatibility, the focus is on platform and OS differences. There’s no notion of frontend and backend (unless you deal with online play). You can’t just launch a game and fix it with time, the first impression matters considerably more than with a website. Marketing is also extremely crucial. With a videogame, you need to build up the hype, whereas a website grows gradually post-launch. The amount of friction to use a website is also considerably less than having to download a game from an Appstore.

I launched Pizza The Pie for iOS in December. While doing a post-mortem of the game’s development, I decided to see where I spent the most amount of effort. While the split between coding and graphics was fairly even, a deeper dive into the programming revealed some interesting information.

My analysis was done after version 1.2 was released, this added iPad support which also meant that I was now allowing for both portrait and landscape orientations. I categorized everything into the following buckets:

Core (Gameplay and Events) Levels (and Level Criteria) Data (Saving and Loading) Screens (Screens, Popups and UI) Themes (Backgrounds, Music, and Sound effects)

Core and Gameplay

One of my primary goals while working on Pizza The Pie was to make sure that the gameplay was as simple as possible. There were a few rules that I set in stone from the very beginning and that I always made sure to adhere to. There would always be three toppings per slice, each pizza would have exactly 6 slices, and the game could be played with one hand on touchscreens.

Pizza The Pie is fairly simple. There are toppings that fall from the sky. You need to spin the pizza so that the toppings form a pizza slice that matches one from the orders menu. Of course, this would get repetitive so I had to add a few extra elements to make the game more dynamic — bonuses, combos, timers, and bombs to name a few. Some of these are meant to help you out while others cause havoc to your precious pizza slices.

The controls are dead simple too: Rotate the pizza using your finger and double tap the screen to drop the topping quickly. That’s all there is to it. You can play the game and eat a slice of pizza is you so desired.

Levels

There are three modes to select from on the main screen: Story, Endless, and Time Trial. Internally, these are considered levels. While I advertised Pizza The Pie on the AppStore as only having these three game modes, the reality is that there are actually closer to 8 different ways to play. Story mode has 58 levels split amongst 5 regions. Each region has its own theme and introduces a new gameplay element.

For example, USA adds combos which help clear bad slices while Europe brings in “sour bombs” that drastically change the focus of the game. Like almost every other mobile game out there, each level has three stars that you can get. These criteria to get these stars also changes per level: number of toppings used, time to complete, combos achieved, and so on.

Endless and time trial are actually two modes that are already present in story mode but they are expanded further and have additional features and UI elements.

Saving and loading data

Each world has its own save file and so do both endless and time trial modes. I’m tracking a ton of settings per level and per player. Level settings include the best score, best time, largest combo, number of combos, and how many stars you earned to name a few. Think of player settings as level settings but across the entire game: how many games did you play, total play time, total wins, total losses, total slices completed etc. All this information is stored locally and never shared with anyone. This is purely data needed for Pizza The Pie’s internals to work.

Screens and UI

Without getting into any specifics, here are all the screens that required some form of code to work: the title screen, level select, level detail, victory splash, losing splash, pause menu, tutorials, settings, story, and credits. All of these support both landscape and portrait modes so I need to move certain UI components programmatically. I also take screen size into account when laying out the elements. In addition to screens, there is also a variety of icons that are handled via code. The orders menu, the current score, and the timer to name a few.

Themes

A user can choose their own theme for endless and time trial. In story mode, the themes are pre-selected. There are also various sound effects that play throughout the game based on your actions. Tapping on a button, placing a topping, a bomb exploding etc. All of this is handled by a theme manager, a music manager, and a sound effect manager.

So there you have it. These five major components that make up Pizza The Pie’s code base.

The breakdown

Before beginning to work on Pizza The Pie, my assumption was the following: 85% of the code would be gameplay, 10% screens, and 5% for the rest which I hadn’t really carefully thought out. I was in for a nasty surprise. I had my gameplay mostly done within two months, I expected another month or two for the rest which included art asset creation. The devil is in the details, it took almost nine more months to complete a game.

After reviewing the 7500+ lines of code and 81 c-sharp files (removing all the comments and variable declarations) the code was broken down like so.

Breakdown by lines of code

Conclusion

As I mentioned in my original article, How I built My First Videogame, building a videogame is no easy feat. It’s not necessarily the coding that’s hard — the planning, the time and the dedication that’s required to actually complete and launch the game is arguably more difficult. My advice: keep things simple and overestimate everything. Never did I expect my game to have 7500+ lines of code. The core gameplay doesn’t even represent 40% of the total code base. All the other elements are components are typically taken for granted are actually a huge timesuck. These numbers don’t include the amount of time I spent creating (and recreating) artwork not only the game but for its promotion. The website that I built. The amount of effort put into marketing and research. The press kit. The testing period. Articles like this one.

It was a learning experience and a fun one at that. I don’t know if I’ll ever make another game but I am focused on improving Pizza The Pie further and bringing it to more platforms.

I hope you enjoyed this article and that it helps you in your own quest to build a video game. Clap if you liked it and don’t forget to try out Pizza The Pie on iPhone and iPad.