It’s rare that gamers ever get to hear the full story behind how (and why) a game was made. So it’s awesome that Derek Yu, the creator of Spelunky, has written a book that does just that.
Published by Boss Fight, Spelunky is Yu’s autobiographical, full-blown account of the making of the game, going very deep into everything from how it was designed to the dynamics of the team working on it. There are even excerpts of the game’s code written out.
Spelunky is out next Tuesday, March 29, and will cost $US5 ($7) (you can get it here). For now, though, here’s an excerpt that covers the process Yu went through taking the original Spelunky and turning it into a HD console game.
Spelunky Classic: “I love the way pixel art looks, but to your average person it simply looks old.” The game we were now making was not a port of Spelunky Classic, but a remake — or, as I called it in the initial design document I sent Microsoft, an “upgrade.” In my head, however, I felt as though I was really making a “fan game” of the original Spelunky. Real fan games aren’t made by the original developers, of course. They’re games made by fans that act as unofficial sequels, remakes, or remixes of existing intellectual property. High-level fan games can take large teams years to make and some come close to matching the quality of the titles that inspired them.
It might seem strange to spend so much time and effort on “just a fan game.” If you’re creative enough to make a professional-grade fan game, why not create your own original game instead? Particularly since the threat of legal action would no longer be hanging overhead.
The reason I think fan games are so popular is that creating an original idea and expanding upon one are such different creative acts. There’s a deep-seated uneasiness about confronting an empty canvas — after every failure, you might end up back at square zero. It takes a lot of failing and false starts to come up with something that works, as shown by the numerous pre-Spelunky prototypes I left behind.
Reimagining an existing game is carefree, though. You’re starting with something tangible that you know works and that you can fall back on when you hit a dead end. That’s partly why even professional artists who have created their own worlds enjoy making fan art. It offers the same kind of bliss as lying in the grass and pointing out what clouds remind you of. I was fortunate in that when I was doing the stressful part of creating Spelunky — developing the initial “Big Bang” of the concept with lots of prototyping — I was shielded from the pressures of making a commercial game. Then, when I was making another commercial game, I was at least free of the pressures of creating an original idea.
I was eager to approach the problem of reimagining the original Spelunky. There was never any question for me that I’d be changing the “pixel art” graphics. I love the way pixel art looks, but to your average person it simply looks old. And technically, it is: Pixel art was originally a product of hardware limitations, not a style in and of itself. Although modern pixel artists still enjoy the challenge of overcoming those limitations, it didn’t seem appropriate for Spelunky’s debut on HD televisions around the world.
Another thing I wanted to change was the movement. In Spelunky Classic, Spelunky Guy has a floaty jump and slippery run that took time to learn how to control. This was exacerbated by the fact that the game is locked to 30 frames per second (FPS), the default setting of Game Maker 8.1. By the time I realised this, changing the FPS would have required large rewrites to the existing code. As a result, Spelunky Classic has some extra choppiness compared to the 60 FPS remake.
I didn’t want the player’s controls to be another hurdle toward getting into the game, so Andy spent a lot of time tweaking them to feel smooth. Since jumping was such an important part of Spelunky, we made it so that you can still jump for a few extra steps off the side of a ledge, to reduce the occurrence of players falling into pits and wondering why their jump hadn’t registered (a common frustration of everyone who has ever played platformers). This also made it easier for you to make some tricky jumps, like when your target platform is directly above you.
Thankfully, giving the player more control didn’t make Spelunky easier to beat, since the enemies received a number of upgrades, including faster movement. I also added new enemies and more difficult versions of the old enemies. For example, the spitting cobras in the Mines are an upgrade to the snakes from the original. Also, unlike Spelunky Classic, where all four levels of the Mines are identical, I created three tiers of difficulty that determine how often monsters appear. As you move from the first level of an area to the fourth, you’ll encounter more monsters. Some difficult monsters, like the cobra, may only appear after the first level of an area.
You may recall that when I explained monster generation earlier, I gave a snippet of code from the Jungle that looked like this:
if (rand(1,60) == 1) instance_create(x, y-16, oManTrap);
else if (rand(1,60) == 1) instance_create(x, y-16, oCaveman);
else if (rand(1,120) == 1) instance_create(x, y-16, oFireFrog);
else if (rand(1,30) == 1) instance_create(x, y-16, oFrog);
That same block of code looks like this in the remake (altered slightly to make it easier to understand):
if (rand_monster(70, 60, 50))
create_entity_on_floor(i, j, ENT_TYPE_MONS_MANTRAP);
else if (rand_monster(60, 40, 30))
create_entity_on_floor(i, j, ENT_TYPE_MONS_CAVEMAN);
else if (rand_monster(120, 50, 40))
create_entity_on_floor(i, j, ENT_TYPE_MONS_TIKIMAN);
else if (rand_monster(240, 70, 50))
create_entity_on_floor(i, j, ENT_TYPE_MONS_SNAIL);
else if (rand_monster(120, 120, 120))
create_entity_on_floor(i, j, ENT_TYPE_MONS_FIREFROG);
else if (rand_monster(40, 20, 20))
create_entity_on_floor(i, j, ENT_TYPE_MONS_FROG);
else if (rand_monster(30, 30, 30))
create_entity_on_floor(i, j, ENT_TYPE_MONS_CRITTERFROG);
The function “rand_monster” takes in three parameters that determine the chance of the monster appearing in the first level, the middle two levels, and the last level. As you can see, the mantrap has an increasingly high chance of appearing in the Jungle the further you progress, with a 1/70 chance of appearing above a floor tile in level 1, a 1/60 chance in levels 2 and 3, and a 1/50 chance of appearing in level 4. You can pull some other interesting tidbits from looking at this code, like the fact that tiki men and snails (both monsters that are new to the remake) are significantly more likely to appear after the first level, but fire frogs are equally rare across the board.
In designing new monsters, I not only wanted to add more complex interactions and challenges, but I also wanted to make the world feel more alive. The human mind excels at finding patterns and making connections, so just adding a few variations on existing monsters gives the impression that they have families. When you see that a tiki man is really a caveman with a mask and a boomerang, you start to wonder if they belong to a tribe where the tiki men are high-ranking members. Other patterns quickly play into that notion, like the fact that tiki men are rarer and only appear in the Jungle, whereas cavemen roam around in other areas, too. Tiki men are already more difficult monsters than cavemen, but these little details cement their elite status and therefore their place in Spelunky’s world.
This “alive” quality doesn’t depend so much on the complexity of each monster’s artificial intelligence. Take, for example, the way players associate the four ghosts in Pac-Man with aggression, ambush, capriciousness, and stupidity. In reality, the behaviour of the ghosts is determined by simple algorithms that target different tiles to move to based on each character’s position. When these behaviours play out together on the same map, however, it seems as though the ghosts are working together, with Blinky chasing Pac-Man into the ambush of Pinky and so on.
I applied a similar principle to Spelunky: Combine simple behaviours to give the impression that the monsters are working together. This not only creates challenging situations, but it also makes the world feel more like a living, breathing ecosystem. Wherever possible, I tried to add monsters that attack you from new directions, so that when they were paired with existing monsters the attacks would feel coordinated. In the Jungle, for example, the snail blows acid bubbles that float upward — you can often see these floating up from gaps in the floor, making gaps more dangerous to jump over or into. And in the Ice Caves, the woolly mammoth spits a horizontally-moving freeze shot that creates a cross fire with the UFO’s downward-moving projectile. Both the snail’s bubble and mammoth’s blast are also used elsewhere in the game — the bubble floats up from acid pools in the hidden Worm level and the freeze shot can be fired from a freeze ray the player can acquire from a shop. Giving its inhabitants a shared language is not just a time-saving measure, but another way to make the world feel cohesive.
One of my favourite Spelunky stories is a great showcase of how simple behaviours can lead to complex moments. It comes from Tom Francis, a former editor of PC Gamer and now a fellow game developer, about the time Tom was in the Black Market and watched a tiki man wander empty-handed into one of the shops.
Tom sees the tiki man pick up a boomerang that’s for sale in the shop. “For a split second, I am amused,” he writes. “He’s going to buy a new boomerang! Silly tribesman, you don’t own material wealth!” But then it dawns on him that something terrible is about to happen, and he scrambles away to a safe corner to avoid what he calls the “shopstorm”:
All nine shopkeepers hurl themselves into the air and start firing their shotguns in random directions. They kill the tribesman. They kill two other tribesmen. They kill frogs, pitchers, snails. One kills the slave he was selling, another kills his own dog. Two of them throw themselves to their deaths in the excitement. Four of them throw themselves into a pit, where their bursts of buckshot cut each other to ribbons.
When the blasts quiet down, I crawl slowly out of my hiding place and walk carefully through the empty shops, collecting everything for free. What happened here was: the tribesman walked out of the shop. He walked out of the shop with the shopkeeper’s boomerang in his hand, and he walked out of the shop without paying for it.
What makes Tom’s story so cool is that a number of disparate systems came together in just the right way to write its plot. First, a tiki man had to lose his boomerang, either by getting hit by something (like a tiki trap) or by throwing it at Tom. Then the tiki man had to walk into one of the Black Market’s shops. Finally, the shop had to be selling a boomerang. What happened next was the tiki man’s “pick up a boomerang and walk away with it” system met with the shopkeeper’s “get incredibly angry if an unpaid item leaves the shop” system and all hell broke loose. Tom’s thorough understanding of these systems takes nothing away from his fascination with it. Actually, the opposite is true — his understanding only deepens his enjoyment.
Traditional, linear, static narratives will always be important in video games, but these personal tales are the ones that, to me, separate the gaming experience from other art forms. Unlike fan fiction, where the audience is creating stories based on their favourite worlds, game players are living them. And in the context of these stories, the random number generator is akin to Fate, setting up scenarios that at times seem too incredible to be anything but scripted. No wonder game players are known to send prayers and curses to the “Random Number God” or “RNGesus.”
It’s easy to add more and more things to a randomised game and rely on what I think of as the “free value” that randomization offers. In a game with randomised levels, people will keep playing just to see what comes up. But to make it more than a glorified slot machine requires putting together a collection of systems and rules that is worth understanding, behind a world that feels interconnected. If you can manage that, a simple story of rescuing a troll from a pit and making it your friend, an “EPIC MOMENT” when a spider was killed by an arrow trap, or a deadly shopstorm becomes something as meaningful and memorable as hours of dialogue and scripted cutscenes. Sometimes more so.