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

  1. rem Camera Showcase
  2.  
  3. rem Standard Setup Code for all examples
  4. sync on : sync rate 0 : color backdrop rgb(0,128,0)
  5. set text font "arial" : set text size 16
  6. set text to bold : set text transparent
  7.  
  8. rem Some music
  9. load music "misty.mp3",1 : loop music 1
  10.  
  11. rem Loading Prompt
  12. sync : center text screen width()/2,screen height()/2,"LOADING" : sync
  13.  
  14. rem Load image
  15. load image "wall.bmp",1
  16.  
  17. rem Create character
  18. for t=1 to 2
  19.  load object "miko\miko.x",t
  20.  set object specular t,0
  21.  xrotate object t,270
  22.  fix object pivot t
  23.  if t=1
  24.   position object t,0,0,200
  25.   rotate object t,0,180,0
  26.  else
  27.   position object t,0,0,-200
  28.   rotate object t,0,0,0
  29.  endif
  30.  loop object t,0,9000
  31.  set object speed t,500
  32. next t
  33.  
  34. rem Create sphere room
  35. load object "Sphere2.x",3
  36. scale object 3,1000,1000,1000
  37. scale object texture 3,10,5
  38. set object specular 3,0
  39. texture object 3,1
  40.  
  41. rem Create reflective circular floor
  42. make object sphere 5,1000
  43. color object 5,0 : ghost object on 5
  44. set reflection shading on 5
  45. scale object 5,100,100,1
  46. xrotate object 5,90+180
  47. set object specular 5,0
  48.  
  49. rem Cut-out view close-up
  50. make camera 1
  51. set camera view 1,320+48,16,640-16,240-48
  52. make light 1 : color light 1,256,512,2024 : set light range 1,1000
  53.  
  54. rem Create floating globe
  55. make object sphere 4,125
  56. scale object texture 4,300,100
  57. ghost object on 4
  58.  
  59. rem Create buzz globe
  60. make object sphere 999,10 : color object 999,rgb(255,0,0)
  61. make light 7 : color light 7,1024,100,100
  62. set light range 7,200
  63.  
  64. rem Setup main camera and light
  65. set current camera 0
  66. set camera range 1,7000
  67. set point light 0,0,0,0
  68. set light range 0,1500
  69. color light 0,256,512,256
  70. camdist#=0.0
  71.  
  72. rem Rim Object
  73. for t=7 to 28
  74.  s#=t : s#=s#/3.0
  75.  make object cube t,s#
  76.  texture object t,4
  77.  set object t,1,1,1,0,0,0,0
  78.  ghost object on t
  79. next t
  80.  
  81. rem Effect Prompt
  82. desc$="Multicamera and Reflection View"
  83.  
  84. rem Main loop
  85. do
  86.  
  87. rem Character control
  88. if leftkey()=1 then yrotate object 1,wrapvalue(object angle y(1)-3)
  89. if rightkey()=1 then yrotate object 1,wrapvalue(object angle y(1)+3)
  90.  
  91. rem Let camera track character
  92. a#=object angle y(1)
  93. x#=object position x(1)
  94. y#=object position y(1)
  95. z#=object position z(1)
  96. set current camera 1
  97. set camera to follow x#,y#,z#,a#,-115,135,10.0,0
  98. set current camera 0
  99.  
  100. rem Handle camera collision within circle
  101. a#=atanfull(x#,z#)
  102. d#=sqrt((x#*x#)+(z#*z#))
  103. if d#>500 then x#=sin(a#)*500 : z#=cos(a#)*500 : position object 1,x#,y#,z#
  104.  
  105. rem Slowly move camera out
  106. if camdist#<100.0 then camdist#=camdist#+0.1
  107.  
  108. rem Slowly rotate sphere room
  109. xrotate object 3,wrapvalue(object angle x(3)+0.1)
  110. yrotate object 3,wrapvalue(object angle y(3)+0.2)
  111. zrotate object 3,wrapvalue(object angle z(3)+0.3)
  112.  
  113. rem Hover the orb around center
  114. v#=wrapvalue(v#+0.5) : h#=wrapvalue(h#+2.0)
  115. position object 4,sin(v#)*-750,100+(cos(h#)*100),cos(v#)*-750 : yrotate object 4,v#+60
  116. position light 1,sin(v#)*-800,100+(cos(h#)*100),cos(v#)*-800
  117. position light 0,sin(v#)*-500,100+(cos(h#)*100),cos(v#)*-500
  118. position camera 0,sin(v#)*(camdist#*7.0),200+(cos(h#)*100),cos(v#)*(camdist#*7.0)
  119. point camera 0,x#,y#+100,z#
  120.  
  121. rem Fire light
  122. position object 999,0,200+(cos(h#+10)*150),sin(h#+10)*150
  123. position light 7,0,200+(cos(h#)*150),sin(h#)*150
  124.  
  125. rem Emit particles around rim
  126. for t=7 to 28
  127.  r#=wrapvalue(r#+0.5)
  128.  rotate object t,r#,r#*2,r#*3
  129.  position object t,cos(r#+t)*500,0,sin(r#+t)*500
  130. next t
  131.  
  132. rem Show Framerate
  133. center text (640-16)-(((640-16)-(320+48))/2),20,"Use Arrow Keys"
  134. text 20,screen height()-40,desc$
  135. fps$="DBPro Fps: "+str$(screen fps())
  136. text screen width()-20-text width(fps$),screen height()-40,fps$
  137.  
  138. rem Update screen
  139. sync
  140.  
  141. rem End loop
  142. loop
  143.