SpelunkyWiki

Negative depth in the Tutorial

Negative depth in the Tutorial is a quirk of Spelunky Classic in which the pause screen gives a depth below zero in the Tutorial, because it's level 0.

The pause screen lists the level, the player's depth in feet, his money, kills, time and saves. In the Tutorial it calls the level TUTORIAL CAVE, but works out the depth as it does on any level, and there the sum comes out below zero everywhere: -147.60 feet where the player starts, and still -82.32 on the floor of the lower cave. Nothing else uses the depth, so it changes nothing in play.

What happens

#

The player enters the Tutorial and pauses: the screen gives his depth as -147.60 feet. He walks on, drops into the lower cave and pauses again on its floor, the lowest he can stand, and the depth is still below zero, -82.32 feet [1].

Replays it in the game, where you can take over.Replays it in the game, to pause and scrub.
The Tutorial's negative depth. The player enters the Tutorial cave and pauses: the pause screen gives his depth as -147.60 feet. He walks on, drops into the lower cave and pauses again on its floor, the lowest he can stand, and the depth is still below zero, -82.32 feet.

Why

#

The pause screen's code writes the depth from the level's number and the player's height, py, his y when the game paused [2]:

    if (isLevel())
    {
        n = 128-24;
        if (global.currLevel < 1) draw_text(40, n-24, "TUTORIAL CAVE");
        else if (isRoom("rLoadLevel")) draw_text(40, n-24, "LEVEL: " + global.customLevelName + " BY " + global.customLevelAuthor);
        else draw_text(40, n-24, "LEVEL " + string(global.currLevel));
        draw_text(40, n-16, "DEPTH: " + string(174.8*(global.currLevel-1)+(py+8)*0.34) + " FEET");
objects/oScreen/step_begin.gml:85-91, from spelunky.gmk, Spelunky Classic 1.1's source, © 2008, 2009 Derek Yu and Mossmouth, LLC (Spelunky User License v1.1b).

That's 174.8 feet for each level before this one, and 0.34 feet a pixel down the level. isLevel() counts the Tutorial's room as a level [3], and both ways into the Tutorial, the START door on a first game and the TUTORIAL door, set the level to 0 [4]. So the depth starts at 174.8 * (0 - 1), -174.8 feet, and the cave, 304 pixels tall, is too shallow for the 0.34 feet a pixel to bring it back above zero [5]. The code gives the Tutorial its own name a line above, but not its own depth.

Reproducing it

#

Pause anywhere in the Tutorial. Where the player starts, py is 72, so the depth is -174.8 + 80 * 0.34, shown as -147.60. The replay of the clip pauses there (frame 568) and again on the lower cave's floor (980), at py 264, -82.32 feet [6]. Another replay pauses where the player starts, on the way back to the title [7].

In the port

#

The spelunky.ai port reproduces it exactly: it's in docs/quirks.md's list of the 1.1 source's bugs [5], and the oracle's fingerprint of the replay pins the level and the player's height the depth is worked out from. No option turns it off.

FAQ

#
Why is the depth negative in the Spelunky Classic Tutorial?

The pause screen counts 174.8 feet for each level before the one the player is on, and the Tutorial is level 0, so it starts 174.8 feet below zero. The player's height in the cave adds a little, but the cave isn't deep enough to bring it back above zero: it reads -147.60 feet where he starts.

Is the Tutorial's depth anywhere above zero in Spelunky Classic?

No. It would take a spot more than 506 pixels down, and the Tutorial is 304 pixels tall. Standing on the floor of its lower cave, the pause screen still reads -82.32 feet.

Does the negative depth change anything in Spelunky Classic?

No. The depth is only drawn on the pause screen; nothing else reads it.

See also

#

References

#
  1. Clip quirks/tutorial-negative-depth
  2. objects/oScreen/step_begin.gml:55
  3. scripts/isLevel.gml:7
  4. objects/oPlayer1/other_animation_end.gml:72-95
  5. The Tutorial's pause screen shows a negative depth., docs/quirks.md §1
  6. Replay fidelity/replays/flow-tutorial-pause-depth.txt, which the clip The Tutorial's negative depth plays
  7. Replay fidelity/replays/flow-tutorial-title.txt

Source code

#