Gravity

From Mario Fan Games Galaxy Wiki

Gravity is the system that handles vertical movement in a platforming fangame, particularly Mario games. It is one of the most vital, and most difficult, elements to implement into such an engine.

There are four known methods of gravity seen in fangames: Triangular Method, Trapezoidal (British trapezium) Method, and the two Parabolic (curved) Methods.


Triangular Method

Trianglejump.PNG

The least accurate and the ugliest of methods, the Triangular Method moves the character up at a constant speed for a set number of pixels, then immediately moves them back down again at a constant speed. This makes collision-checking easier, as the speed at which they collide with an object is constant, and probably known.

Pros:

  • Easy to implement
  • Unlikely to glitch

Cons:

  • Does not accurately replicate Mario physics at all
  • Very immersive
  • Not very practical


Trapezial Method

Trapezoidaljump.PNG

A slightly more accurate method, the Trapezoidal Jump is almost exactly the same as the Triangular Method, except that there is a period during which no vertical movement occurs at all. This is a somewhat better simulation of gravity, but it is still quite poor and has an unworthy appearance.

Pros:

  • Easy to implement
  • Unlikely to glitch

Cons:

  • Not a good replication of Mario physics
  • Somewhat immersive


Simple Parabolic Method

Parabolicjump.PNG

The Simple Parabolic Method is fairly accurate to Mario physics, except that it generally forms a very sharp jump, causing a severe loss of jumping accuracy. The jump and the speed with which it is moved through is also exactly the same vertically regardless of the horizontal speed; as such, jumping small pits at slow speed is not an option.

In this method, speed and acceleration are not at all constant. As such, the collision detection must be modified to accommodate a variable speed with a delicate enough execution to avoid becoming stuck in obstacles.

Pros:

  • Fairly accurate to Mario physics
  • Smooth control and appearance

Cons:

  • Slightly difficult to implement
  • Collision detection may glitch


Modified Parabolic Method

Sparabolicjump.PNG

This is possibly the most accurate method known to replicate Mario physics. It is similar to the Simple Parabolic Method, with an important exception -- the parabola of the jump is modified depending on the horizontal speed at the time of the jump, so that slower speeds do not yield impossible jumps.

However, this method still has the problem of variable speed and acceleration, and collision detection is still a relatively arduous battle. OniLink10's OLME NS Engine has a simplified version of this method.

Pros:

  • Most accurate replication of Mario physics
  • Extremely smooth control and appearance

Cons:

  • Most difficult to implement
  • Prone to glitches