News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Sliding Collision Around A Track

Started by kevin, June 04, 2012, 02:06:54 AM

Previous topic - Next topic

kevin

  Sliding Collision Around A Track

  This example lets the player move a sprite character around an oval shaped track.   The player has full sliding collision with the track and fences.  The demo uses the built in sprites sliding world collision mode to handle the  positioning of the sprite.  All we do is move it, the collision engine will work out the new position for us.   Obviously if the collision is world based, we need to create world, which is done randomly here in code.  In a real game you'd  knock up a little tool for such things.  

  To create the track shape, we draw two ovals to a world buffer, an outer and inner edge.  These two edges form the track.  Sliding collision is single sided so the line segments in the outter oval and inner oval need to be connected in opposite directions.  Together these form the area that will keep the moving sprite within.

  The track also includes some randomly sized rectangles splodged around it. These also drawn as line segment outlines.  Where each segment is pointing outwards.  So when a sprite pushes against the segment, the collision engine pushes/slides the character into new safe position.  

  Anyway, most of this example is really in setting the collision world.  The actual movement code in the main loop is trivial, nothing more than MoveSprite.  In a real game we'd obviously use our own game editor to built the collision world to suit the game visual environment.

   Video

   



  Related Examples
 
   * Line Of Sight
   * Advanced Platform Collision (Vector WORLD)
   * Convert Map To Collision Worlds
   * World Closest POint
   * Using Cameras to Follow PLayers
   * Calc Ray Reflections



  Download