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

  1. rem Light Showcase
  2.  
  3. rem Choose better display mode
  4. if check display mode(1024,768,32)=1
  5.  set display mode 1024,768,32
  6. else
  7.  if check display mode(1024,768,16)=1
  8.   set display mode 1024,768,16
  9.  endif
  10. endif
  11.  
  12. rem Standard Setup Code for all examples
  13. sync on : sync rate 0 : backdrop off
  14. set text font "arial" : set text size 16
  15. set text to bold : set text transparent
  16.  
  17. rem Load Hero music
  18. load music "music\hero.mp3",1 : loop music 1
  19.  
  20. rem User prompt
  21. sync : center text screen width()/2,screen height()/2,"LOADING" : sync
  22.  
  23. rem Load Statue Model
  24. set normalization on
  25. load object "models\statue.x",1
  26. load image "models\bumpmap.bmp",1
  27. xrotate object 1,270 : fix object pivot 1
  28. set light mapping on 1,1
  29. set object specular 1,0
  30. rotate object 1,0,0,0
  31.  
  32. rem Load room
  33. load object "world\room.x",2
  34. xrotate object 2,270 : fix object pivot 2
  35. set object specular 2,0
  36. rotate object 2,0,0,0
  37.  
  38. rem Set dynamic light zero
  39. hide light 0
  40.  
  41. rem Create pixie lights and dots
  42. for l=1 to 7
  43.  make light l
  44.  set point light l,0,0,0
  45.  set light range l,2000
  46.  make object sphere 2+l,50 : ghost object on 2+l
  47.  if l>1 then hide light l : hide object 2+l
  48. next l
  49.  
  50. rem Main loop
  51. desc$="Pixie Lights (Select keys 1-7)"
  52. do
  53.  
  54. rem Control light visibility
  55. k$=inkey$()
  56. if k$>="1" and k$<="7"
  57.  if keypress=0
  58.   keypress=1
  59.   li=1+(asc(k$)-asc("1"))
  60.   if light visible(li)=1
  61.    hide light li : hide object 2+li
  62.   else
  63.    show light li : show object 2+li
  64.   endif
  65.   c#=wrapvalue(180+(a#+(li*85)))
  66.  endif
  67. else
  68.  keypress=0
  69. endif
  70.  
  71. rem Rotate around model
  72. a#=wrapvalue(a#+0.5)
  73. b#=wrapvalue(b#+0.2)
  74. c#=wrapvalue(c#+0.05)
  75. x#=cos(c#)*250.0
  76. z#=sin(c#)*300.0
  77. position light 0,x#,150,z#
  78. position camera x#,100,z#
  79. point camera 0,150,0
  80.  
  81. rem Rotate lights around model
  82. for l=1 to 7
  83.  x#=cos(a#+(l*85))*300.0
  84.  z#=sin(a#+(l*85))*150.0
  85.  position light l,x#,100+(sin(b#)*100),z#
  86.  position object 2+l,x#,100+(sin(b#)*100),z#
  87. next l
  88.  
  89. rem Alter light colours over time
  90. leva#=wrapvalue(leva#+0.01)
  91. level#=cos(leva#)
  92. for l=1 to 7
  93.  col=127.0+(127.0*level#)
  94.  rev=col*-1
  95.  if l=1 then color light l,col,rev,rev
  96.  if l=2 then color light l,128,col,128
  97.  if l=3 then color light l,255,255,col*2
  98.  if l=4 then color light l,col,rev,col
  99.  if l=5 then color light l,col,col,col
  100.  if l=6 then color light l,500,500,500
  101.  if l=7 then color light l,rev*3,rev*3,rev*3
  102. next l
  103.  
  104. rem Show Framerate
  105. text 20,screen height()-40,desc$
  106. fps$="DBPro Fps: "+str$(screen fps())
  107. text screen width()-20-text width(fps$),screen height()-40,fps$
  108.  
  109. rem Update screen
  110. sync
  111.  
  112. rem End loop
  113. loop
  114.  
  115.