Spelunky Wiki

Source Code

Redirected from Source code

495pages on
this wiki
Add New Page
Add New Page Talk0

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 this GM Decompiler, 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

For old releases (ones that are built for GM7 and under), This 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.

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.

For the newer releases (ones built for GM8.0 and over), you must actually open the .GMK and use the built-in debug mode.

Simply press the red "play" button on the main toolbar (or press F6) when you have the .GMK file open, and the game will start in debug mode, which creates a separate "Debug Information" window.

It's highly recommended, but not necessary for operation, that you understand basic GML programming when you are in debug mode.

Unused items Edit

Some items are mentioned within the source code, but aren't available in-game without using illegitimate means:

Jordan Shoes
Nice J's!
Nice J's, bro!
Type: Accessory
Function: Increases jump height some more than the Spring Shoes
Source: • Cannot be found through normal means.
Cost: ???
Weight: Light
Notes: The "Jordan" part of "Jordans Shoes" in most likely a reference to Air Jordan brand sneakers
  • 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
This item contains no sprite or object, and exists only as 'global.hasNinjaSuit' in the source code. Setting this in debug mode has no effect.
  • Death Mask/Death Mask Wear
These exist only as sprites. sDeathMaskPickup was most likely going to be for the actual collectable physics Item and the sDeathMaskWear would most likely overlay the Spelunkers head, similar to how Items are overlayed near the hands of the Spelunker.
Pictured: sDeathMaskPickup
Pictured: sDeathMaskWear
Golden Egg
Gold Egg
It's like an angels tear drop!
Type: Collectable
Function: Treasure
Source: None (sprite-only)
Cost: None (sprite-only)
Damage: ???
Weight: ???
Notes: In the sourcecode, it is 8x8. Preview image enlarged to show texture!
  • Golden Egg

This exists only as a sprite, but as it is in the "Sprites/Items/Treasures" folder, it was most likely going to be a Treasure.

Ball is life fam
Type: Object
Function: Throwing object
Source: • Cannot be found through normal means.
Damage: 1 (Thrown)
Weight: Light
Notes: The Basketball may also be related to the "Jordans Shoes" item, as the real Micheal Jordan is a former professional basketball player

  • Basketball
This exists as a functional object.

When added ingame, it has a 0.7 bounceFactor, and a frictionFactor of 0.6.
(For comparison, other light items, such as rocks, have a 0.5 bounceFactor and a 0.3 frictionFactor.)

It is an item, and when picked up, it dribbles in the players hand.
When thrown, it goes as high and as fast as other light items.
  • Basket

Testing the ball and baskets added through debug modes effects on each other in the title screen.

This exists as an object, but it remains completely stationary
no matter what the player or any object does to it.
There are three other sprites besides the one pictured,
they are named "sBasketSwoosh", "ssRim", and "sRimDeflect".
The objects for the sprites mentioned are all located in the Objects/Other/Title folder in the game data, so it is hypothesized that the Basket, and as such, the Basketball too, would probably have been placed in the title screen.

So mysterious!
Type: Collectable
Function: Treasure
Source: None (sprite-only)
Cost: None (sprite-only)
Damage: ???
Weight: ???
Notes: In the sourcecode, it is 8x8. Preview image enlarged to show texture!
  • Bell
Just like the Gold Egg, this exists only as a sprite, but as it is in the "Sprites/Items/Treasures" folder, it was also most likely going to be a Treasure.
  • Mushrooms

These exist only as sprites. There are eight of them.
It is unknown where in-game they would have taken place, as the "Mushrooms" folder is in the root "Sprites" folder. (They're in Sprites/Mushrooms, as opposed to a typical Sprites/Blocks/Lush/Mushrooms or Sprites/Items/Others/Mushrooms.)

Unused Traps Edit

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

Thwomp Trap
The Spelunker makes a narrow escape in the temples. (That is, if the object could actually damage him.)
Location: Was most likely to be The Temple based off of the color and design.
Damage: No Damage (Contact from aside, while moving)
Pattern: Trigger (Repeating Hazard)
Notes: This traps coding is unfinished, and it cannot damage the player.


  • Thwomp Trap
This exists as a partially functioning object. It moves similarly to the Crush Trap, if the Crush Trap only moved vertically.
It is practically certain that the name and pattern of this trap is based on the Super Mario Bros. enemy Thwomp.
The trap only triggers if the player are in the left or right edges vertical range (about 5 blocks upon either edge), however, if the player are directly in the middle, it will not trigger. (Note, this would be for the most part only possible to properly set up through illegitimate means.)
It is impossible for the player or any other character get hurt by this trap, as the incomplete coding doesn't contain any damage variables. This means the player can't get crushed if the player triggers it from the bottom normally, neither can the player get crushed by standing on top of the trap and waiting for it to raise until it hits the ceiling.
The trap can be destroyed through means of Bombs, Fire Frogs, and by use of the Mattock, but produces no particle effect. (aside from the explosives's default particle effects.)

A demonstration of the Thwomp Trap's patterns when added in game.

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).

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.

Also on Fandom

Random Wiki