MORE CODE
Bare Bones
Sliding Collision
Sliding Collision using non-rotating collision boxes.
For an example using several colliding objects and another type of collision testing try:
Sliding Tile Puzzle.
`Bare Bones Sliding Collision Demo
`Author: Hop A Long
`May 27, 2004

`************************************************
`  Get Ready
`************************************************
`  Setup sync etc.

   Sync On
   Sync Rate 30
   Hide Mouse

`************************************************
`  Make a "Player" Object
`************************************************
`  Make Player with a Non-Rotating Collision Box
`  since this type will generate the data necessary
`  to produce Sliding Collision

   Make Object Box 10,20,20,20
   Position Object 10,0,0,0
   Make Object Collision Box 10,-10,-10,-10,10,10,10,0


`************************************************
`  Make a Low Wall to collide with
`************************************************
`  Make the Wall with a Non-Rotating Collision Box
`  so the necessary data will be available.

   Make Object Box 11,100,50,10
   Position Object 11,0,0,200
   Make Object Collision Box 11,-50,-25,-5,50,25,5,0


`********************************************************************
`  START MAIN  LOOP
`********************************************************************
   Do

      `  Get some text going
         Text 10,0, "Bare Bones Sliding Collision Demo"
         Text 10,20,"FPS: "+str$(screen fps())
         Text 10,40,"Up Arrow:Forward  Down Arrow:Back"
         Text 10,60,"Mouse:Left or Right"

      `  Announce when a collision occurs
         If obj_id > 0
         `  Display the object data on the screen
            Text 10,100, "There has been collision with object number: "+str$(obj_id)
            Text 10,120, "Dimensions of object "+str$(obj_id)+" x: "+str$(object size x(obj_id))+"  y:  "+str$(object size y(obj_id))+"  z:  "+str$(object size z(obj_id))
            Text 10,140, "Player's position:  x: "+str$(posx#)+"  z: "+str$(posz#)
         Endif

      `*************************************************
      `  MOVEMENT CODE
      `*************************************************
      `  Store the Player angle y in cy# (change in y)
         cy# = Object Angle Y(10)

      `  Move the Player in the XZ plane
         If Upkey()=1 then Move Object 10,3
         If Downkey()=1 then Move Object 10,-3

      `  Rotate the Player's direction
         Yrotate Object 10,wrapvalue(cy#+(mousemovex()*0.5))

      `  Get the Player's positions
         posx# = Object position x(10)
         posz# = Object position z(10)
         posy# = Object position y(10)

      `  Use the three location values to position the Player
         position object 10,posx#,posy#,posz#


      `*************************************************
      `  COLLISION DETECTION CODE
      `*************************************************

         obj_id = 0

      `  Detect collision with an Object and Slide
         If Object Collision(10,0)>0
         `  Obtain the object id for our text print out
            obj_id = Object Collision(10,0)

         `  Decrement the Player coordinates to begin the slide
         `  You would need y if crossing a bridge, applying gravity etc.
         `  The Get Object Collision command only returns a value when a non-rotating
         `  collision box is used.
            Dec posx#,get object collision x()
            Dec posy#,get object collision y()
            Dec posz#,get object collision z()

         Endif

         Position Object 10,posx#,posy#,posz#

      `*************************************************
      ` CAMERA ROUTINES
      `*************************************************
      `  Build new camera position and store
         camX# = Newxvalue(posx#,cy#-180,100)
         camZ# = Newzvalue(posz#,cy#-180,100)

      `  Place the camera
         Position Camera camX#,50,camZ#

      `  Point the camera at the player object
         Point camera posx#,25,posz#

      `  Refresh Screen
         Sync

   Loop
`**************************************************************************************************
`  END MAIN LOOP
`**************************************************************************************************

`  End the program
   End