TGC Codebase Backup



Basic Matrix Manipulation by CaseyK

1st May 2005 11:32
Summary

This shows how you can use the data command construct to create a matrix with set height's.



Description

This shows how you can use the data command construct to create a matrix with set height's.(Same)



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Initialize the syncronization for your screen
Sync On: Sync Rate 55
Rem Build the matrix Number 1, XSize = 100, ZSize = 100, XTiles = 10, ZTiles = 10
Rem Notice It says 9 and not 10. This is because zero counts as one.
Make Matrix 1,100,100,9,9
Rem Scan through the dimensions of the matrix too place data too the matrix
For Scan_X_Tiles = 0 To 9
   For Scan_Z_Tiles = 0 To 9
      Rem Get information from data construct
      Read Tile_Height
      Rem Apply it to the matrix
      Set Matrix Height 1,Scan_X_Tiles,Scan_Z_Tiles,Tile_Height
   Next Scan_Z_Tiles
Next Scan_X_Tiles
Rem Update Changes done to Matrix 1
Update Matrix 1
Rem Main Game Loop
Do
   Rem Point camera at center of matrix so you can see what you've done
   Position Camera 0,128,0
   Point Camera 50,0,50
   Rem Refresh Screen
   Sync
Loop

Rem Notice how there are ten data entry's per line.
Rem As well as 10 lines of data commands.
Rem Each value is for the tile height which is read above.
Data 50,50,50,50,50,50,50,50,50,50
Data 50,00,20,20,20,00,00,00,00,50
Data 50,00,20,20,00,00,00,00,00,50
Data 50,00,20,00,00,00,00,20,00,50
Data 50,00,20,00,00,00,00,20,00,50
Data 50,00,20,00,00,00,00,20,00,50
Data 50,00,20,00,00,00,00,20,00,50
Data 50,00,00,00,00,00,20,20,00,50
Data 50,00,00,00,00,20,20,20,00,50
Data 50,50,50,50,50,50,50,50,50,50