News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Platform Game Movement Based on Ray Intersection

Started by kevin, September 10, 2012, 06:41:44 PM

Previous topic - Next topic

kevin

Platform Game Movement Based on Ray Intersection

About:

    This shows another approach for building platform game movement, this time  using line definitions.   The concept here is that our platforms are defined as line fragments.  So the character ( the player in this case) has three stages walking (left/right), Jumping and Falling.

   When in walking mode, the  character is just checking if it's over the platform.  When the player is outside of the platform bounds, it swaps to falling more.

   When falling, we're checking for ray intersections with the fragments bellow the character, looking for an impact with a floor platform that's the characters height away.  The character is positioned at it's head.  If the impact is further away than the characters height, we're still falling. If it's equal to or closer than then we're landed on the platform.

   Jumping is split into two parts, when moving up, we're not checking for any impacts, allowing the character to jump from lower platform over higher ones.  When it reaches the top of it's jump, the character switches from Jumping to Falling mode.    

   You can find a number of similar examples on the forums.  

  Controls:

   Left/Right Arrow Keys = Move Left/Right
        Up Arrow or Space = Jump
               ESC Key = QUIT



  Related Examples:

   * Sonic the Hedgehog Loop Mock Up
   * Platformer Pixel Collisions Via Ray Casting
   * Advanced Platform Collision (Vector based)
   * Walking On Sprites
   * Walking on Sprite Collision Map



  Video:
 
   



  Download: