Spelunky Wiki

Source Code

487pages on
this wiki

Redirected from Source code

The full source of Spelunky Classic has been released.

Derek stated he'd open source the code at some point. The readme.txt file from version 0.99.8 says:

Q: When will you release the source code (.gmk file)? A: Probably 6 months to a year after v1.0 of the game is released. Possibly sooner.
License: This license allows you to distribute Spelunky freely, so long as you distribute it unmodified and whole. This license prohibits you from selling or otherwise profiting from Spelunky, any part of Spelunky, including its source code, or any custom levels made with Spelunky's built-in level editor.

However, the complete source code can be extracted from any Game Maker game using the GM Decompiler, and is so complete that a new .exe can be generated from it. However, distributing any changes would clearly violate the above license. While useful for acquiring the source for older releases, this is no longer necessary since the latest release is open.

Extracting the source codeEdit

  1. Run the GM Decompiler to extract the .gmk file.
  2. Use either the trial version of Game Maker, or LateralGM, to view the .gmk.
  3. If you're interested in only a text version of the scripts:
    1. Scripts > Export All to export all non-object code
    2. Edit > Show Object Information > Save Button > File Type = Text to export all object code

Debug mode Edit


The options available in debug mode

The GM Debug Mode Enabler can be used to start any Game Maker 7 game in debug mode, which allows you to modify any in-game variables. This can allow unlimited cheating, but it's also useful for exploring unused items. Or it would, but Spelunky is now compiled in GM8.

If you use debug mode very frequently, it's easier if you make a copy of the .exe after the GM Debug Mode Enabler has started the game (i.e. after it modifies the .exe on disk), but before you shut down the game (i.e. before GM Debug Mode Enabler restores the original .exe). This modified .exe will then always start in debug mode, without having to use the Enabler.

Unused items Edit

Some items are mentioned within the source code, but aren't yet available in-game:

  • Jordan shoes
See 'global.hasJordans' in the source code. This can be set via debug mode, and has stronger effects than the spring shoes. It's not apparently available in-game.
  • Ninja suit
See 'global.hasNinjaSuit' in the source code. Setting this in debug mode has no effect.
  • Death Mask
This exists only as a sprite.
  • Golden Egg
Same here. It would be wicked awesome if this was put in the game, though.
  • Thwomp Trap
I don't know what this does. Probably related to the Thwomp Trap from Mario.
  • Basketball
Exists as an object. Also has a basketball hoop. Don't know what it does.
  • Bell
Exists as only a sprite
  • Mushrooms
Once again, exist only as sprites. There are eight of them.

Object names Edit

It has been suggested to name enemy/item/etc articles on the wiki based on the most public declaration by Derek Yu. In-game mentions, changelog mentions, and forum mentions are all preferred. However, sometimes the only name given is in the source code. The source code name should be considered the last resort, because sometimes source code names differ from their official public name (e.g. the Hedjet is known as 'oCrown' in the source code, but clearly says "you got the hedjet!" when you pick it up).

There is an easy way to tell what objects are named in the source code. Start the game in Debug Mode. Do Watch>Add, and paste this in:

object_get_name(instance_position(mouse_x,mouse_y,all).object_index) + string_copy("",window_set_cursor(cr_default),0) 

Now the debug window will display the name of any object that you move your mouse over.

Around Wikia's network

Random Wiki