DarkBASIC Pro
Versão de Avaliação
Patch 5.7
USB Dongle
Forum
Indique
Lista de Email
Diário Antigo
Outros Produtos
Cartography Shop
DarkMatter
Local DBPro Sites
Italy
UK
Visualizador de Código Fonte
Este é o Código Fonte de "Plasma Demo".
Cor:
Verde
Laranja
Branco
Tam. Fonte:
Padrão
Grande
` This code is copyright Dark Basic Software Limited 2002 Rem Project: PlasmaDemo Rem Created: 09/08/2002 08:45:23 Rem Hours: 5 rem Initialise sync on : sync rate 0 if check display mode(1024,768,32)=1 then set display mode 1024,768,32 rem Create board data dim board(3,3) seq=1 : for y=0 to 3 : for x=0 to 3 : board(x,y)=seq : inc seq : next x : next y board(3,3)=0 rem Loading screen load bitmap "media\gfx\backdrop.jpg" : sync rem Create scene create bitmap 1,screen width(),screen height() rem Load pyramid load object "media\pyramid\pyramid.x",1 scale object 1,200,200,200 position object 1,-1,-15,0 autocam off rem Create plasma load image "media\plasma\plasma.bmp",1 for pl=1 to 10 make object plain 100+pl,256,256 position object 100+pl,rnd(30)-15,rnd(30)-15,50 texture object 100+pl,1 set object light 100+pl,0 ghost object on 100+pl,2 next pl rem Create pixie chain load image "media\plasma\pixie.bmp",2 for px=1 to 20 make object plain 200+px,21-(px*1),21-(px*1) position object 200+px,0,50,0 texture object 200+px,2 set object light 200+px,0 ghost object on 200+px,2 next px rem Load sounds load sound "media\sounds\wind1.wav",1 load sound "media\sounds\wind2.wav",2 load sound "media\sounds\chime.wav",3 load sound "media\sounds\slide.wav",4 load sound "media\sounds\win.wav",5 loop sound 1 : loop sound 2 rem Setup light set point light 0,100,100,-100 set ambient light 0 rem Start backdrop banding band=1 : r=0 : g=0 : b=0 rem Shuffle board start position xx=(screen width()-40)/4.0 : yy=(screen height()-40)/4.0 shufx=3 : shufy=3 : mixitup=15 oktoselect=1 rem Render loop do rem Autoscramble if mixitup>0 and moving=0 randomize timer() ra=rnd(3) : moved=0 oldshufx=shufx : oldshufy=shufy if ra=0 and shufx>0 then shufx=shufx-1 : moved=1 if ra=1 and shufy>0 then shufy=shufy-1 : moved=1 if ra=2 and shufx<3 then shufx=shufx+1 : moved=1 if ra=3 and shufy<3 then shufy=shufy+1 : moved=1 if moved=1 if board(shufx,shufy)=lastmovingtile moved=0 : shufx=oldshufx : shufy=oldshufy endif endif endif rem User selection if mixitup=0 and mouseclick()=1 and oktoselect=1 mx=mousex()/xx : my=mousey()/yy : moved=0 if mx>=0 and mx<=3 and my>=0 and my<=3 if board(mx,my)>0 oldshufx=shufx : oldshufy=shufy if moved=0 and mx-1=shufx and my=shufy and shufx>=0 then shufx=mx : shufy=my : moved=1 if moved=0 and mx+1=shufx and my=shufy and shufx<=3 then shufx=mx : shufy=my : moved=1 if moved=0 and my-1=shufy and mx=shufx and shufy>=0 then shufx=mx : shufy=my : moved=1 if moved=0 and my+1=shufy and mx=shufx and shufy<=3 then shufx=mx : shufy=my : moved=1 endif endif if moved=1 then oktoselect=0 endif rem Move the tile if moved=1 and moving=0 movingtile=board(shufx,shufy) : moving=1 : moved=0 lastmovingtile=movingtile board(oldshufx,oldshufy)=0 board(shufx,shufy)=0 fromx=shufx : fromy=shufy tox=oldshufx : toy=oldshufy if mixitup>0 then dec mixitup play sound 4 endif rem Main visual screen set current bitmap 0 cls 0 : print screen fps() rem Draw all tiles for y=0 to 3 for x=0 to 3 sx=x*10 : sy=y*10 : seq=board(x,y) if seq>0 placey=(seq-1)/4 : placex=(seq-1)-(placey*4) 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 endif next x next y rem Move tile slowly if moving>0 seq=movingtile sx=fromx*10 : sy=fromy*10 placey=(seq-1)/4 : placex=(seq-1)-(placey*4) slx=(fromx*xx)+sx : sly=(fromy*yy)+sy elx=(tox*xx)+sx : ely=(toy*yy)+sy mlx=slx+(((elx-slx)/100.0)*moving) mly=sly+(((ely-sly)/100.0)*moving) copy bitmap 1,(placex*xx),(placey*yy),(placex*xx)+xx,(placey*yy)+yy, 0,mlx,mly,mlx+xx,mly+yy inc moving,10 if moving>=100 board(tox,toy)=movingtile : moving=0 : movingtile=0 : moved=0 oktoselect=1 endif endif rem Detect victory if mixitup=0 seq=1 : ok=1 for y=0 to 3 for x=0 to 3 if board(x,y)<>seq then ok=0 inc seq : if seq=16 then seq=0 next x next y if ok=1 play sound 5 gosub _seefull mixitup=15 endif endif rem Render hidden 3D scene set current bitmap 1 rem Rotate pyramid yrotate object 1,wrapvalue(object angle y(1)+0.1) rem Shift plasma plains p#=wrapvalue(p#+0.2) randomize 1 for pl=1 to 10 a#=wrapvalue(p#+(pl*45)) x#=rnd(50)-25 : y#=rnd(50)-25 if pl<=5 then position object 100+pl,x#+cos(a#)*50,y#+sin(a#)*50,50-(pl*2) if pl>=6 then position object 100+pl,x#+cos(a#)*50,y#+sin(a#)*50,pl-60 next pl rem Move pixies around tip of pyramid yya#=wrapvalue(yya#+0.1) pxa#=wrapvalue(pxa#+2) for px=1 to 20 pxay#=pxa#+(px*5) position object 200+px,cos(pxay#)*40,30+(sin(pxay#)*(cos(yya#*20))),sin(pxay#)*40 zrotate object 200+px,pxay# next px rem Slowly change the backdrop colour if band=1 then r=r+1 if band=1 and r>255 then r=255 : band=2 if band=2 then g=g+1 : r=r-1 if band=2 and g>255 then g=255 : r=0 : band=3 if band=3 then b=b+1 : g=g-1 if band=3 and b>255 then b=255 : g=0 : band=4 if band=4 then r=r+1 : b=b-1 if band=4 and r>255 then r=255 : b=0 : band=2 color backdrop rgb(r,g,b) rem Every so often, trigger chime randomize timer() if rnd(500)=1 then play sound 3 rem Update screen sync loop _seefull: set text size 30 set text font "Arial" while mouseclick()<>0 : endwhile while mouseclick()=0 set current bitmap 0 ink rgb(0,0,0),0 : center text (screen width()/2)+1,screen height()-39,"CLICK MOUSE TO PLAY" ink rgb(255,255,255),0 : center text (screen width()/2),screen height()-40,"CLICK MOUSE TO PLAY" sync endwhile while mouseclick()<>0 : endwhile return
Selecionar todo o Código
Ver este Download
Copyright © 2003 Dark Basic Software Limited.
Virtual Object Informática Ltda.®