curved surfaces
Home Up Event Sequence Simple Example Ramps curved surfaces Old version

 

Platforms with curved surfaces

The ramp code does not allow for the player sliding down steep slopes. Also I wanted to implement curved platforms in a style reminiscent of the Sonic-the-hedgehog games.

This code expands on the ramp code with two major additions:

I have added a collision event. This event uses the bounce function to obtain information about the angle of a surface. 

//
// special bounce script
// leaves hspeed, vspeed unmodified
// puts result in hs1,vs1
// to be added to hspeed,vspeed at end of step
//
// V0.1 19 Dec 2004 Oliver Broad
//
var hs0,vs0
if jump
{
      hs0 = hspeed
      vs0 = vspeed
      move_bounce_solid(true)
      hs1 +=  (hspeed-hs0)/2
      vs1 +=  (vspeed-vs0)/2
      hspeed = hs0
      vspeed = vs0
}
Note that hspeed and vspeed are saved before the move_bounce_solid() call, and restored immediately after, this is because other events depend on the values of hspeed, vspeed, so they must not be modified at this point. Later the values in hs1 and vs1 are added to hspeed and vspeed.

Also note that the bounce function appears to work best when an object is moving relatively fast.

The information gained from the move_bounce_solid() command is used to make the player bounce off of steep slopes just enough that they appear to slide instead of being able to stand on single-pixel ledges.

The ramp_platform code has been modified, the code in the freefall section setting hspeed and vspeed to zero has been commented out. The speed is set by the collision code, zeroing it here as well would cause erratic results.

A whole new movement mode has been added for when the player is running.

Special code is added to the left, right and jump actions.

EXE: curve_platform.zip

GMD: curve_platform.gmd

Footnote: Feel free to use this.