Darius Kazemi had a serious problem, and pondered a solution. He couldn’t play Spelunky at work.
The roguelike (or rogue-inspired, if you’re particular about your rogue-ing) recently launched in revamped form on Xbox Live Arcade, but Spelunky has been available as a free download for PC players since late December 2008. At work, however, Kazemi is assigned to a Linux-based machine, which is devoid of Spelunking.
“This was like my birthday present to myself,” said Kazemi to me yesterday. “My birthday was this past weekend, and I use Linux at work, so I can’t play Spelunky at work. I want to play Spelunky at work--I’m too productive!--and now I can! Good for me, bad for my employers. [laughs]”
The result is a functional version of Spelunky running in HTML5, meaning the game is platform agnostic. Sure, the version that’s up-and-running doesn’t feature any sound, runs into serious frame rate issues when a boulder appears, and always spawns players on the left-hand side, but it works. Hell, it’ll even play the opening animation on an iPhone and iPad, though the concept of playing the twitch-based Spelunky with touch controls sounds awful.
Kazemi, better known as Tiny Subversions on his blog and Twitter, is the director of community development at open web technology company Bocoup. He’s also a hardcore Spelunky player, having downloaded the original version of the game the same week it was uploaded to the TIGSource forums by creator Derek Yu. Kazemi figures he’s racked up 7,000 games since, and it's still going.
“I did one of those blog posts a year or two ago where it was like ‘Oh, name the most important games to you”’and almost all the most important games to me were ones I played in middle school and high school,” he said. “And then there’s a big gap, and, then, there’s Deus Ex, and there’s another big gap, and, then, there’s Spelunky. It’s one of those games that stays with me that I’m probably going to be playing for my whole life at this point.”
We have a friend of Kazemi’s to thank for suggesting the idea of an HTML5 version of Spelunky. Three hours later, Kazemi had something up and running, and he shared it with the world on Saturday. Being Saturday, however, no one noticed. He mentioned it again on Monday, and it took off. Even Minecraft creator Markus “Notch” Perrson said something about it, albeit to tell Kazemi the boulder didn’t work.
You, like me, might be surprised at hearing it took Kazemi only three hours to port Spelunky. Turns out Spelunky was created using the popular development software GameMaker. Nearly a year ago, GameMaker creator YoYo Games introduced the ability to spit out HTML5 versions of games made within the GameMaker software. This meant Spelunky was a candidate for becoming a web game.
The conversion wasn’t without its troubles, though. (A more technical breakdown is available here).
The audio was built using old, then-better Windows libraries, which obviously wouldn’t work in a browser game. Kazemi said he’s working on a solution, but for the moment, the HTML5 version of Spelunky is a silent affair. Chances are screaming players will make plenty of noise to make up for it.
Especially for a game built a few years ago, the code will go down some weird paths in conversion.
“When you’re doing a machine conversion of one programming language to another,” he said, “there’s always going to be--it’s basically the equivalent of homonyms in the English language, where there will be a word that can be interpreted in two different ways, and the compiler picks the wrong interpretation and it messes up your code.”
Kazemi is using an older version of GameMaker, though, which YoYo Games publicly, jokingly chided him for, as the developers are pretty sure some of the issues Spelunky’s conversion ran into have since been fixed. He’s going to upgrade his copy of GameMaker and see what happens. He’s hoping these updates might fix the game’s infamous Dark Levels, which aren’t working in the current HTML5 version. If not, he’s ready to hack it together himself.
Some of the issues were made solveable because Kazemi is deeply familiar with the Spelunky source code. In one case, a nasty glitch related to the level generation algorithm (Spelunky is not completely random) was fixed by forcing player to spawn on the left, rather than randomizing left or right.
Kazemi became versed with Spelunky’s code by becoming part of the “very active but very obscure” mod community for the original game. In addition to developing and abandoning a Twitter mod that proved “very spammy,” (the results of which are still featured on the account @darius_spelunks) he wrote a series of forum posts that explained his examination of the game’s detailed level generation.
“It was mostly for the modders on the Spelunky forum who wanted to make harder levels for Spelunky,” he said.
Wait, harder Spelunky levels?
“Yeah, yeah,” he laughed. “The nice part about Spelunky is that it’s really hard, but it’s also really fair, you know? A lot of these forum mods make it feel a lot more like I Wanna Be the Guy, where you’re just walking--and then you die!”
Over the next month, Kazemi hopes to fix the obvious problems, eventually turning on the features players expect from Spelunky. From there, he may resurrect that Twitter mod, and wants to include a level modifier that allows players to better understand how Spelunky builds its levels. He described Spelunky’s worlds as 50% hand-made pieces, 50% randomization, and wants a tool that can control those elements. If you wanted to generate a stage without any randomization-- devoid of monsters, traps, or treasures--that would, in theory, be possible with Kazemi’s proposed tool.
Though GameMaker helped make Spelunky running in HTML5 a reality, without Kazemi’s unique set of skills, it’s harder to imagine it would have happened.
“Originally people were like ‘Oh, you’re so good at this!’” he said. “Well, no, it was just three hours of fiddling around. But, actually, [it’s] that I know Game Maker really well, I know HTML5 really well, and I know [the] Spelunky source code really well. The fact that I happen to know all those three things meant it was relatively easy to do, but there’s probably not a lot of people who are good at all those things. I’ll take some credit for it, I guess. [laughs]”
Between the successful version for Xbox 360 and the platform-agnostic original on the web, Kazemi is just happy to have more people playing Spleunky. And, yes, Derek Yu has seen Kazemi’s work--the official account mentioned it.
“For a long time, Spelunky was just this sleeper thing, and now there’s articles about Spelunky all over the place,” he said. “It’s really nice to see people talking about it.”