TGC Codebase Backup



matrix and object help for all by dazzling dazzla

10th Jan 2005 9:26
Summary

This code will show you how to set the properties of a matrix with ease.



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `sets the screen refresh to manual and to a rate of 30 fps(
`frames per second)
sync on
sync rate 30

`loads media for usage later. In detail, what this does is saves
`the "_map.bmp" bitmap into the image file 1 and the "textures.bmp"
`bitmap into image file 2.
load image "dazz.bmp",1
load image "textures.bmp",2

`this will make a matrix and store it as matrix file 1 and give it
`the following properties; 1000 spaces x 1000 spaces, divided into
`20x tiles and 20z tiles
make matrix 1,1000,1000,20,20
`this command will allot an image for use with matrix 1. the 2nd
`part of the syntax will tell it to use image 1 on the matrix.
`the 3rd and 4th parts will tell us how many divisions will be
`made of the image for us in tiling the matrix
prepare matrix texture 1,1,2,2
`this will set matrix 1's tenth tile in the x direction and 10th
`tile in the z direction with the fourth texture taken from the
`image we prepared earlier

`sets the tile properties
for c=0 to 10
for d=0 to 10
set matrix tile 1,c,d,2
next c
next d

for e=0 to 11
set matrix tile 1,11,e,3
next e

for f=0 to 10
set matrix tile 1,f,11,3
next f

for a =0 to 10
for b =0 to 10
set matrix height 1,a,b,100
next b
next a

`this will position matrix 1 0 places x,0 places y and 0 places
`z
position matrix 1,0,0,0


`this will make a sphere 20 world spaces big
`and save it as object file 10
make object sphere 10,20
texture object 10,2
`will position object 10 randomly in the x direction, 5 spaces in
`y and randomly in the z direction
position object 10,rnd(20),5,rnd(20)

`main loop
do

   Rem Store Object angle
   AngleY# = object angle Y(10)

   Rem Control input for camera
   If Upkey()=1
`works out where the new "x"position of an object in space
`will be and saves it in xtest#
      XTest# = Newxvalue(X#,AngleY#,20)
      ZTest# = Newzvalue(Z#,AngleY#,20)
`checks to see if the xtest# values are less than the matrix
`borders before moving the objects jump to the position object
`command to see how this is implemented to make it look like
`the object hasn't gone through the matrix
      If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
         Move object 10,10
      Endif
   Endif

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

   X# = Object position x(10)
   Z# = Object position z(10)
   Y# = Get Ground Height(1,X#,Z#)

   Position object 10,X#,Y#+10,Z#

   CameraZ# = Newzvalue(Z#,AngleY#-180,100)
   CameraX# = Newxvalue(X#,AngleY#-180,100)
   CameraY# = Get Ground Height(1,CameraX#,CameraZ#)

   Position camera CameraX#,CameraY#+25,CameraZ#
   Point camera X#,Y#+10,Z#

   Rem Refresh Screen
   Sync

loop