This guide aims to provide an overview of what we know now about lagging and glitching the game. First some definitions:
- Lagging means making the game stop processing for a duration of time. Most commonly done by pressing S or PrintScreen on the keyboard. There are other methods, however, like dragging the game window around
- Glitching refers to making the game behave in an unintended way. Lagging can be used to do this
Currently known glitches:
- Superjump
- In-game timer manipulation
- Tree warp
Superjump
The oldest known glitch, found in 2016 by Nimanao. It allows you to jump a lot higher than normally possible. Demonstration: (instructions in the video description)
In-game timer manipulation
This glitch makes the game display a lower end time than is accurate. Previously known as a side effect of the superjump, Galanga used it without the jump to set a 0.02s time on Bunny Hill in December 2020. Demonstration: (instructions in the video description)
Tree warp
Found in February 2021 by TripleBuffered, this glitch allows you to warp through trees at the side level boundaries. Demonstration: (instructions in the video description)
Why does lagging cause these glitches?
The game has a main loop that processes keyboard input, calculates game physics (Tux's movement) and draws the results to your screen every frame the game runs. Normally, this happens 60 times a second. However, when you lag the game, this loop stops processing for a while. Once it resumes, all missed input is processed, then all the physics calculations for the missed time are done in one go, and then the final result of that is drawn to your screen.
The glitches are caused by differences in the physics calculations. For the most part, these calculations don't change much when the game is lagged, as the game's ODE solver will just chop up the long duration in small timesteps and process each of those in turn. Collision detection, terrain type and slope processing, force calculations and so on still happen normally. However, there are two important actions that are only done once per frame, no matter how long lagging has made that frame:
- Updating game time
- Clipping Tux back in bounds
Updating game time
Game time (the time that has passed since the current race started) is stored in the global variable g_game.time. It is updated once per frame, after all the physics calculations are done. This means that any calculation that depends on game time will give different results when a frame is lagged. And that, in turn, causes the superjump. When jumping, the game applies an upward force to the character for a short duration of time. To check if that time duration is over, game time is used. So if the game time falls in that duration at the start of the lagged frame, the upward force will be applied during the entire length of the frame, no matter how long that frame is.
Additionally, game time is not updated if the global variable g_game.finish is true. On certain levels, this variable is set to true if the physics calculations detect that the finish line barrier was crossed. If that happens on a lagged frame, the game time will keep the value that was set at the end of the previous frame, which may be a long time ago. This causes the in-game timer manipulation glitch. Levels on which this is possible: Bunny Hill, Twisty Slope, Bumpy Ride and Frozen River.
Clipping Tux back in bounds
The physics calculations make sure Tux is clipped back in bounds if he is out of bounds, but they only do so once each frame, after the ODE solver has finished processing. While the ODE solver is processing Tux's movement in small timesteps, his position can be out of bounds. This causes the tree warp glitch. If you create enough lag to give Tux time to pass the tree(s) out of bounds before he is clipped back in, there will be no collision and no speed loss.
Glitchcam
In March 2021, TripleBuffered modified the game code to add a glitchcam. This way, you can see the physics calculation steps the game does when recovering from lag, and you can see the glitches happening.
Superjump
In-game timer manipulation