Random Galaxy by Sergey K12th Jun 2006 19:45
|
---|
Summary a Random Galaxy shows how to create images inside dbp Description a Random Galaxy shows how to create an images inside darkbasic pro without any extra media and stuff.. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com sync on sync rate 100 : autocam off a as dword b as word c as dword d as byte backdrop on color backdrop 0 randomize timer() set camera range 1,2 b = rnd(1000)+700 c = rnd(5000)+10000 d = 50 position camera 0,100000,100000,100000 for a=1 to d CreateSpark() text 0,0,"Texture Load: "+str$((a*100)/d)+"%" sync next a for a=1 to b make object plain a,rnd(60)+40,rnd(60)+40 position object a,-(c*0.5)+rnd(c),-(c*0.5)+rnd(c),-(c*0.5)+rnd(c) texture object a,rnd(d-1)+1 ghost object on a set object light a,0 set object cull a,0 text 0,0,"Game Load: "+str$((a*100)/b)+"%" sync next a set camera range 1,50000 position camera 0,0,0 do set cursor 0,0 print "FPS: "+str$(Screen fps()) print "Polygons: "+str$(statistic(1)) CameraControl() for a=1 to b if object exist(a)=1 Os = Object in Screen(a) Vis = object visible(a) if Os = 1 then point object a,camera position x(),camera position y(),camera position z() if Os = 0 and Vis = 1 then hide object a if Os = 1 and Vis = 0 then show object a endif next a sync loop function CameraControl() if keystate(17)=1 then move camera 1 if keystate(31)=1 then move camera -1 if keystate(17)=1 and shiftkey()=1 then move camera 3 if keystate(31)=1 and shiftkey()=1 then move camera -3 if keystate(30)=1 cx = camera angle x() cz = camera angle z() rotate camera 0,camera angle y(),0 yrotate camera camera angle y()-90 move camera 1 yrotate camera camera angle y()+90 rotate camera cx,camera angle y(),cz endif if keystate(32)=1 cx = camera angle x() cz = camera angle z() rotate camera 0,camera angle y(),0 yrotate camera camera angle y()-90 move camera -1 yrotate camera camera angle y()+90 rotate camera cx,camera angle y(),cz endif xrotate camera camera angle x()+(mousemovey()*0.4) yrotate camera camera angle y()+(mousemovex()*0.4) endfunction function CreateSpark() for a=1 to 4 if image exist(a)=1 then delete image a next a ImgSizeX = 320 ImgSizeY = 240 sp1 = rnd(255) sp2 = rnd(255) sp3 = rnd(255) create bitmap 1,ImgSizeX,ImgSizeY box 0,0,ImgSizeX,ImgSizeY,0,RGB(sp1,sp2,sp3),0,0 get image 1,0,0,ImgSizeX*0.5,ImgSizeY*0.5,1 delete bitmap 1 create bitmap 1,ImgSizeX,ImgSizeY box 0,0,ImgSizeX,ImgSizeY,RGB(sp1,sp2,sp3),0,0,0 get image 2,0,ImgSizeY*0.5,ImgSizeX*0.5,ImgSizeY,1 delete bitmap 1 create bitmap 1,ImgSizeX,ImgSizeY box 0,0,ImgSizeX,ImgSizeY,0,0,RGB(sp1,sp2,sp3),0 get image 3,ImgSizeX*0.5,ImgSizeY*0.5,ImgSizeX,ImgSizeY,1 delete bitmap 1 create bitmap 1,ImgSizeX,ImgSizeY box 0,0,ImgSizeX,ImgSizeY,0,0,0,RGB(sp1,sp2,sp3) get image 4,ImgSizeX*0.5,0,ImgSizeX,ImgSizeY*0.5,1 delete bitmap 1 imgnum = GetNewImageNumber() create bitmap 1,ImgSizeX,ImgSizeY paste image 1,ImgSizeX*0.5,ImgSizeY*0.5,1 paste image 2,ImgSizeX*0.5,0,1 paste image 3,0,0,1 paste image 4,0,ImgSizeY*0.5,1 get image imgnum,0,0,ImgSizeX,ImgSizeY,1 delete bitmap 1 endfunction imgnum function GetNewImageNumber() a = 0 repeat inc a until image exist(a)=0 endfunction a |