More Code
MATRIX  JUMPING
JUMPING AND MOVEMENT ACROSS THE SURFACE OF A MATRIX
`Jumping Code for a Matrix
`Author: Hop A Long
`June 16, 2004


`*****SET UP*****
   Sync On
   Sync Rate 30
   Autocam Off
   Hide Mouse

`*****USEFUL VARIABLES
   dy# = 0
   Jumping = 0

`*****MAKE THE MATRIX*****
   Make Matrix 1,10000,10000,20,20

`*****TEXTURE THE MATRIX*****
   Create Bitmap 1,256,256 : cls rgb(0,100,250) : ink rgb(0,0,150),0
   For j = 1 to 4
      Circle 128,128,j*32
   Next j
   Get Image 1,0,0,256,256 : Delete Bitmap 1
   Prepare Matrix Texture 1,1,1,1
   Fill Matrix 1,0,1
   Randomize Matrix 1,125

`*****MAKE A PLAYER*****
   Make object sphere 1,20 : Color Object 1,rgb(250,150,0)
   Position Object 1,750,0,750

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

      `*****LAUNCH THE JUMP*****
      If Spacekey()=1  and dy#=0.0
      `  Set the change in y value to the starting value of 2.0.
         dy#=3.0
         Jumping = 1
      Endif

      `*****MOVEMENT CODE****
      `  Store Player Y Angle
      ang_y# = Object Angle Y(1)

      `*****CONTROL INPUT TO KEEP PLAYER ON THE MATRIX*****
      If Upkey()=1
         posx#_t = Newxvalue(posx#,ang_y#,20)
         posz#_t = Newzvalue(posz#,ang_y#,20)
         If posx#_t>0 and posx#_t<10000 and posz#_t>0 and posz#_t<10000
            Move object 1,10
         Endif
      Endif

      If Leftkey()=1 then Yrotate object 1,Wrapvalue(ang_y#-5)
      If Rightkey()=1 then Yrotate object 1,Wrapvalue(ang_y#+5)

      `*****LOCATE THE PLAYER*****
      posx# = Object position x(1)
      posz# = Object position z(1)

      `*****WHEN THERE IS NO JUMP*****
      If Jumping = 0
         posy# = Get Ground Height(1,posx#,posz#)+3.0
      Endif

      `*****WHEN A JUMP OCCURS*****
      If Jumping = 1
         dy# = dy#-0.1
         posy# = posy# + dy#
         y_test# = Get Ground Height(1,posx#,posz#)+3.0
         If posy# < y_test#
            posy# = y_test#
            Jumping = 0
            dy# = 0.0
         Endif
      Endif

      `*****POSITION THE PLAYER*****
      Position object 1,posx#,posy#,posz#

      `*****PLACE THE CAMERA*****
      camz# = Newzvalue(posz#,ang_y#-180,100)
      camx# = Newxvalue(posx#,ang_y#-180,100)
      camy# = Get Ground Height(1,camx#,camz#)
      Position camera camx#,camy#+50,camz#

      Point camera posx#,posy#+10,posz#

      `******TITLE DESCRIPTION*****
      Ink rgb(250,150,0),0
      Text 10,20,"JUMPING ON A MATRIX"
      Text 480,40,"space bar to jump"
      Text 480,60,"up arrow to run"
      Text 480,80,"left or right arrow to turn"
      If Jumping = 1
         Text 10,60,"jump height    : "+str$(posy# - y_test#)
         Text 10,80,"ground height : "+str$(y_test#)
      Endif
      If Jumping = 0
         Text 10,60,"jump height    : 0"
         Text 10,80,"ground height : "+str$(posy#)
      Endif

      `*****REFRESH*****
      Sync

Loop
`******************END OF LOOP********************************************