Astro by Rasdini1st Mar 2004 21:36
|
---|
Summary Astro-blast(new version)/asteroid type game with spheres/no media required Description good luck, I hope you don't find any bugs. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Rem Project: Astroblast Rem Created: 2/28/04 7:13:12 PM Rem ***** Main Source File ***** rem Written by:Richard Sardini Jr. E-mail:Noramdia@adelphia.net rem phone 814-504-6033 cls ink rgb(0,0,255),0 print " Welcome to Astro-Blast - Written by Richard Sardini" ink rgb(255,255,255),0 print "Arrow up or joystick up for thrust, left and right arrows" print "or joystick left and right to turn. Press space bar or" print "joystick fire button 1 to fire, and 'S' key or fire button 2" print "to turn on shields. Shields don't last long and take a bit" print "to charge so use sparingly. Use Super Shield Zapper by " print "pressing z or joystick fire button 3. You can only use" print "the shield zapper if your shields energy is >80 so keep" print "that in mind as you use your shields. Press 'P' anytime" print " during play to pause the game and any other key to continue." print "Press any key or joystick fire button 1 to begin." waiting: if joystick fire a()=1 then goto hitit if inkey$()="" then goto waiting hitit: cls set display mode 800,600,16 black=rgb(0,0,0):white=rgb(255,255,255):red=rgb(255,0,0):green=rgb(0,255,0):blue=rgb(0,0,255) sync on rem make bitmap for particles create bitmap 1,100,100 ink black,0:for x=0 to 100:line x,0,x,100:next x:ink red,0 for x=1 to 30:circle 50,50,x:next x:ink rgb(50,170,255),0 for x=1 to 10:circle 50,50,x:next x:blur bitmap 1,6:get image 100,0,0,100,100 delete bitmap 1 rem make ship make object cone 1,30:scale object 1,100,100,50:color object 1,white xrotate object 1,90:fix object pivot 1 rem make shields make object sphere 2,90:color object 2,red:ghost object on 2 position object 2,-5000,-5000,-5000 autocam off color backdrop black rem make simple radar screen make camera 1 color backdrop 1,rgb(100,100,100) set camera view 1,650,20,750,120 position camera 1,0,1200,0:point camera 1,0,0,0 set camera range 1,1,10000 set current camera 0 position camera 0,0,50,-100 point camera 0,0,0,0 hide mouse ink white,0 rem make exhaust make particles 1,100,30,30:color particles 1,100,130,230 rem make boarders make object box 2000,100,4,100:color object 2000,blue:position object 2000,0,-100,0 set object collision off 2000:ghost object on 2000 for x=2001 to 2004:clone object x,2000:color object x,red:ghost object on x:next x position object 2001,-1100,0,-1100:position object 2002,-1100,0,1100 position object 2003,1100,0,-1100:position object 2004,1100,0,1100 make object box 2005,2500,4,4:color object 2005,green:position object 2005,0,0,-1000 clone object 2006,2005:color object 2006,green:position object 2006,0,0,1000 make object box 2007,4,4,2500:color object 2007,green:position object 2007,-1000,0,0 clone object 2008,2007:color object 2008,green:position object 2008,1000,0,0 for x=2000 to 2008:set object collision off x:next x rem make alien make object sphere 100,20:make mesh from object 100,100:delete object 100 make object sphere 10,40:scale object 10,100,140,30 add limb 10,1,100:color object 10,rgb(120,140,255):color limb 10,1,red offset limb 10,1,0,0,-20 xrotate object 10,90:fix object pivot 10:position object 10,-3000,-3000,-3000 rem set variables yr#=270:dim bpdur(5):dim bltrng(5):dim expdur#(210):dim afdur(5) newgame: astrd=1000:score=0:thrust#=0:lev#=0:lev1=1:blts=1:frdelay=0 shields#=100:sh=-1:shexdur=0:ships=5:freq=800:freq1=600 alexdur=0:appear=0:shscale#=80:shsize=140:skipzap=0:restor=0 rem position ship position object 1,0,0,0 point object 10,object position x(1),0,object position z(1) rem main loop do rem check for and move alien if object position x(10)<-2000 appear=rnd(2000) if appear=1000 replacealien: num1=rnd(800)-400:num2=rnd(800)-400 if num1>-200 and num1<200 or num2>-200 and num2<200 then goto replacealien position object 10,object position x(1)+num1,0,object position z(1)+num2 if object position x(10)<-1000 or object position x(10)>1000 or object position z(10)<-1000 or object position z(10)>1000 goto replacealien endif t1=object collision(10,0) if t1=1 then goto replacealien endif endif rem move alien if object position x(10)>-2000 move object 10,.105+lev# position object 10,object position x(10),0,object position z(10) fire=rnd(freq1) if fire=freq1/2 and object in screen(10)=1 pick5=0 for x=70 to 72 if pick5=1 then goto skipsquare if object exist(x)=0 make object cube x,5:color object x,green:position object x,object position x(10),0,object position z(10) point object x,object position x(1),0,object position z(1):move object x,20 afdur(x-69)=600:pick5=1 endif skipsquare: next x endif endif rem move alien bullets for x=70 to 72 if object exist(x)=1 move object x,1 dec afdur(x-69) if afdur(x-69)<0 then delete object x if object exist(x)=1 t1=object collision(x,0) if t1>299 and t1<701 or t1=1 delete object x:inc score,20 if t1>299 and t1<400 count=1 for y=400 to 499 if count>2+(lev1-2) then goto skipmake7 if object exist(y)=0 make object sphere y,40:color object y,rgb(rnd(255),rnd(255),rnd(255)) position object y,object position x(t1),0,object position z(t1) point object y,object position x(t1)+(rnd(50)-25),0,object position z(t1)+(rnd(50)-25):move object y,20 inc count endif skipmake7: next y delete object t1 endif if t1>399 and t1<500 count=1 for y=500 to 700 if count>4 then goto skipmake8 if object exist(y)=0 make object sphere y,25:color object y,rgb(rnd(255),rnd(255),rnd(255)) position object y,object position x(t1),0,object position z(t1) point object y,object position x(t1)+(rnd(50)-25),0,object position z(t1)+(rnd(50)-25):move object y,20 inc count endif skipmake8: next y delete object t1 endif if t1>499 if particles exist(t1)=0 make particles t1,100,80,30:position particles t1,object position x(t1),0,object position z(t1) expdur#(t1-499)=5:color particles t1,rnd(255),rnd(255),rnd(255) endif delete object t1 endif if t1=1 hide object 1:if particles exist(2)=0 then make particles 2,100,30,50 position particles 2,object position x(1),0,object position z(1) shexdur=5:shields#=100 if sh=1 then sh=-1:position object 2,-5000,-5000,-5000:set object collision on 1 endif endif endif endif next x rem point alien at us c=rnd(freq):if c=freq/2 then point object 10,object position x(1),0,object position z(1) rem bonuses if score=500 then inc ships:inc score,100 if score=1000 then inc ships:inc score,100 if score=2000 then inc ships:inc score,100 if score=3000 then inc ships,5:inc score,100 rem end of game if ships=0 for x=2 to 1200:if particles exist(x)=1 then delete particles x next x sync off:backdrop off set cursor 200,200 print "Game over, your score was-->";score redoinput: print "play again(y/n)?" wait key if inkey$()="n" then end if inkey$()="y" sync on:backdrop on:for x=300 to 700:if object exist(x)=1 then delete object x next x goto newgame endif print "Bad input, try again." goto redoinput endif rem charge shields if shields#<100 then shields#=shields#+.0125 if shlddelay>0 then dec shlddelay:goto skipshields if shexdur>0 then goto skipshields if inkey$()="s" or joystick fire b()=1 sh=sh*-1:shlddelay=75 if sh=1 then set object collision off 1:shscale#=80 if sh=-1 then position object 2,-5000,-5000,-5000:set object collision on 1 endif skipshields: rem move ship move object 1,thrust# if skipzap>0 then dec skipzap:goto skipzapper if shexdur>0 then goto skipzapper if joystick fire c()=1 or inkey$()="z" if shsize=140 and shields#>80 shsize=600:skipzap=5000 if sh=-1 then sh=1:restor=1 endif endif skipzapper: rem show shields if sh=1 inc shscale# if shsize>140 then inc shscale# if shscale#>shsize shscale#=80:shsize=140 if restor=1 sh=-1:restor=0:position object 2,-5000,-5000,-5000:set object collision on 1 scale object 2,shscale#,shscale#,shscale# endif endif if sh=1 scale object 2,shscale#,shscale#,shscale# color object 2,rgb(rnd(255),rnd(255),rnd(255)) position object 2,object position x(1),0,object position z(1) if shsize=140 then shields#=shields#-.1125 if shields#<0 then sh=-1:position object 2,-5000,-5000,-5000:set object collision on 1 if invul>5 then set object collision off 1 endif endif rem check object for boudaries for x=300 to 700 if object exist(x)=1 if object position x(x)<-1010 or object position x(x)>1010 or object position z(x)<-1010 or object position z(x)>1010 position object x,rnd(50)-25,0,rnd(50)-25 endif endif next x rem pause function if inkey$()="p" sync off:backdrop off set cursor 400,200 print "! ! GAME PAUSED ! !" wait key sync on:backdrop on endif rem movement and thrust if leftkey()=1 or joystick left()=1 turn object left 1,.5 yr#=yr#+.5:if yr#>360 then yr#=0 endif if rightkey()=1 or joystick right()=1 turn object right 1,.5 yr#=yr#-.5:if yr#<0 then yr#=360 endif rem increase and show thrust if upkey()=1 or joystick up()=1 position particles 1,object position x(1)+cos(yr#)*20,0,object position z(1)+sin(yr#)*20 rotate particles 1,object angle x(1),object angle y(1),object angle z(1) set particle life 1,20:set particle chaos 1,10:show particles 1 inc thrust#,.0125 if thrust#>.95 then thrust#=.95 endif rem hide thrust if upkey()=0 and joystick up()=0 hide particles 1 endif rem fire sequence if frdelay>0 then dec frdelay:goto skipfire if shexdur>0 then goto skipfire if spacekey()=1 or joystick fire a()=1 pick=0:frdelay=30 for x=1 to 5 if pick=1 then goto fired if object exist(50+x)=0 make object sphere 50+x,5:color object 50+x,red:pick=1 position object 50+x,object position x(1),0,object position z(1) set object to object orientation 50+x,1:move object 50+x,20 bltrng(x)=250 endif fired: next x endif skipfire: rem move bullets and check for hits for x=1 to 5 if object exist(50+x)=1 move object 50+x,2 dec bltrng(x) if bltrng(x)<0 then delete object 50+x if object exist(50+x)=1 t1=object collision(50+x,0) if t1>299 and t1<701 or t1=10 or t1>69 and t1<73 delete object 50+x:inc score,20 if t1>299 and t1<400 count=1 for y=400 to 499 if count>2+(lev1-2) then goto skipmake if object exist(y)=0 make object sphere y,40:color object y,rgb(rnd(255),rnd(255),rnd(255)) position object y,object position x(t1),0,object position z(t1) point object y,object position x(t1)+(rnd(50)-25),0,object position z(t1)+(rnd(50)-25):move object y,20 inc count endif skipmake: next y delete object t1 endif if t1>399 and t1<500 count=1 for y=500 to 700 if count>4 then goto skipmake2 if object exist(y)=0 make object sphere y,25:color object y,rgb(rnd(255),rnd(255),rnd(255)) position object y,object position x(t1),0,object position z(t1) point object y,object position x(t1)+(rnd(50)-25),0,object position z(t1)+(rnd(50)-25):move object y,20 inc count endif skipmake2: next y delete object t1 endif if t1>499 if particles exist(t1)=0 make particles t1,100,80,30:position particles t1,object position x(t1),0,object position z(t1) expdur#(t1-499)=5:color particles t1,rnd(255),rnd(255),rnd(255) endif delete object t1 endif if t1=10 if particles exist(10)=0 make particles 10,100,30,60:position particles 10,object position x(10),0,object position z(10) position object 10,-3000,-3000,-3000:alexdur=5:score=score+40 endif endif if t1>69 and t1<73 make particles t1,100,80,30 position particles t1,object position x(t1),0,object position z(t1) color particles t1,0,255,0:bpdur(t1-69)=5 delete object t1 endif endif endif endif next x rem control asteroid explosions for x=500 to 700 if particles exist(x)=1 inc expdur#(x-499),12:if expdur#(x-499)>500 then delete particles x if particles exist(x)=1 set particle velocity x,expdur#(x-499) set particle emissions x,100-expdur#(x-499) set particle chaos x,expdur#(x-499) endif endif next x rem check ship for hits t1=object collision(1,0) if t1>299 or t1>69 and t1<73 or t1=10 if t1>299 and t1<400 count=1 for y=400 to 499 if count>2+(lev1-2) then goto skipmake3 if object exist(y)=0 make object sphere y,40:color object y,rgb(rnd(255),rnd(255),rnd(255)) position object y,object position x(t1),0,object position z(t1) point object y,object position x(t1)+(rnd(50)-25),0,object position z(t1)+(rnd(50)-25):move object y,20 inc count endif skipmake3: next y delete object t1 endif if t1>399 and t1<500 count=1 for y=500 to 700 if count>4 then goto skipmake4 if object exist(y)=0 make object sphere y,25:color object y,rgb(rnd(255),rnd(255),rnd(255)) position object y,object position x(t1),0,object position z(t1) point object y,object position x(t1)+(rnd(50)-25),0,object position z(t1)+(rnd(50)-25):move object y,20 inc count endif skipmake4: next y delete object t1 endif if t1>499 if particles exist(t1)=0 make particles t1,100,80,30:position particles t1,object position x(t1),0,object position z(t1) expdur#(t1-499)=5:color particles t1,rnd(255),rnd(255),rnd(255) endif delete object t1 endif if t1=10 if particles exist(10)=0 make particles 10,100,30,60:position particles 10,object position x(10),0,object position z(10) position object 10,-3000,-3000,-3000:alexdur=5:score=score+40 endif endif hide object 1:if particles exist(2)=0 then make particles 2,100,30,50 position particles 2,object position x(1),0,object position z(1) shexdur=5:shields#=100 if sh=1 then sh=-1:position object 2,-5000,-5000,-5000:set object collision on 1 endif rem ship invulnerability after being killed and restored if invul>5 dec invul color object 1,rgb(rnd(255),rnd(255),rnd(255)) if invul=5 set object collision on 1 color object 1,white invul=0 endif endif rem ships explosion if shexdur>0 inc shexdur,5 if shexdur>200 delete particles 2 shexdur=0:show object 1:ships=ships-1 invul=1000:set object collision off 1 endif if particles exist(2)=1 set particle chaos 2,shexdur set particle emissions 2,shexdur set particle velocity 2,shexdur endif endif rem alien ships explosion if alexdur>0 inc alexdur,8 if alexdur>150 delete particles 10 alexdur=0 endif if particles exist(10)=1 set particle chaos 10,alexdur set particle emissions 10,alexdur set particle velocity 10,alexdur endif endif rem check shields if sh=1 t1=object collision(2,0) if t1>299 or t1=10 or t1>69 and t1<73 if t1>299 and t1<400 count=1 for y=400 to 499 if count>2+(lev1-2) then goto skipmake5 if object exist(y)=0 make object sphere y,40:color object y,rgb(rnd(255),rnd(255),rnd(255)) position object y,object position x(t1),0,object position z(t1) point object y,object position x(t1)+(rnd(50)-25),0,object position z(t1)+(rnd(50)-25):move object y,20 inc count endif skipmake5: next y delete object t1 endif if t1>399 and t1<500 count=1 for y=500 to 700 if count>4 then goto skipmake6 if object exist(y)=0 make object sphere y,25:color object y,rgb(rnd(255),rnd(255),rnd(255)) position object y,object position x(t1),0,object position z(t1) point object y,object position x(t1)+(rnd(50)-25),0,object position z(t1)+(rnd(50)-25):move object y,20 inc count endif skipmake6: next y delete object t1 endif if t1>499 if particles exist(t1)=0 make particles t1,100,80,30:position particles t1,object position x(t1),0,object position z(t1) expdur#(t1-499)=5:color particles t1,rnd(255),rnd(255),rnd(255) endif delete object t1 endif if t1=10 if particles exist(10)=0 make particles 10,100,30,60:position particles 10,object position x(10),0,object position z(10) position object 10,-3000,-3000,-3000:alexdur=5:score=score+40 endif endif if t1>69 and t1<73 make particles t1,100,80,30 position particles t1,object position x(t1),0,object position z(t1) color particles t1,0,255,0:bpdur(t1-69)=5 delete object t1 endif endif endif for x=70 to 72 if particles exist(x)=1 inc bpdur(x-69),6:if bpdur(x-69)>160 then delete particles x if particles exist(x)=1 set particle velocity x,bpdur(x-69) set particle emissions x,100-bpdur(x-69) set particle chaos x,bpdur(x-69) endif endif next x rem change thrust if thrust#>0 then dec thrust#,.0025 if thrust#<0 then thrust#=0 rem check ship boundaries and turn ship 180 degrees if object position x(1)<-1000 or object position x(1)>1000 or object position z(1)<-1000 or object position z(1)>1000 turn object right 1,180 yr#=wrapvalue(yr#+180) if object position x(1)<-1005 or object position x(1)>1005 or object position z(1)<-1005 or object position z(1)>1005 position object 1,0,0,0 endif endif rem move asteroids for x=300 to 399 if object exist(x)=1 move object x,.25+lev# if object position x(x)<-1000 or object position x(x)>1000 or object position z(x)<-1000 or object position z(x)>1000 turn object right x,180+rnd(90)-45 endif endif next x rem move asteroids for x=400 to 499 if object exist(x)=1 move object x,.5+lev# if object position x(x)<-1000 or object position x(x)>1000 or object position z(x)<-1000 or object position z(x)>1000 turn object right x,180+rnd(90)-45 endif endif next x rem move asteroids for x=500 to 700 if object exist(x)=1 move object x,.75+lev# if object position x(x)<-1000 or object position x(x)>1000 or object position z(x)<-1000 or object position z(x)>1000 turn object right x,180+rnd(90)-45 endif endif next x rem asteroids bounce off each other here for x=300 to 700 if object exist(x)=1 t1=object collision(x,0) if t1>300 and t1<600 turn object right x,180+(rnd(90)-45):move object x,5 turn object right t1,180+(rnd(90)-45):move object t1,5 endif endif next x rem see if all asteroids have been destroyed check=0 for x=300 to 700:if object exist(x)=1 then check=check+1 next x if check=0 for x=300 to 305+lev1 make object sphere x,80:color object x,rgb(rnd(255),rnd(255),rnd(255)) pickover: obx=rnd(2000)-1000:obz=rnd(2000)-1000 if obx>-600 and obx<600 or obz>-600 and obz<600 then goto pickover position object x,obx,0,obz:point object x,(rnd(500)-250),0,(rnd(500)-250) next x pickover2: check=0 for x=300 to 305+lev1 t1=object collision(x,0) if t1>300 and t1<308+lev1 inc check pickover3: obx=rnd(2000)-1000:obz=rnd(2000)-1000 if obx>-600 and obx<600 or obz>-600 and obz<600 then goto pickover3 position object x,obx,0,obz:point object x,(rnd(500)-250),0,(rnd(500)-250) endif next x if check>0 then goto pickover2 lev1=lev1+1:lev#=lev#+.125:if lev1>10 then lev1=10 endif rem set cameras and print stats position camera 1,object position x(1),1200,object position z(1) point camera 1,object position x(1),0,object position z(1) position camera object position x(1),0,object position z(1) rotate camera object angle x(1),object angle y(1),object angle z(1) position camera object position x(1),700,object position z(1) point camera object position x(1),0,object position z(1) set cursor 0,0 print "SCORE-->";score;:set cursor (screen width()/2)-75,0:Print "ASTRO-BLAST - Written by Richard Sardini Jr." print "SHIPS--->";ships print "SPHEROIDS LEFT-->";check print "SHIELDS-->";int(shields#) if skipzap=0 set cursor 50,screen height()/2 ink rgb(rnd(255),rnd(255),rnd(255)),0 print "ZAPPER" set cursor 50,(screen height()/2)+20 print "READY" if shields#<80 set cursor 50,(screen height()/2)+40 print "But shield energy too low" endif ink white,0 endif rem refresh screen sync rem goto main loop loop |