So I had some time on my hands this weekend and made major headway on porting the PC version of Spelunky to HTML5. You can play it here.
In theory this should be a one-button process, but for a complex game like Spelunky it’s a bit harder.
- Ripped out the entire sound system. It had an external dependency on a DLL, which clearly doesn’t play nice with HTML5
- Fixed some bugs related to the compiler assuming the original programmer was being very careful with their GMScript.
- In particular, in GMScript you can (though it is not recommended) do “foo.bar = baz” without checking to see if “foo” exists. It just fails silently. The compiler does not wrap this in a check to see if “foo” is defined, so JS complains when it’s not. (Note: this may not be an issue in GameMaker Studio. I’m using the last version of GM HTML5 before they switched to Studio.)
- Repaired the rendering pipeline. For dark levels and a few other effects, the original game uses some draw modes that aren’t supported in GameMaker HTML5, so I had to take those out. I will eventually go in and reimplement them using globalCompositeOperation. For now, dark levels are not dark.
- Made some horrible, wretched hacks for bugs I couldn’t track down. For instance, there was a bug that happened when your character spawned on the right-hand side of the level, so I hard-coded it so you only spawn on the left.
The whole port took about three hours. I’m still working on it — I need to
reimplement sound, redo all the custom graphical effects, and track down some collision/math issues that are a pain in the ass to reproduce. I also need to add persistence using LocalStorage (right now it doesn’t save your scores). Update Aug 3 2012: a million thanks to the YoYo Games team for taking my three-hour port and fixing a bunch of the bugs (sound! saving! better performance in general!) and polishing the hell out of the game. I mean: look at that art framing the game!