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

  1. Rem Project: PlasmaDemo
  2. Rem Created: 09/08/2002 08:45:23
  3. Rem Hours: 5
  4.  
  5. rem Initialise
  6. sync on : sync rate 0
  7. if check display mode(1024,768,32)=1 then set display mode 1024,768,32
  8.  
  9. rem Create board data
  10. dim board(3,3)
  11. seq=1 : for y=0 to 3 : for x=0 to 3 : board(x,y)=seq : inc seq : next x : next y
  12. board(3,3)=0
  13.  
  14. rem Loading screen
  15. load bitmap "media\gfx\backdrop.jpg" : sync
  16.  
  17. rem Create scene
  18. create bitmap 1,screen width(),screen height()
  19.  
  20. rem Load pyramid
  21. load object "media\pyramid\pyramid.x",1
  22. scale object 1,200,200,200
  23. position object 1,-1,-15,0
  24. autocam off
  25.  
  26. rem Create plasma
  27. load image "media\plasma\plasma.bmp",1
  28. for pl=1 to 10
  29.  make object plain 100+pl,256,256
  30.  position object 100+pl,rnd(30)-15,rnd(30)-15,50
  31.  texture object 100+pl,1
  32.  set object light 100+pl,0
  33.  ghost object on 100+pl,2
  34. next pl
  35.  
  36. rem Create pixie chain
  37. load image "media\plasma\pixie.bmp",2
  38. for px=1 to 20
  39.  make object plain 200+px,21-(px*1),21-(px*1)
  40.  position object 200+px,0,50,0
  41.  texture object 200+px,2
  42.  set object light 200+px,0
  43.  ghost object on 200+px,2
  44. next px
  45.  
  46. rem Load sounds
  47. load sound "media\sounds\wind1.wav",1
  48. load sound "media\sounds\wind2.wav",2
  49. load sound "media\sounds\chime.wav",3
  50. load sound "media\sounds\slide.wav",4
  51. load sound "media\sounds\win.wav",5
  52. loop sound 1 : loop sound 2
  53.  
  54. rem Setup light
  55. set point light 0,100,100,-100
  56. set ambient light 0
  57.  
  58. rem Start backdrop banding
  59. band=1 : r=0 : g=0 : b=0
  60.  
  61. rem Shuffle board start position
  62. xx=(screen width()-40)/4.0 : yy=(screen height()-40)/4.0
  63. shufx=3 : shufy=3 : mixitup=15
  64. oktoselect=1
  65.  
  66. rem Render loop
  67. do
  68.  
  69.  rem Autoscramble
  70.  if mixitup>0 and moving=0
  71.   randomize timer()
  72.   ra=rnd(3) : moved=0
  73.   oldshufx=shufx : oldshufy=shufy
  74.   if ra=0 and shufx>0 then shufx=shufx-1 : moved=1
  75.   if ra=1 and shufy>0 then shufy=shufy-1 : moved=1
  76.   if ra=2 and shufx<3 then shufx=shufx+1 : moved=1
  77.   if ra=3 and shufy<3 then shufy=shufy+1 : moved=1
  78.   if moved=1
  79.    if board(shufx,shufy)=lastmovingtile
  80.     moved=0 : shufx=oldshufx : shufy=oldshufy
  81.    endif
  82.   endif
  83.  endif
  84.  
  85.  rem User selection
  86.  if mixitup=0 and mouseclick()=1 and oktoselect=1
  87.   mx=mousex()/xx : my=mousey()/yy : moved=0
  88.   if mx>=0 and mx<=3 and my>=0 and my<=3
  89.    if board(mx,my)>0
  90.     oldshufx=shufx : oldshufy=shufy
  91.     if moved=0 and mx-1=shufx and my=shufy and shufx>=0 then shufx=mx : shufy=my : moved=1
  92.     if moved=0 and mx+1=shufx and my=shufy and shufx<=3 then shufx=mx : shufy=my : moved=1
  93.     if moved=0 and my-1=shufy and mx=shufx and shufy>=0 then shufx=mx : shufy=my : moved=1
  94.     if moved=0 and my+1=shufy and mx=shufx and shufy<=3 then shufx=mx : shufy=my : moved=1
  95.    endif
  96.   endif
  97.   if moved=1 then oktoselect=0
  98.  endif
  99.  
  100.  rem Move the tile
  101.  if moved=1 and moving=0
  102.   movingtile=board(shufx,shufy) : moving=1 : moved=0
  103.   lastmovingtile=movingtile
  104.   board(oldshufx,oldshufy)=0
  105.   board(shufx,shufy)=0
  106.   fromx=shufx : fromy=shufy
  107.   tox=oldshufx : toy=oldshufy
  108.   if mixitup>0 then dec mixitup
  109.   play sound 4
  110.  endif
  111.  
  112.  rem Main visual screen
  113.  set current bitmap 0
  114.  cls 0 : print screen fps()
  115.  
  116.  rem Draw all tiles
  117.  for y=0 to 3
  118.   for x=0 to 3
  119.    sx=x*10 : sy=y*10 : seq=board(x,y)
  120.    if seq>0
  121.     placey=(seq-1)/4 : placex=(seq-1)-(placey*4)
  122.     copy bitmap 1,(placex*xx),(placey*yy),(placex*xx)+xx,(placey*yy)+yy, 0,(x*xx)+sx,(y*yy)+sy,(x*xx)+sx+xx,(y*yy)+sy+yy
  123.    endif
  124.   next x
  125.  next y
  126.  
  127.  rem Move tile slowly
  128.  if moving>0
  129.   seq=movingtile
  130.   sx=fromx*10 : sy=fromy*10
  131.   placey=(seq-1)/4 : placex=(seq-1)-(placey*4)
  132.   slx=(fromx*xx)+sx : sly=(fromy*yy)+sy
  133.   elx=(tox*xx)+sx : ely=(toy*yy)+sy
  134.   mlx=slx+(((elx-slx)/100.0)*moving)
  135.   mly=sly+(((ely-sly)/100.0)*moving)
  136.   copy bitmap 1,(placex*xx),(placey*yy),(placex*xx)+xx,(placey*yy)+yy, 0,mlx,mly,mlx+xx,mly+yy
  137.   inc moving,10
  138.   if moving>=100
  139.    board(tox,toy)=movingtile : moving=0 : movingtile=0 : moved=0
  140.    oktoselect=1
  141.   endif
  142.  endif
  143.  
  144.  rem Detect victory
  145.  if mixitup=0
  146.   seq=1 : ok=1
  147.   for y=0 to 3
  148.    for x=0 to 3
  149.     if board(x,y)<>seq then ok=0
  150.     inc seq : if seq=16 then seq=0
  151.    next x
  152.   next y
  153.   if ok=1
  154.    play sound 5
  155.    gosub _seefull
  156.    mixitup=15
  157.   endif
  158.  endif
  159.  
  160.  rem Render hidden 3D scene
  161.  set current bitmap 1
  162.  
  163.  rem Rotate pyramid
  164.  yrotate object 1,wrapvalue(object angle y(1)+0.1)
  165.  
  166.  rem Shift plasma plains
  167.  p#=wrapvalue(p#+0.2)
  168.  randomize 1
  169.  for pl=1 to 10
  170.   a#=wrapvalue(p#+(pl*45))
  171.   x#=rnd(50)-25 : y#=rnd(50)-25
  172.   if pl<=5 then position object 100+pl,x#+cos(a#)*50,y#+sin(a#)*50,50-(pl*2)
  173.   if pl>=6 then position object 100+pl,x#+cos(a#)*50,y#+sin(a#)*50,pl-60
  174.  next pl
  175.  
  176.  rem Move pixies around tip of pyramid
  177.  yya#=wrapvalue(yya#+0.1)
  178.  pxa#=wrapvalue(pxa#+2)
  179.  for px=1 to 20
  180.   pxay#=pxa#+(px*5)
  181.   position object 200+px,cos(pxay#)*40,30+(sin(pxay#)*(cos(yya#*20))),sin(pxay#)*40
  182.   zrotate object 200+px,pxay#
  183.  next px
  184.  
  185.  rem Slowly change the backdrop colour
  186.  if band=1 then r=r+1
  187.  if band=1 and r>255 then r=255 : band=2
  188.  if band=2 then g=g+1 : r=r-1
  189.  if band=2 and g>255 then g=255 : r=0 : band=3
  190.  if band=3 then b=b+1 : g=g-1
  191.  if band=3 and b>255 then b=255 : g=0 : band=4
  192.  if band=4 then r=r+1 : b=b-1
  193.  if band=4 and r>255 then r=255 : b=0 : band=2
  194.  color backdrop rgb(r,g,b)
  195.  
  196.  rem Every so often, trigger chime
  197.  randomize timer()
  198.  if rnd(500)=1 then play sound 3
  199.  
  200.  rem Update screen
  201.  sync
  202.  
  203. loop
  204.  
  205. _seefull:
  206.  set text size 30
  207.  set text font "Arial"
  208.  while mouseclick()<>0 : endwhile
  209.  while mouseclick()=0
  210.   set current bitmap 0
  211.   ink rgb(0,0,0),0 : center text (screen width()/2)+1,screen height()-39,"CLICK MOUSE TO PLAY"
  212.   ink rgb(255,255,255),0 : center text (screen width()/2),screen height()-40,"CLICK MOUSE TO PLAY"
  213.   sync
  214.  endwhile
  215.  while mouseclick()<>0 : endwhile
  216. return
  217.