Bomb Demo by Surge30th Mar 2005 15:30
|
---|
Summary This is my bomb demo and it is pretty cool, you should check it out and tell me what ou think. Description You are in a 3d world and all you do is move around and shoot a bomb that realeases a massive explosion and cool effects, you should check it out and tell me what you think. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com rem Bomb Demo By Brandon Cerge hide mouse rem little intro set text font Gradl$ set text size 40 set text to italic b$=" Loading Brandon's Bomb Demo" for x=0 to 255 step 2 ink rgb(255-x,255-x,255-x),0 center text 300,200,b$ next x rem prepare text for the game set text to normal set text font arial$ set text size 18 set text to bold rem setup sync on sync rate 60 fog distance 2000 autocam off rem load arrays dim partx#(300) dim party#(300) dim partz#(300) dim partxvel#(300) dim partyvel#(300) dim partzvel#(300) dim partlife(300) inten#=150 dim max(1) max(1)=300 rem load textures and sounds and music load image "grass01.bmp",1 load image "fire.bmp",2 load music "field.mid",1 load sound "explode5.wav",1 load sound "shoot.wav",2 load sound "voidhum.wav",3 rem make the particles that will go everywhere for t=1 to max(1) : make object plain (50+t),5,5 texture object (50+t),1 next t rem make bomb and explosions make object sphere 1,10 hide object 1 texture object 1,1 make object sphere 2,4000 texture object 2,2 ghost object on 2 hide object 2 make object sphere 3,4000 texture object 3,2 hide object 3 rem done loading now lets make our world make matrix 1,10000,10000,20,20 prepare matrix texture 1,1,1,1 fill matrix 1,0,1 randomize matrix 1,500 rem fogging color backdrop rgb(128,128,128) fog color rgb(128,128,128) fog on rem set up initial variables cax#=1000 caz#=1000 cay#=get ground height(1,cax#,caz#)+35 position camera cax#,cay#,caz# bomb#=0 text#=1 rem begin the music loop music 1 rem THE MAIN LOOP BEGINS HERE!!!!!!!!! do rem go and make the text box if text#=1 then gosub box rem get the current camera angle a#=camera angle y() b#=camera angle x() rem key equates if upkey()=1 then move camera 10 if downkey()=1 then move camera -10 if leftkey()=1 then yrotate camera wrapvalue(a#-5) if rightkey()=1 then yrotate camera wrapvalue(a#+5) if spacekey()=1 and bomb#=0 then bomb#=200 if shiftkey()=1 then xrotate camera wrapvalue(b#+1) if returnkey()=1 then xrotate camera wrapvalue(b#-1) if scancode()=157 and text#=1 then text#=0 if scancode()=14 and text#=0 then text#=1 rem if bomb has been fired, its life begins here if bomb#=200 play sound 2 position object 1,cax#,cay#,caz#+10 set object to camera orientation 1 show object 1 dec bomb# endif rem if bomb is alive, move it if bomb#>90 move object 1,30 dec bomb# endif rem if the bomb hits the ground, then it will explode if bomb#>90 if object position y(1) < get ground height(1,object position x(1),object position z(1)) then bomb#=90 endif rem now the bomb will explode!!!!!!!!! if bomb#<=90 and bomb#>0 hide object 1 position object 2,object position x(1),object position y(1),object position z(1) position object 3,object position x(1),object position y(1),object position z(1) if bomb#=88 play sound 1 loop sound 3 endif show object 2 show object 3 s#=(90-bomb#) rem now we will scale the explosions so they get big scale object 2,s#,s#,s# scale object 3,s#/1.5,s#/1.5,s#/1.5 dec bomb# yrotate object 2,wrapvalue(object angle y(2)+3) xrotate object 3,wrapvalue(object angle x(3)+4) xrotate object 2,wrapvalue(object angle x(2)-3) yrotate object 3,wrapvalue(object angle y(3)+4) x#=object position x(1) y#=object position y(1) z#=object position z(1) if bomb#=89 then request_explosion(x#,y#,z#,max(1),inten#,120) endif rem if bomb#=0 then hide the explosions to start again if bomb#=0 hide object 2 hide object 3 stop sound 3 endif rem position camera and refresh cax#=camera position x() caz#=camera position z() cay#=get ground height(1,cax#,caz#)+35 position camera cax#,cay#,caz# sync handle_explosion loop rem subroutines and functions box: ink 0,0 box 3,1,142,157 ink rgb(255,0,0),0 box 5,3,140,155 ink rgb(255,255,255),0 text 10,5, "-Player Controls-" text 10,20,"Arrows: Move" text 10,35,"Enter: Look up" text 10,50,"Shift: Look Down" text 10,65,"Spacebar: Shoot" text 10,85,"-Bomb Status-" text 10,100,"Bomb: "+str$(bomb#) text 10,120,"-Exit-" text 10,135,"Exit: Escape" return function request_explosion(ex#,ey#,ez#,particles,intensity#,life) t=0:p=0 repeat t=t+1 if partlife(t)=0 p=p+1 partlife(t)=life + rnd(life/5) partx#(t)=ex# party#(t)=ey# partz#(t)=ez# partyvel#(t)=rnd(intensity#)-(intensity#/2) partxvel#(t)=rnd(intensity#)-(intensity#/2) partzvel#(t)=rnd(intensity#)-(intensity#/2) show object (50+t) endif if p>=particles then exit until t>=max(1) endfunction function handle_explosion() for t=1 to max(1) if partlife(t)>1 partlife(t) = partlife(t) - 1 position object 50+t,partx#(t),party#(t),partz#(t) partxvel#(t)=partxvel#(t)*0.95 partyvel#(t)=partyvel#(t)*0.95 partzvel#(t)=partzvel#(t)*0.95 partyvel#(t)=partyvel#(t)-0.5 partx#(t) = partx#(t) + partxvel#(t) party#(t) = party#(t) + partyvel#(t) partz#(t) = partz#(t) + partzvel#(t) if party#(t)<=get ground height(1,partx#(t),partz#(t))+5 then partyvel#(t)=partyvel#(t)*-0.7 rotate object t+50,wrapvalue(object angle x(t+50)+rnd(50)),wrapvalue(object angle y(t+50)+rnd(50)),0 endif if partlife(t)=1 partlife(t)=0 hide object 50+t endif next t endfunction |