That’s no spreadsheet… that’s a game engine!

That's No Moon. It's a Space Station

When I give a talk or meet someone new, I usually find myself using a line that makes it sound like I’m in some kind of support group:

“Hi, I’m Tyler. I make spreadsheets for fun.”

I always say it with a twinge of guilt, because I know I’m not supposed to enjoy spreadsheets the way I do. They’re tools, used for managing your finances, or sorting customer data, or cataloging large swathes of information in one go. It’s not supposed to be fun.

And, perhaps, that’s why I’m drawn to it. As a person with very few instincts that would be called “rebellious”, turning a spreadsheet into something fun is my own small act of revolution, in an otherwise milquetoast life of office computing.

I should start with an example: towards the start of this year, I was (as many of us were) working from home, bored, looking for a way to pass the time between Zoom meetings. I started poking around for those mindless office games we all used to play, like Solitaire or Minesweeper. Not finding any versions I liked, and figuring that installing games on my work laptop would look “unproductive”, I opted to make my own.

I’m a decent enough programmer, and could have opened up something like PICO-8 to whip up something that would sate my office ennui in a few hours (after, most likely, a lot of StackOverflow searches). But what was right in front of me, a part of that same job that I was supposed to be paying attention to, was Google Sheets. I was using it to track some Very Boring Metrics (VBMs) at the time, but the tools were all there: it could make squares, it had checkboxes to click, and I could get it to track where I’d clicked to see if a “mine” was there. With a little bit of conditional formatting, a game suddenly emerged, where once there was only business.

Minesweeper in a spreadsheet
My own version of Minesweeper running in Google Sheets

(If you’d like to learn more about that specific project, you can check out my step-by-step instructions.)

Why would you do this?

Getting one over on “the man” is only one of the benefits of making a game in a spreadsheet. It’s also a great, low-cost way to prototype a game idea, or find a new way to think about a particular mechanic.

For example, a while back I wanted to learn more about how chess games process valid moves, and the constrictions of a spreadsheet forced me to think about the order in which operations took place, in addition to the operations themselves. You can play the result and read my full write-up all in Google Sheets. Thanks to starting that process with a spreadsheet, I have a better understanding of what pitfalls to avoid, what functions I can simplify, and what benefits a more robust programming language might afford me. Whereas if I had started with something like Lua or Python, my penchant for feature creep might have taken me down unnecessary rabbit holes, and prevented the project from getting finished.

Chess in a spreadsheet
Chess in a spreadsheet

It’s also a great way to learn about how fundamental video game mechanics can boil down to simple math, such as plotting a player’s position as they move, or adjusting a character’s attributes (health, stamina, etc.) when something else happens. One of my favorite party tricks is whipping out a game of Snake in under 10 minutes (you can tell I’m great at parties), to show the basics of transposing a game concept onto a spreadsheet. (You can check out a copy of that spreadsheet here.)

Lastly, and this is the big one for me, it’s fun. Deciding to make a spreadsheet do something it wasn’t designed to do is like creating—then solving—a 50,000-piece jigsaw puzzle. Working within the constraints of a spreadsheet scratches the same itch as hands-on crafts (I’m an on-again-off-again crochet and chainmail hobbyist), while stretching the same muscles as programming or playing an intense puzzle game. Then even if the end result is totally useless, I can feel satisfied knowing that I solved something complex and weird. And, (so far) I’ve never felt like that time was wasted.

How do I get started?

I’m so glad you asked! The first step would be to pick which spreadsheet app you’d like to use—my weapon of choice is Google Sheets, but I’ve seen similar approaches taken in Microsoft Excel, Apple Numbers, or web apps like Smartsheet or Rows. To make a game in a spreadsheet, you’re going to need three things:

  1. Something to click on

Games rely on interaction, and spreadsheets usually give us at least one option for that besides manually entering text and numbers. Google Sheets, for example, has checkboxes that can be turned off and on (and turned into buttons with a little trickery), or apps like Excel let you create buttons that trigger formulas and macros.

Adding something clickable to your spreadsheet helps bring it a little closer to what most players will recognize as a video game, and create a more intuitive experience for them. So even though they won’t have seen Frogger in a spreadsheet before, they’ll probably have a good idea of how to start playing.

Frogger in a spreadsheet
Frogger in a spreadsheet
  1. Circular referencing

When moving a character left or right on a screen, what you’re typically doing is adjusting their position along the X axis by a certain amount. In most cases, if you dig into the code of a game, you’ll see that each object has its own “X” and “Y” values, which get adjusted any time that object needs to move. If I wanted a character to walk to the right, for example, I might write a function like this, which tells them to add 1 to their current X position while I press the right arrow on my keyboard:

actor.onKeyPress("right", {
this.x = this.x + 1;
});

In spreadsheets, it’s sometimes difficult to achieve the same result, because cells will actively resist adjusting their own values. That process is called “circular referencing”, and a spreadsheet will usually disable it by default, because things can get really messy if it happens by accident (adding your quarterly budget to itself by mistake, for instance).

Example “Circular Dependency” error in Google Sheets
Example “Circular Dependency” error in Google Sheets

To check to see if your spreadsheet supports circular referencing, start a new spreadsheet and head to cell A1. There, type in =A1+1 and see what happens! If you’re in Google Sheets, you’ll get some instructions to turn it on, otherwise you might get a recommendation for what to try instead. Rows, for instance, doesn’t support circular references, but does have an interesting “EXECUTE” command to help make up for it.

With circular referencing turned on, you can now have cells that keep track of your character’s X and Y coordinates (and a myriad of other things), which update themselves when needed. Example: If you have a checkbox in cell C3 which a player can click to move their character to the right, the cell that stores the X value (let’s say it’s cell A1) can look like this:

=IF(C3=TRUE,A1+1,A1)

That’s saying that if the conditions are met (clicking the button), increase this cell’s current value by one. Otherwise, leave it as-is. Now you’ve got the start of a game!

  1. Conditional formatting

This last thing is, if I’m being honest, completely optional. But it is nice.

When you change the background or font color in a cell, that’s formatting. Conditional formatting allows you to change the look and feel of a cell dynamically based on its content, or the content of other cells. That lets you gesture at information without having to show all of the behind-the-scenes numbers, making your game much more approachable.

One last example, then I’m done: when I experimented with making a turn-based strategy game a-la Into the Breach, I used conditional formatting to show where each character was on an 8-by-8 grid.

“Spreadsheet Tactics” running in Google Sheets
“Spreadsheet Tactics” running in Google Sheets

There, I’m using checkboxes to let the player select which piece they want to move, and which space to move them to. Because a cell with a checkbox can only have a value of “TRUE” or “FALSE”, I use conditional formatting to display other information to the player, such as where the friendly (blue) and enemy (red) characters are, where the enemies are targeting (light red), and where the selected character can move to (light blue). All of that information is actually calculated in other cells that I’ve hidden from the player, but conditional formatting lets me gesture to it in a way that players who have seen a turn-based strategy game before will understand.

Conditional formatting can also do things like hide text until it needs to be displayed, or help create the illusion of movement. While games like Rogue prove that graphics aren’t strictly necessary, I highly recommend taking advantage of the feature if you have it.

What else can spreadsheets do?

Turns out, the answer is “quite a bit!” While spreadsheets come with some constraints that you wouldn’t see in game engines like Unity or Unreal Engine, the capabilities go far beyond tracking your expenses.

If you’re interested in seeing other games and weird uses for spreadsheets, you can check out my portfolio, which is, yes, a spreadsheet.

Happy spreadsheeting. ?

Tyler Robertson

Tyler Robertson is a writer and maker based in London, England. When he’s not writing about automation or pushing spreadsheets to their limits, he can be found roaming the English countryside with this partner and their miniature dachshund. You can follow him on Twitter for more of both: @aTylerRobertson

Follow me
Tyler Robertson is a writer and maker based in London, England. When he’s not writing about automation or pushing spreadsheets to their limits, he can be found roaming the English countryside with this partner and their miniature dachshund.
Follow me
Latest posts by Tyler Robertson (see all)

Be the first to comment

Leave a Reply

Your email address will not be published.


*