home *** CD-ROM | disk | FTP | other *** search
/ DarkBasic Professional / DarkBasicPro.iso / data1.cab / Lang_Files_(English) / Help / examples / matrix / matrix2-example.dba < prev    next >
Encoding:
Text File  |  2004-09-22  |  3.8 KB  |  138 lines

  1. rem Matrix Functionality
  2.  
  3. gosub _setupcamera
  4. gosub _simplematrix : gosub _usingvectors : gosub _mouselook : gosub _deletematrix
  5. gosub _texturedmatrix : gosub _mouselook : gosub _deletematrix
  6. gosub _modifymatrix : gosub _mouselook
  7. gosub _movematrix : gosub _editmatrix : gosub _mouselook
  8. gosub _shiftmatrix : gosub _matrixdata
  9. gosub _deletematrix
  10.  
  11. rem End of program
  12. end
  13.  
  14. _setupcamera:
  15.  position camera 0,300,0 : autocam off
  16.  x#=30 : y#=0
  17. return
  18.  
  19. _simplematrix:
  20.  MatrixNumber=1
  21.  make matrix MatrixNumber,1000,1000,25,25
  22.  title$="Simple Matrix"
  23. return
  24.  
  25. _usingvectors:
  26.  
  27. VectorNumber=1 : MatrixNumber=1
  28. result==make vector3(VectorNumber)
  29. set vector3 VectorNumber, -500, 0, -500
  30. position matrix MatrixNumber, VectorNumber
  31. set vector3 to matrix position VectorNumber, MatrixNumber
  32. result=delete vector3(VectorNumber)
  33.  
  34. return
  35.  
  36. _texturedmatrix:
  37.  ImageNumber=1
  38.  MatrixNumber=1
  39.  load image "ground.jpg",ImageNumber
  40.  make matrix MatrixNumber,1000,1000,25,25
  41.  prepare matrix texture MatrixNumber,ImageNumber,1,1
  42.  title$="Textured Matrix"
  43. return
  44.  
  45. _modifymatrix:
  46.  ImageNumber=1
  47.  load image "ground.jpg",ImageNumber
  48.  make matrix MatrixNumber,1000,1000,25,25
  49.  prepare matrix texture MatrixNumber,ImageNumber,1,1
  50.  randomize matrix MatrixNumber,200 : update matrix MatrixNumber : sleep 1000
  51.  ImageNumber=2
  52.  load image "tile.bmp",ImageNumber
  53.  prepare matrix texture MatrixNumber,ImageNumber,2,2 : sleep 1000
  54.  set matrix wireframe on MatrixNumber : sleep 1000
  55.  fill matrix MatrixNumber,100.0,3 : update matrix MatrixNumber : sleep 1000
  56.  set matrix wireframe off MatrixNumber
  57.  title$="Modified Matrix"
  58. return
  59.  
  60. _movematrix:
  61.  position matrix MatrixNumber,0,0,500
  62.  TextureMode=1 : set matrix texture MatrixNumber, TextureMode, 0
  63.  position matrix MatrixNumber,0,0,0
  64. return
  65.  
  66. _editmatrix:
  67.  Height#=0.0 : a#=0.0
  68.  for x=0 to 25
  69.   for z=0 to 25
  70.  
  71.    a#=a#+1 : if a#>359 then a#=a#-360.0
  72.    Height#=cos(a#)*50
  73.    set matrix height MatrixNumber, x, z, Height#
  74.  
  75.    if x<25 and z<25
  76.     TileID=1+rnd(3)
  77.     set matrix tile MatrixNumber, x, z, TileID
  78.    endif
  79.  
  80.    nx#=0.0 : ny#=(sin(a#)+1.0)/2.0 : nz#=0.0
  81.    set matrix normal MatrixNumber, x, z, nx#, ny#, nz#
  82.  
  83.   next z
  84.  next x
  85.  update matrix MatrixNumber
  86.  title$="Edited Matrix"
  87. return
  88.  
  89. _shiftmatrix:
  90.  clear camera view rgb(0,0,128)
  91.  for t=1 to 1000 step 3
  92.   set cursor 0,0  : print "SHIFTING MATRIX"
  93.   if t>=001 and t<250 then shift matrix up MatrixNumber
  94.   if t>=250 and t<500 then shift matrix down MatrixNumber
  95.   if t>=500 and t<750 then shift matrix left MatrixNumber
  96.   if t>=750 and t<999 then shift matrix right MatrixNumber
  97.   update matrix MatrixNumber
  98.   sleep 3
  99.  next t
  100.  title$="Matrix Data"
  101. return
  102.  
  103. _matrixdata:
  104.  
  105. ghost matrix on MatrixNumber
  106. clear camera view rgb(0,0,128)
  107. while inkey$()<>"x"
  108.  set cursor 0,0 : print "MATRIX DATA (Press X to Exit)" : print
  109.  print "exist:";matrix exist(MatrixNumber)
  110.  print "tilesexist:";matrix tiles exist(MatrixNumber)
  111.  print "tilecount:";matrix tile count(MatrixNumber)
  112.  print "wireframe:";matrix wireframe state(MatrixNumber)
  113.  print "position x:";matrix position x(MatrixNumber)
  114.  print "position y:";matrix position y(MatrixNumber)
  115.  print "position z:";matrix position z(MatrixNumber)
  116.  print "tile height at 12,12:";get matrix height(MatrixNumber, 12, 12)
  117.  print "ground height at 0,0:";get ground height(MatrixNumber, 0, 0)
  118.  x#=x#+mousemovey() : y#=y#+mousemovex() : rotate camera x#,y#,0
  119. endwhile
  120. ghost matrix off MatrixNumber
  121.  
  122. return
  123.  
  124. _deletematrix:
  125.  MatrixNumber=1
  126.  if matrix exist(MatrixNumber)=1 then delete matrix MatrixNumber
  127. return
  128.  
  129. _mouselook:
  130.  
  131. while mouseclick()<>1
  132.  set cursor 0,0 : print title$+" (Left Mouse Button To Continue)"
  133.  x#=x#+mousemovey() : y#=y#+mousemovex() : rotate camera x#,y#,0
  134. endwhile
  135. while mouseclick()=1 : endwhile
  136.  
  137. return
  138.