home *** CD-ROM | disk | FTP | other *** search
/ DarkBasic Professional / DarkBasicPro.iso / data1.cab / Lang_Files_(English) / Projects / FaceDemo / FaceDemo.dba < prev    next >
Encoding:
Text File  |  2004-09-22  |  4.2 KB  |  170 lines

  1. Rem Project: FaceDemo
  2. Rem Created: 12/08/2002 04:09:58
  3. Rem Hours: 3
  4.  
  5. rem Init
  6. sync on : sync rate 0 : backdrop off
  7.  
  8. rem Load Head and prepare
  9. load object "media\Head.x",1
  10.  
  11. rem Handle head eyes
  12. make object sphere 2,50 : glue object to limb 2,1,1 : hide limb 1,1
  13. make object sphere 3,50 : glue object to limb 3,1,2 : hide limb 1,2
  14. scale object 2,100,75,100
  15. scale object 3,100,75,100
  16.  
  17. rem Black bloc for mouth
  18. make object sphere 4,75
  19. color object 4,0
  20. glue object to limb 4,1,0
  21. position object 4,0,55,-70
  22.  
  23. rem Detail the eyes
  24. load image "media\refl.bmp",1
  25. load image "media\face2.bmp",2
  26. texture object 2,1 : rotate object 2,90,0,90 : scale object texture 2,2,1
  27. texture object 3,1 : rotate object 3,90,0,90 : scale object texture 3,2,1
  28. rotate object 2,270,180,0
  29. rotate object 3,270,180,0
  30.  
  31. rem Create backdrop and body
  32. make object plain 201,1300,1000
  33. yrotate object 201,350
  34. load image "media\backdrop.jpg",201
  35. position object 201,100,10,380
  36. set object light 201,0
  37. texture object 201,201
  38. make object sphere 202,600
  39. scale object 202,60,100,60
  40. color object 202,0
  41. xrotate object 202,330
  42. position object 202,0,-210,150
  43.  
  44. rem Reflective mirror
  45. stencilbuffervalid=0
  46. if statistic(2)=1
  47.  stencilbuffervalid=1
  48.  make object sphere 501,500
  49.  position object 501,200,75,50
  50.  scale object 501,30,80,40
  51.  ghost object on 501
  52.  set reflection shading on 501
  53.  make object plain 502,5000,5000
  54.  position object 502,0,0,-300
  55.  set object light 502,0
  56.  yrotate object 502,20
  57. endif
  58.  
  59. rem Create smoke effect
  60. load image "media\smoke.tga",601
  61. for ss=0 to 9
  62.  make object plain 601+ss,128,128
  63.  position object 601+ss,-25-rnd(25),-50-(ss*50),-175
  64.  zrotate object 601+ss,rnd(350)
  65.  texture object 601+ss,601
  66.  set object light 601+ss,0
  67.  ghost object on 601+ss,0
  68. next ss
  69.  
  70. rem Setup light
  71. set ambient light 0
  72. set point light 0,0,-100,-300
  73. set light range 0,500
  74.  
  75. rem Setup color lights
  76. make light 1 : set point light 1,-300,0,-200 : color light 1,rgb(0,0,255)
  77. make light 2 : set point light 2, 300,0,-200 : color light 2,-255,255,-255
  78. make light 3 : set point light 3,0,-100,-300 : color light 3,500,-100,-100
  79.  
  80. rem Create some particles
  81. load image "media\fire.bmp",42
  82. make fire particles 1,42,500,40-6,74,-245,2,20,3
  83.  
  84. rem Load fire animation
  85. for ff=0 to 10
  86.  load image "media\fire\fire"+str$(10000+ff)+".tga",301+ff
  87. next ff
  88. anim=301
  89.  
  90. rem Setup camera
  91. set camera range 2,2000
  92. position camera 40,75,-250
  93. rotate camera 0,0,0
  94.  
  95. rem Load all sounds
  96. load sound "media\sounds\fire.wav",1 : loop sound 1
  97. load sound "media\sounds\urg1.wav",2 : set sound speed 2,12000
  98. load sound "media\sounds\urg2.wav",3 : set sound speed 3,12000
  99. load sound "media\sounds\urg3.wav",4 : set sound speed 4,12000
  100.  
  101. rem Main loop
  102. do
  103.  
  104.  rem Rotate face based on mouse position
  105.  moverate#=100.0
  106.  w#=wrapvalue(w#+2)
  107.  px#=mousex()+cos(w#)*5
  108.  py#=mousey()+sin(w#)*5
  109.  xmouse#=curvevalue((320-px#)/10.0,xmouse#,moverate#)
  110.  ymouse#=curvevalue((240-py#)/10.0,ymouse#,moverate#)
  111.  
  112.  rem Mouse coords
  113.  mx=mousex() : my=mousey()
  114.  
  115.  rem Detect mouse pause
  116.  if lastx=mx and lasty=my
  117.   if timer()-lasttime>3000
  118.    autofly=1 : play sound 2+rnd(2)
  119.   endif
  120.  else
  121.   lastx=mousex() : lasty=mousey()
  122.   lasttime=timer()
  123.   autofly=0
  124.  endif
  125.  
  126.  rem Automove fly
  127.  if autofly=1
  128.   position mouse rnd(640),rnd(480)
  129.  endif
  130.  
  131.  rem Rotate Head
  132.  position object 1,xmouse#,0,0
  133.  position object 202,xmouse#/2.0,-210,150
  134.  rotate object 1,ymouse#,xmouse#-10,0
  135.  
  136.  rem Flame animation in eyes
  137.  texture object 2,anim : texture object 3,anim
  138.  set sphere mapping on 2,2 : set sphere mapping on 3,2
  139.  inc animp
  140.  if animp>10
  141.   animp=0
  142.   inc anim : if anim>311 then anim=301
  143.  endif
  144.  
  145.  rem Rotate mirror sphere
  146.  if stencilbuffervalid=1
  147.   mr#=wrapvalue(mr#+1)
  148.   position object 501,200+(cos(mr#)*30),75+(sin(mr#)*10),100
  149.   rotate object 501,340,35+180+(cos(mr#)*10),5
  150.   texture object 502,anim
  151.  endif
  152.  
  153.  rem Raise smoke
  154.  for ss=0 to 9
  155.   zrotate object 601+ss,wrapvalue(object angle z(601+ss)+0.03)
  156.   if object position y(601+ss)>200
  157.    position object 601+ss,-25-rnd(25),-200,-175
  158.   else
  159.    position object 601+ss,object position x(601+ss),object position y(601+ss)+0.1,-175
  160.   endif
  161.  next ss
  162.  
  163.  rem Update screen
  164.  sync
  165.  
  166. rem End loop
  167. loop
  168.  
  169.  
  170.