Gravity line clipping

From Viki
Jump to navigation Jump to search

Gravity line clipping, or line clipping for short, is a glitch where the player can clip through a gravity line that would otherwise flip them.

To perform it, the player must press ACTION on one frame, release it the next frame, and then press ACTION on the next frame. Any other sequence of inputs will not work.

This technique is most commonly applied to horizontal gravity lines, but is possible on vertical gravity lines too.


The player must flip off of a surface and be flipped by the gravity line 2 frames later.

Horizontal gravity lines

For horizontal gravity lines, this means a surface under (or above) a gravity line that isn't too far away from said surface, such that the player touches it within 2 frames of flipping off the surface.

This means that the gravity line must not be more than 39 pixels above a floor or 35 pixels below a ceiling (counting from its visual appearance). In terms of normal editor gravity line placements, it must not be more than 5 tiles above a floor or 4 tiles below a ceiling.

Vertical gravity lines

For vertical gravity lines, since vertical gravity lines only flip the player one frame after they touch it, the player must touch the gravity line on the same frame they have just left the surface.

Code analysis

This glitch is possible due to the player's onground and onroof attributes, which directly control their eligibility to flip. These variables are set to 2 when the player makes contact with a floor (for onground) or a ceiling (for onroof), and decremented by 1 for each frame they are not contacting the respective surface. If they are greater than 0, the player is eligible to flip off of the respective surface.

When the player flips off of a floor, they are flipped. But when they touch a gravity line, they are unflipped. If, on the frame they are unflipped, they are eligible to flip (because this frame is within 2 frames past the last frame of contact with the floor), then they can flip off of the floor again, which clips them through the gravity line. The same logic applies for flipping off of a ceiling, but in opposite directions.

Note that while it may appear that the player is always unflipped after flipping off of the floor, this is not actually the case, because onground and onroof are used to determine the orientation of the player's sprite to be drawn, and not necessarily their gravity state.