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

  1. rem Matrix Showcase
  2.  
  3. rem Standard Setup Code for all examples
  4. sync on : sync rate 0 : color backdrop 0
  5. set text font "arial" : set text size 16
  6. set text to bold : set text transparent
  7.  
  8. rem Create matrix
  9. load image "face.bmp",1
  10. load image "water.bmp",2
  11. for m=1 to 2
  12.  if m=1 then s=200
  13.  if m=2 then s=100
  14.  make matrix m,s,s,36,36
  15.  if m=1 then position matrix m,-50,20,-50
  16.  if m=2 then position matrix m,0,120,0
  17.  prepare matrix texture m,m,36,36
  18.  ghost matrix on m
  19.  tc=1
  20.  for z=35 to 0 step -1
  21.   x=0
  22.   while x<=35
  23.    set matrix tile m,x,z,tc
  24.    inc tc : inc x
  25.   endwhile
  26.  next z
  27. next m
  28.  
  29. rem Setup light
  30. set point light 0,50,500,50
  31. color light 0,1000,1000,200
  32.  
  33. rem Setup camera
  34. position camera 50,170,50
  35. point camera 50,0,50
  36.  
  37. rem Main loop
  38. desc$="Water Matrix (Hit Space)"
  39. do
  40.  
  41. rem Space controls wireframe
  42. if spacekey()=1
  43.  if wr=0
  44.   wrstate=1-wrstate
  45.   if wrstate=0 then set matrix wireframe off 1 : set matrix wireframe off 2
  46.   if wrstate=1 then set matrix wireframe on 1 : set matrix wireframe on 2
  47.   wr=1
  48.  endif
  49. else
  50.  wr=0
  51. endif
  52.  
  53. rem Control matrix like water
  54. for m=1 to 2
  55.  a#=wrapvalue(a#+1)
  56.  for z=0 to 36
  57.   for x=0 to 36
  58.    x#=cos(a#+(x*10))
  59.    y#=sin(a#+(z*10))
  60.    nx#=0.0-(cos(a#+(x*10))*0.25)
  61.    nz#=0.0-(sin(a#+(z*10))*0.25)
  62.    ny#=1.0-nx#-nz#
  63.    set matrix height m,x,z,(x#+y#)*15.0
  64.    set matrix normal m,x,z,nx#,ny#,nz#
  65.   next x
  66.  next z
  67.  update matrix m
  68. next m
  69.  
  70. rem Show Framerate
  71. text 20,screen height()-40,desc$
  72. fps$="DBPro Fps: "+str$(screen fps())
  73. text screen width()-20-text width(fps$),screen height()-40,fps$
  74.  
  75. rem Update screen
  76. sync
  77.  
  78. rem End loop
  79. loop
  80.  
  81.