REM Project: Space Invaders REM Created: 7/11/2006 10:41:16 AM REM REM ***** Main Source File ***** REM createsound("explosion",1,100,1000,8000,0.01,0,0,0,0,0,10) createsound("opening1",2,400,2000,4000,0,0,0.05,0.3,0.05,1800,10) createsound("opening2",3,350,2000,4000,0,0,0.05,0.3,0.05,1800,10) createsound("opening3",4,300,2000,4000,0,0,0.05,0.3,0.05,1800,10) createsound("opening4",5,350,1500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("opening5",6,375,500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("opening6",7,256,1000,4000,0,0,0.05,0.3,0.05,1800,10) createsound("opening6",8,256,4000,4000,0,0,0.05,0.3,0.05,1800,10) createsound("opening7",9,213,500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("opening9",10,150,500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("shot",16,100,100,8000,0,1.5,0,0,0,0,10) createsound("enemy,explosion",17,500,500,8000,0,0,0.05,0.4,0.5,1800,10) createsound("move",18,256,100,4000,0,0,0.05,0.3,0.05,1800,10) createsound("down",19,235,100,4000,0,0,0.05,0.3,0.05,1800,10) createsound("ending 1",20,128,1000,8000,0,0,0,0,0,0,10) createsound("ending 2",21,118,1000,4000,0,0,0,0,0,0,10) createsound("ending 3",22,98,6000,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen1",23,293.67,1000,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen2",24,440,500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen3",25,349.23,500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen4",26,392,500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen5",27,329.63,500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen6",28,261.6,500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen7",29,220,500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen8",30,146.83,500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen9",31,493.88,500,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen10",32,146.83,1000,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen11",33,329.63,1000,4000,0,0,0.05,0.3,0.05,1800,10) createsound("titlescreen12",34,493.88,1000,4000,0,0,0.05,0.3,0.05,1800,10) dim dotx(300) dim doty(300) dim shots(2) global finnalnote=1 make camera 1 dim l(8) dim fire(4) dim score#(2) dim score(2) dim ri(2) sync on move camera 1,-30 make object box 50,1,1,1 make mesh from object 1,50 for i=1 to 26 add limb 50,i,1 next i lim=0 restore topalien for y=1 to 7 for x=1 to 7 if y=7 and x=3 then l(1)=lim if y=7 and x=5 then l(2)=lim read r if x=4 and y=4 then goto skip1 if r=1 offset limb 50,lim,4-x,4-y,0 lim=lim+1 endif skip1: next x next y scale object 50,100/7,100/7,100/7 make mesh from object 2,50 make object box 51,1,1,1 lim=0 for i=1 to 22 add limb 51,i,1 next i restore twoalien for y=1 to 7 for x=1 to 9 if y=5 and x=1 then l(3)=lim if y=5 and x=7 then l(4)=lim read r if x=5 and y=4 then goto skip2 if r=1 offset limb 51,lim,5-x,4-y,0 lim=lim+1 endif skip2: next x next y scale object 51,100/9,100/7,100/7 make mesh from object 3,51 position object 51,500,0,0 make object box 52,1,1,1 lim=0 for i=1 to 33 add limb 52,i,1 next i restore threealien for y=1 to 9 for x=1 to 7 if y=9 and x=1 then l(5)=lim if y=9 and x=7 then l(6)=lim read r if x=4 and y=5 then goto skip3 if r=1 offset limb 52,lim,4-x,5-y,0 lim=lim+1 endif skip3: next x next y scale object 52,100/7,100/8,100/7 make mesh from object 4,52 position object 52,500,0,0 make object box 53,1,1,1 lim=0 for i=1 to 23 add limb 53,i,1 next i restore fouralien for y=1 to 7 for x=1 to 7 if y=7 and x=3 then l(7)=lim if y=7 and x=5 then l(8)=lim read r if x=4 and y=4 then goto skip4 if r=1 offset limb 53,lim,4-x,4-y,0 lim=lim+1 endif skip4: next x next y scale object 53,100/7,100/7,100/7 make mesh from object 5,53 position object 53,500,0,0 color backdrop 1,0 make object cone 60,5 color object 60,rgb(0,0,75) make object cone 61,1 move object up 61,2.05 color object 61,0 set ambient light 1 move object down 50,5 color object 50,69458459 p=-1 s=2 do if sound playing(s-1)=0 and s<8 and thru<2 if s=7 and sound playing(6)=0 s=2 thru=thru+1 endif play sound s s=s+1 endif if mouseclick()=1 then goto game a$="The aliens were looking for a place to expand, more land, more resources." b$="One of the reconnaissance ships found somthing amazing..." text screen width()/2-text width(a$)/2,screen height()-text height(a$)*3,a$ text screen width()/2-text width(b$)/2,screen height()-text height(a$)*2,b$ wait 1 tic=tic+1 if tic=400 then goto part1 sync loop do part1: if sound playing(s-1)=0 and s<8 and thru<2 if s=7 and sound playing(6)=0 s=2 thru=thru+1 endif play sound s s=s+1 endif a$="Sjxcigonsj fjxidl ixnweisj." b$="Translation: Turn on those headlights its dark out here." text screen width()/2-text width(a$)/2,screen height()-text height(a$)*3,a$ text screen width()/2-text width(b$)/2,screen height()-text height(a$)*2,b$ move object right 50,0.125 wait 50 right=right+1 if right>80 then goto shipleft sync loop shipleft: do if sound playing(s-1)=0 and s<8 and thru<2 if s=7 and sound playing(6)=0 s=2 thru=thru+1 endif play sound s s=s+1 endif if mouseclick()=1 then goto game a$="Sjxcigonsj fjxidl ixnweisj." b$="Translation: Turn on those headlights its dark out here." text screen width()/2-text width(a$)/2,screen height()-text height(a$)*3,a$ text screen width()/2-text width(b$)/2,screen height()-text height(a$)*2,b$ move object left 50,0.125 wait 50 right=right+1 if right>160 then goto suckup1 sync loop suckup1: set ambient light 50 do if sound playing(s-1)=0 and s<8 and thru<2 if s=7 and sound playing(6)=0 s=2 thru=thru+1 endif play sound s s=s+1 endif if thru=2 if sound playing(2)=0 and sound playing(6)=0 and p=-1 play sound 7 p=0 endif if sound playing(7)=0 and p=0 play sound 9 p=1 endif if sound playing(9)=0 and p=1 play sound 7 p=2 endif if sound playing(7)=0 and p=2 play sound 9 p=3 endif if sound playing(9)=0 and p=3 play sound 10 p=4 endif if sound playing(10)=0 and p=4 play sound 9 p=5 endif if sound playing(9)=0 and p=5 play sound 7 p=6 endif endif if mouseclick()=1 then goto game a$="Axidksnlsinenshad!!!" b$="Translation: IT'S A WORMHOLE. GET OUT OF HERE!" text screen width()/2-text width(a$)/2,screen height()-text height(a$)*3,a$ text screen width()/2-text width(b$)/2,screen height()-text height(a$)*2,b$ move object up 50,0.06 wait 50 right=right+1 if right>250 then goto suckup2 sync loop suckup2: make light 1 position light 1,0,0,250 point light 1,0,20,400 delete object 60 delete object 61 make object sphere 60,5 set ambient light 1 color object 60,rgb(0,0,100) make object sphere 61,100 move object 61,400 move object up 61,40 color object 61,rgb(200,200,0) do if sound playing(s-1)=0 and s<8 and thru<2 if s=7 and sound playing(6)=0 s=2 thru=thru+1 endif play sound s s=s+1 endif if thru=2 if sound playing(2)=0 and sound playing(6)=0 and p=-1 play sound 7 p=0 endif if sound playing(7)=0 and p=0 play sound 9 p=1 endif if sound playing(9)=0 and p=1 play sound 7 p=2 endif if sound playing(7)=0 and p=2 play sound 9 p=3 endif if sound playing(9)=0 and p=3 play sound 10 p=4 endif if sound playing(10)=0 and p=4 play sound 9 p=5 endif if sound playing(9)=0 and p=5 play sound 8 p=6 endif endif if mouseclick()=1 then goto game a$="Dskxoien skdinklll ixelkshen." b$="Translation: Contact our mothership. " c$="We've found our new home." text screen width()/2-text width(a$)/2,screen height()-text height(a$)*3,a$ text screen width()/2-text width(b$)/2,screen height()-text height(a$)*2,b$ text screen width()/2-text width(c$)/2,screen height()-text height(a$)*1,c$ wait 50 right=right+1 if right>400 then goto game sync loop sw=1 p=-1 game: for i=2 to 6 if sound playing(i)=1 then stop sound i next i if light exist(1)=1 then delete light 1 if object exist(61)=1 then delete object 61 if object exist(60)=1 then delete object 60 position object 50,0,-8,0 sync move camera 1,-10 make light 5 make light 6 position light 5,0,0,30 position light 6,0,0,-30 point light 5,0,0,0 point light 6,0,0,0 make object box 57,1,1,1 make mesh from object 1,57 lim=0 for i=1 to 32 add limb 57,i,1 next i scale object 57,100/2,100/2,100 position object 57,0,16,0 color object 57,rgb(0,0,150) restore the for y=1 to 5 for x=1 to 15 read r if x=7 and y=3 then goto skip7 if r=1 offset limb 57,lim,x-7,3-y,0 lim=lim+1 endif skip7: next x wait 100 sync next y make object box 58,1,1,1 lim=0 for i=1 to 82 add limb 58,i,1 next i scale object 58,100/2,100/2,100 position object 58,11,3,0 color object 58,rgb(100,0,0) restore renewed for y=1 to 5 for x=1 to 35 read r if x=18 and y=3 then goto skip8 if r=1 offset limb 58,lim,x-18,3-y,0 lim=lim+1 endif skip8: next x wait 100 sync next y make object box 59,1,1,1 lim=0 for i=1 to 51 add limb 59,i,1 next i scale object 59,100/2,100/2,100 position object 59,-16,0,0 color object 59,rgb(0,0,150) restore space for y=1 to 5 for x=1 to 23 read r if x=12 and y=3 then goto skip9 if r=1 offset limb 59,lim,x-23,3-y,0 lim=lim+1 endif skip9: next x wait 100 sync next y make object 600,2,0 lim=0 for i=1 to 90 add limb 600,i,2 color object 600,rgb(0,0,150) next i position object 600,7,-10,0 scale object 600,100/2,100/2,100 restore invaders for y=1 to 5 for x=1 to 43 read r if x=22 and y=3 then goto skip10 if r=1 offset limb 600,lim,x-22,3-y,0 lim=lim+1 endif skip10: next x wait 100 sync next y change#=1 dif=1 a=1 life=3 dim button1(100) set text size 40 set text font "Arial" randomize timer() d$="Created by Spopovich" e$="Press the space key to continue." ink rgb(100,0,100),rgb(100,0,100) for i=1 to 300 dotx(i)=rnd(screen width()) doty(i)=rnd(screen height()) next i ink rgb(255,255,255),rgb(255,255,255) move camera -5 global p1=-1 global pa=0 for i=1 to 40 if spacekey()=1 then goto outofsound move object down 57,0.25 move object left 58,0.25 move object right 59,0.25 move object up 600,0.25 wait 50 sync for j=1 to 300 dot dotx(j),doty(j) next j next i do position camera 1,0,0,0 turn camera right 1,3 move camera 1,-35 text screen width()/2-text width(d$)/2,screen height()/2+text height(d$)*3,d$ text screen width()/2-text width(e$)/2,screen height()/2+text height(e$)*4,e$ if color=0 color object 57,rgb(0,0,150) color object 58,rgb(100,0,0) color object 59,rgb(0,0,150) color object 600,rgb(0,0,150) color=1 goto pastcolor endif color=color+1 if color=3 color object 57,rgb(100,0,0) color object 58,rgb(0,0,150) color object 59,rgb(100,0,0) color object 600,rgb(100,0,0) color=0 endif pastcolor: song(0,1,10,23,24,25,26,33,23,24,25,26,33) song(1,2,10,23,27,25,26,33,23,26,24,28,34) song(2,0,6,23,25,26,23,29,32,0,0,0,0) wait 100 ink rgb(255,255,255),rgb(255,255,255) for i=1 to 300 dot dotx(i),doty(i) next i ink rgb(100,0,100),rgb(100,0,100) sync if spacekey()=1 then goto outofsound loop outofsound: delete camera 1 delete object 600 delete object 57 delete object 58 delete object 59 set text size 20 position object 50,500,0,0 color backdrop 0 sync ink rgb(255,255,255),rgb(255,255,255) global m=1 global p=1 delete light 5 delete light 6 butoncheck: song(0,1,10,23,24,25,26,33,23,24,25,26,33) song(1,2,10,23,27,25,26,33,23,26,24,28,34) song(2,0,6,23,25,26,23,29,32,0,0,0,0) button("Play",20,1,1) button("Version",20,81,2) button("Difficulty",20,162,3) button("Controlls",20,243,4) button("Players",20,324,5) if p=2 then button("co-op or duel",20,405,6) a$="version "+str$(a) b$="difficulty "+str$(dif) c$="players "+str$(p) if m=1 then d$="co-op" if m=2 then d$="duel" text 0,0,a$ if p=2 then text text width(a$)+10,0,d$ text screen width()-text width(b$),0,b$ text screen width()-text width(b$)-10-text width(c$),0,c$ sync goto butoncheck play2: cls a$="Loading..." text screen width()/2-text width(a$)/2,screen height()/2-text height(a$)/2,a$ sync set ambient light 50 level#=1 lim=0 make object box 100,1,1,1 make mesh from object 1,100 for i=1 to 23 add limb 100,i,1 next i restore ship for y=1 to 7 for x=1 to 7 read r if x=4 and y=3 then goto skip if r=1 offset limb 100,lim,4-x,3-y,0 lim=lim+1 endif skip: next x next y scale object 100,100/7,100/3,100/7 make mesh from object 9,100 make camera 1 color backdrop 1,0 set camera range 1,100000 restore ship for y=1 to 7 for x=1 to 7 read r if r=1 if x=4 and y=2 then ink rgb(150,0,0),rgb(150,0,0) if x=3 and y=3 then ink rgb(0,0,150),rgb(0,0,150) if x=1 and y=6 then ink rgb(255,255,255),rgb(255,255,255) if x=4 and y=6 then ink rgb(0,0,150),rgb(0,0,150) if x=7 and y=6 then ink rgb(255,255,255),rgb(255,255,255) if x=1 and y=7 then ink rgb(0,0,150),rgb(0,0,150) box x*3,y*6,(x+1)*3,(y+1)*6 endif next x next y get image 1,0,0,30,60 cls ink rgb(255,255,255),rgb(255,255,255) line 20,0,20,40 line 0,20,40,20 get image 3,0,0,40,40 cls if a=1 for i=1000 to 1300 a$="Loading..." text screen width()/2-text width(a$)/2,screen height()/2-text height(a$)/2,a$ make object sphere i,5 position object i,rnd(4000)-2000,rnd(2500)-1250,rnd(1000)+1000 next i endif if a=2 and m=1 for i=1000 to 1300 a$="Loading..." text screen width()/2-text width(a$)/2,screen height()/2-text height(a$)/2,a$ make object sphere i,5 position object i,rnd(4000)-2000,rnd(2500)+1000,rnd(2000)-1000 next i endif if a=2 and m=2 for i=1000 to 1150 a$="Loading..." text screen width()/2-text width(a$)/2,screen height()/2-text height(a$)/2,a$ make object sphere i,5 position object i,rnd(4000)-2000,rnd(2500)+1000,rnd(2000)-1000 next i for i=1151 to 3000 a$="Loading..." text screen width()/2-text width(a$)/2,screen height()/2-text height(a$)/2,a$ make object sphere i,5 position object i,rnd(4000)-2000,-1*rnd(2500)-1000,rnd(2000)-1000 next i endif move camera 1,-30 move object down 100,12 color limb 100,0,rgb(150,0,0) color limb 100,14,rgb(0,0,150) for i=1 to 12 color limb 100,i,rgb(0,0,150) next i for i=16 to 23 color limb 100,i,rgb(0,0,150) next i move=1 randomize timer() make light 1 position light 1,object position x(100),object position y(100)+1,object position z(100) point light 1,0,15,0 if a=2 position camera 1,object position x(100),object position y(100),object position z(100)-1 pitch camera up 1,90 endif for i=60 to 67 make object sphere i,.2 position object i,500,0,0 if a=1 then pitch object up i, 90 turn object right i,(i-60)*45 color object i,rgb(100,0,0) next i if p=2 clone object 98,100 color limb 98,0,rgb(0,0,150) color limb 98,14,rgb(150,0,0) for i=1 to 12 color limb 98,i,rgb(150,0,0) next i for i=16 to 23 color limb 98,i,rgb(150,0,0) next i endif sprite 4,0,0,3 if a=2 and p=2 sprite 2,screen width()/2-sprite width(4)/2,screen height()/4+sprite height(4)/2,3 sprite 3,screen width()/2-sprite width(4)/2,screen height()/4*3+sprite height(4)/2,3 endif delete sprite 4 if m=2 then goto duel for i=1 to 10 clone object i,50 color object i,rgb(200,0,185) position object i,1.5*i-8,15-1,0 if a=2 then pitch object up i,90 fix object pivot i next i for i=11 to 20 clone object i,51 color object i,5869458459 position object i,1.5*i-23,15-1-2,0 if a=2 then pitch object up i,90 fix object pivot i next i for i=21 to 30 clone object i,52 color object i,69458459 position object i,1.5*i-38,15-1-4,0 if a=2 then pitch object up i,90 fix object pivot i next i for i=31 to 40 clone object i,53 color object i,948459 position object i,1.5*i-53,15-1-6,0 if a=2 then pitch object up i,90 fix object pivot i next i sprite 4,0,0,3 if a=2 and p=1 then sprite 2,screen width()/2-sprite width(4)/2,screen height()/2+5,3 if a=2 and p=2 sprite 2,screen width()/2-sprite width(4)/2,screen height()/4,3 sprite 3,screen width()/2-sprite width(4)/2,screen height()/4*3,3 make camera 2 set camera view 1,0,0,screen width(),screen height()/2 set camera view 2,0,screen height()/2,screen width(),screen height() color backdrop 2,0 pitch camera up 2,90 position camera 2,object position x(98),object position y(98),object position z(98)-1 endif delete sprite 4 level: if level#<16 then change#=level# for i=1 to 10 position object i,1.5*i-8,15-1,0 show object i next i for i=11 to 20 position object i,1.5*i-23,15-1-2,0 show object i next i for i=21 to 30 position object i,1.5*i-38,15-1-4,0 show object i next i for i=31 to 40 position object i,1.5*i-53,15-1-6,0 show object i next i for i=201 to 204 if object exist(i)=0 make object box i,1,1,1 endif next i position object 201,-8.5,-9.5,0 position object 202,-7.5,-9.5,0 position object 203,-8.5,-10.5,0 position object 204,-7.5,-10.5,0 for i=205 to 208 if object exist(i)=0 make object box i,1,1,1 endif next i position object 205,-0.5,-9.5,0 position object 206,0.5,-9.5,0 position object 207,-0.5,-10.5,0 position object 208,0.5,-10.5,0 for i=209 to 212 if object exist(i)=0 make object box i,1,1,1 endif next i position object 209,8.5,-9.5,0 position object 210,7.5,-9.5,0 position object 211,8.5,-10.5,0 position object 212,7.5,-10.5,0 secret=rnd(39)+1 freezetime=400 four=0 down=0 sync set text size 40 a$="Ready" text screen width()/2-text width(a$)/2,screen height()/2-text height(a$)/2,a$ sync wait 1000 a$="GO!" text screen width()/2-text width(a$)/2,screen height()/2-text height(a$)/2,a$ sync set text size 20 wait 1000 ai#=0 sprite 1,0,0,1 do ti=timer() set text size 30 level$="level "+str$(Change#) lives$=str$(life)+"X " text 0,0,"player 1 score "+str$(score(1)) if p=2 then text 0,text height(lives$),"player 2 score "+str$(score(2)) text screen width()/2-text width(level$)/2,0,level$ text screen width()-text width(lives$),15,lives$ freeze$="Time is frozen for two seconds!" if freeze>1 then text screen width()/2-text width(freeze$),screen width()/2-text height(freeze$),freeze$ if p=2 ship=2 if keystate(30)=1 then gosub left if keystate(32)=1 then gosub right if keystate(31)=1 then gosub fire endif ship=0 if rightkey()=1 then gosub right if leftkey()=1 then gosub left if spacekey()=1 then gosub fire if returnkey()=1 and controlkey()=1 then goto screenshot gosub hit if death>0 death=death-1 for i=60 to 67 move object i,0.025 if death=0 if moveo>0 if object exist (moveo)=1 then hide object moveo position object i,500,0,0 endif endif next i if moveo>0 if object exist (moveo)=1 then move object moveo,-0.25 endif endif if fire(0)>0 and object exist(101)=1 then move object up 101,01 if fire(0)=1 then delete object 101 if fire(0)>0 then fire(0)=fire(0)-1 if fire(0)<5 ticker1=0 tickaway1=0 endif if fire2>0 and object exist(102)=1 then move object down 102,01 if fire2=1 then delete object 102 if fire2>0 then fire2=fire2-1 if fire3>0 and object exist(103)=1 then move object down 103,01 if fire3=1 then delete object 103 if fire3>0 then fire3=fire3-1 if fire4>0 and object exist(104)=1 then move object down 104,01 if fire4=1 then delete object 104 if fire4>0 then fire4=fire4-1 if fire(2)>0 and object exist(105)=1 then move object up 105,01 if fire(2)=1 then delete object 105 if fire(2)>0 then fire(2)=fire(2)-1 if fire(2)<5 ticker2=0 tickaway2=0 endif if fire(3)>0 and object exist(108)=1 then move object up 108,01 if fire(3)=1 then delete object 108 if fire(3)>0 then fire(3)=fire(3)-1 if fire(4)>0 and object exist(107)=1 then move object up 107,01 if fire(4)=1 then delete object 107 if fire(4)>0 then fire(4)=fire(4)-1 if tickaway1=1 then ticker1=ticker1+1 if tickaway2=1 then ticker2=ticker2+1 if freezetime>0 then freezetime=freezetime-1 if freeze>0 then freeze=freeze-1 if freeze=0 then ai#=ai#+1 if ai#=20-change# and freeze<1 then gosub ai gosub hit if a=2 then position camera 1,object position x(100),object position y(100),object position z(100)-1 if a=2 and p=2 then position camera 2,object position x(98),object position y(98),object position z(98)-1 sprite 1,screen width()-sprite width(1),sprite height(1)/2-35,1 tm=timer() ti=25-(tm-ti) wait ti sync loop right: if ri(ship)<18 move object right 100-ship,1 endif if ri(ship)<18 then ri(ship)=ri(ship)+1 return left: if ri(ship)>-18 move object left 100-ship,1 endif if ri(ship)>-18 then ri(ship)=ri(ship)-1 return fire: if object exist(101+2*ship)=0 if ship=0 then tickaway1=1 if ship=2 then tickaway2=1 play sound 16 make object box 101+2*ship,.1,1,.1 shots(ship)=shots(ship)+1 set object radius 101+2*ship,.3 position object 101+2*ship,object position x(100-ship), object position y(100-ship),object position z(100-ship) color object 101+2*ship,rgb(150,0,0) fire(ship)=35 endif if ship=2 and ticker2>10 if object exist(107)=0 and object exist(105)=1 shots(ship)=shots(ship)+1 ticker2=0 tickaway2=0 play sound 16 make object box 107,.1,1,.1 set object radius 107,.3 position object 107,object position x(100-ship), object position y(100-ship),object position z(100-ship) color object 107,rgb(150,0,0) fire(4)=35 endif endif if ship=0 and ticker1>10 if object exist(108)=0 and object exist(101)=1 shots(ship)=shots(ship)+1 ticker1=0 tickaway1=0 play sound 16 make object box 108,.1,1,.1 set object radius 108,.3 position object 108,object position x(100-ship), object position y(100-ship),object position z(100-ship) color object 108,rgb(150,0,0) fire(3)=35 endif endif return ai: play sound 18 for i=1 to 40 if object exist(i) move object right i,move if i<11 and i>0 if sw=1 offset limb i,l(1),-2,-4,0 offset limb i,l(2),2,-4,0 else offset limb i,l(1),-1,-3,0 offset limb i,l(2),1,-3,0 endif endif if i<21 and i>10 if sw=1 offset limb i,l(3),-4,0,0 offset limb i,l(4),4,0,0 else offset limb i,l(3),-3,-1,0 offset limb i,l(4),3,-1,0 endif endif if i<31 and i>20 if sw=1 offset limb i,l(5),-3,-3,0 offset limb i,l(6),3,-3,0 else offset limb i,l(5),-3,-4,0 offset limb i,l(6),3,-4,0 endif endif if i<41 and i>30 if sw=1 offset limb i,l(7),-2,-3,0 offset limb i,l(8),2,-3,0 else offset limb i,l(7),-1,-3,0 offset limb i,l(8),1,-3,0 endif endif endif next i if sw=1 sw=0 else sw=1 endif k=rnd(39)+1 if object visible(k)=1 and object exist(102)=0 play sound 16 make object box 102,.1,1,.1 fire2=35 position object 102,object position x(k), object position y(k),object position z(k) color object 102,rgb(150,0,0) endif if dif>1 k=rnd(39)+1 if object visible(k)=1 and object exist(103)=0 play sound 16 make object box 103,.1,1,.1 fire3=35 position object 103,object position x(k), object position y(k),object position z(k) color object 103,rgb(150,0,0) endif endif if dif>2 k=rnd(39)+1 if object visible(k)=1 and object exist(104)=0 play sound 16 make object box 104,.1,1,.1 fire4=35 position object 104,object position x(k), object position y(k),object position z(k) color object 104,rgb(150,0,0) endif endif ai#=0 four=four+move if four=8 play sound 19 for i=1 to 40 if object exist(i)=1 move object down i,1 endif next i down=down+1 move=-1 endif if four=-8 for i=1 to 40 if object exist(i)=1 move object down i,1 endif next i down=down+1 move=1 endif if down=15 then goto theend return hit: if object exist(101)=1 set object collision to polygons 101 o=object collision(101,0) if o>0 if 0<o and object visible(o)=1 and o<41 or o>200 and o<250 for i=60 to 67 position object i,object position x(o),object position y(o),object position z(o) next i death=20 fire(0)=0 if o<41 if moveo>0 then hide object moveo moveo=o else delete object o endif delete object 101 play sound 17 if secret=o and freezetime>0 then freeze=80 if o<200 shots(1)=shots(1)+1 score(1)=score(1)+10 score#(1)=score(1) score#(1)=score#(1)/1000 endif if score#(1)>int(score#(1))-0.000001 and score#(1)<int(score#(1))+0.000001 and score#(1)>0 then life=life+1 if int(score(1)+score(2))=400*level# then goto youwin endif endif endif if object exist(105)=1 set object collision to polygons 105 o=object collision(105,0) if o>0 if 0<o and object visible(o)=1 and o<41 or o>200 and o<250 for i=60 to 67 position object i,object position x(o),object position y(o),object position z(o) next i death=20 if o<41 if moveo>0 then hide object moveo moveo=o else delete object o endif delete object 105 fire(2)=0 play sound 17 if secret=o and freezetime>0 then freeze=80 if o<200 score(2)=score(2)+10 score#(2)=score(2) score#(2)=score#(2)/1000 endif if score#(2)>int(score#(2))-0.000001 and score#(2)<int(score#(2))+0.000001 and score#(2)>0 then life=life+1 if int(score(1)+score(2))=400*level# then goto youwin endif endif endif if object exist(107)=1 set object collision to polygons 107 o=object collision(107,0) if o>0 if 0<o and object visible(o)=1 and o<41 or o>200 and o<250 for i=60 to 67 position object i,object position x(o),object position y(o),object position z(o) next i death=20 if o<41 if moveo>0 then hide object moveo moveo=o else delete object o endif delete object 107 fire(4)=0 play sound 17 if secret=o and freezetime>0 then freeze=80 if o<200 score(2)=score(2)+10 score#(2)=score(2) score#(2)=score#(2)/1000 endif if score#(2)>int(score#(2))-0.000001 and score#(2)<int(score#(2))+0.000001 and score#(2)>0 then life=life+1 if int(score(1)+score(2))=400*level# then goto youwin endif endif endif if object exist(108)=1 set object collision to polygons 108 o=object collision(108,0) if o>0 if 0<o and object visible(o)=1 and o<41 or o>200 and o<250 for i=60 to 67 position object i,object position x(o),object position y(o),object position z(o) next i death=20 if o<41 if moveo>0 then hide object moveo moveo=o else delete object o endif delete object 108 fire(3)=0 play sound 17 if secret=o and freezetime>0 then freeze=80 if o<200 shots(1)=shots(1)+1 score(1)=score(1)+10 score#(1)=score(1) score#(1)=score#(1)/1000 endif if score#(1)>int(score#(1))-0.000001 and score#(1)<int(score#(1))+0.000001 and score#(1)>0 then life=life+1 if int(score(1)+score(2))=400*level# then goto youwin endif endif endif if object exist(102)=1 set object collision to polygons 102 o2=object collision(102,0) if o2=100 or o2=98 if o2=98 then ship=2 if o2=100 then ship=0 delete object 102 gosub losealife fire2=0 endif if object exist(102)=1 o2=object collision(102,0) if o2>200 delete object o2 delete object 102 fire2=0 endif endif endif o3=0 if object exist(103)=1 set object collision to polygons 103 o3=object collision(103,0) if o3=98 or o3=100 if o3=98 then ship=2 if o3=100 then ship=0 delete object 103 gosub losealife fire3=0 endif if object exist(103)=1 o3=object collision(103,0) if o3>200 delete object o3 delete object 103 fire3=0 endif endif endif o4=0 if object exist(104)=1 set object collision to polygons 104 o4=object collision(104,0) if o4=98 or o4=100 if o4=98 then ship=2 if o4=100 then ship=0 delete object 104 gosub losealife fire4=0 endif if object exist(104)=1 o4=object collision(104,0) if o4>200 delete object o4 delete object 104 fire4=0 endif endif endif return youwin: hide object moveo moveo=0 death=0 cls for i=60 to 67 position object i,500,0,0 next i death=0 sync a$="You win press any key to go to the next level!" text 0,0,a$ if p=1 text 0,100,"shots fired "+str$(shots(0)) text 0,200,"40 hits" endif if p=2 text 0,100,"shots fired player one "+str$(shots(0)) text 0,200,str$(shots(1)) + " hits for player one" text 0,300,"shots fired player two "+str$(shots(2)) text 0,400,str$(40-shots(1)) + " hits for player two" endif sync wait 1000 level#=level#+1 shots(0)=0 shots(1)=0 shots(2)=0 suspend for key goto level function button(caption$,size,top,number) if mousex()>screen width()/2-5*size and mousex()<screen width()/2+5*size and mousey()>top and mousey()<top+4*size then ink rgb(100,100,0), rgb(100,100,0) line screen width()/2-5*size,top,screen width()/2+5*size,top line screen width()/2-5*size,top,screen width()/2-5*size,top+4*size line screen width()/2-5*size,top+4*size,screen width()/2+5*size,top+4*size line screen width()/2+5*size,top+4*size,screen width()/2+5*size,top ink rgb(255,255,255),rgb(255,255,255) text screen width()/2-text width(caption$)/2,top+2*size-text height(caption$)/2,caption$ if mousex()>screen width()/2-5*size and mousex()<screen width()/2+5*size and mousey()>top and mousey()<top+4*size and mouseclick()=1 if number=1 then gosub play if number=2 then gosub Version if number=3 then gosub Difficulty if number=4 then gosub Controlls if number=5 then gosub players if number=6 then gosub mode endif goto back Play: goto play2 return Version: if a=1 global a=2 else global a=1 endif wait 150 cls return Difficulty: if dif=1 global dif=2 goto difend endif if dif=2 global dif=3 goto difend endif if dif=3 global dif=1 goto difend endif difend: wait 150 cls return Controlls: if c=1 cls c=0 goto ret endif if c=0 text 0,300,"Arrows to move, space bar to shoot." text 0,350,"There are two difficulty settings." text 0,400,"Try first person mode!" text 0,450,"One enemy each time has the time freezer." text 0,500,"If you kill that enemy in the first ten seconds" text 0,550,"You will freeze time for two seconds." text 0,600,"2 player controlls are a=left d=right and s=fire" text 0,650,"Try co-op mode still only three lives for the both of you." text 0,700,"Try duel mode to settle who is the better space invaders player." c=1 endif ret: return players: if p=1 global p=2 else global p=1 endif wait 150 cls return mode: if m=1 global m=2 else global m=1 endif wait 150 cls return back: endfunction losealife: for i=101 to 108 if object exist(i)=1 then delete object i next i right=90 play sound 1 sync hide object 100-ship for i=60 to 67 position object i,object position x(100-ship),object position y(100-ship),object position z(100-ship) next i death=20 do if death>0 death=death-1 for i=60 to 67 move object i,0.1 if death=0 position object i,500,0,0 endif next i endif right=-right turn camera right 1,right move camera 1,0.1 turn camera left 1,right if p=2 and a=2 turn camera right 2,right move camera 2,0.1 turn camera left 2,right endif wait 50 sync if death=0 then goto outofdeath loop outofdeath: show object 100-ship life=life-1 if life=0 then goto theend set text size 40 a$="Ready" text screen width()/2-text width(a$)/2,screen height()/2-text height(a$)/2,a$ sync wait 1000 a$="GO!" text screen width()/2-text width(a$)/2,screen height()/2-text height(a$)/2,a$ sync wait 1000 set text size 20 return topalien: data 0,0,0,1,0,0,0 data 0,0,1,1,1,0,0 data 0,1,0,1,0,1,0 data 1,1,1,1,1,1,1 data 0,1,1,1,1,1,0 data 0,1,0,1,0,1,0 data 1,0,1,0,1,0,1 twoalien: data 0,0,1,0,0,0,1,0,0 data 0,0,0,1,0,1,0,0,0 data 0,0,1,1,1,1,1,0,0 data 0,1,1,0,1,0,1,1,0 data 0,1,0,1,1,1,0,1,0 data 0,0,1,0,0,0,1,0,0 data 0,0,0,1,0,1,0,0,0 threealien: data 0,0,0,0,0,0,0 data 0,0,1,1,1,0,0 data 0,1,1,1,1,1,0 data 1,1,1,1,1,1,1 data 1,1,0,1,0,1,1 data 1,1,1,1,1,1,1 data 0,0,1,0,1,0,0 data 0,1,0,1,0,1,0 data 1,0,0,0,0,0,1 fouralien: data 0,0,1,1,1,0,0 data 0,1,1,1,1,1,0 data 1,1,0,1,0,1,1 data 0,1,1,0,1,1,0 data 0,0,1,1,1,0,0 data 0,1,0,0,0,1,0 data 0,0,1,0,1,0,0 ship: data 0,0,0,0,0,0,0 data 0,0,0,1,0,0,0 data 0,0,1,1,1,0,0 data 1,1,1,1,1,1,1 data 0,0,1,1,1,0,0 data 1,0,0,1,0,0,1 data 1,1,1,1,1,1,1 the: data 1,1,1,1,1,0,1,0,0,1,0,1,1,1,0 data 0,0,1,0,0,0,1,0,0,1,0,1,0,0,0 data 0,0,1,0,0,0,1,1,1,1,0,1,1,1,0 data 0,0,1,0,0,0,1,0,0,1,0,1,0,0,0 data 0,0,1,0,0,0,1,0,0,1,0,1,1,1,0 renewed: data 1,1,1,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1,0,1,1,0 data 1,0,1,0,1,0,0,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1 data 1,1,1,0,1,1,1,0,1,0,1,0,1,0,1,1,1,0,0,1,0,0,1,0,0,1,0,0,1,1,1,0,1,0,1 data 1,1,0,0,1,0,0,0,1,0,0,1,1,0,1,0,0,0,0,1,0,1,0,1,0,1,0,0,1,0,0,0,1,0,1 data 1,0,1,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,0,1,1,0 space: data 1,1,1,0,1,1,1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,1 data 1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,1,0,0 data 1,1,1,0,1,1,1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,1,1 data 0,0,1,0,1,0,0,0,0,1,1,1,1,1,0,0,1,0,0,0,1,0,0 data 1,1,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,1,1,0,1,1,1 invaders: data 1,1,1,1,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1 data 0,0,1,0,0,0,1,1,0,0,1,0,0,1,0,0,0,1,0,0,0,0,1,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,1,0,1,0,0 data 0,0,1,0,0,0,1,0,1,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,1,0,1,1,1,0,1,1,1,0,1,1,1 data 0,0,1,0,0,0,1,0,0,1,1,0,0,0,1,0,1,0,0,0,0,1,1,1,1,1,0,0,1,0,1,0,1,0,0,0,1,1,0,0,0,0,1 data 1,1,1,1,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,1,1,0,0,1,1,1,0,1,0,1,0,1,1,1 theend: delete sprite 1 if sprite exist(2) then delete sprite 2 if sprite exist(3) then delete sprite 3 right=0 for i=1 to 212 if object exist(i)=1 then delete object i next i if light exist(1)=0 then make light 1 position light 1,0,0,250 point light 1,0,20,400 delete object 60 delete object 61 make object sphere 60,5 set ambient light 1 color object 60,rgb(0,0,100) make object sphere 61,100 move object 61,400 move object up 61,40 color object 61,rgb(200,200,0) move camera 1,-30 for i= 1 to 50 make object i,rnd(3)+2,0 position object i,i-25,0,-150 color object i,rgb(rnd(255),rnd(255),rnd(255)) next i s=20 do if sound playing(s-1)=0 and s<23 play sound s s=s+1 endif a$="Sheydkd gaidnkl ikslirk!!!!" b$="Translation: Destroy all life!!!!" c$="YOU LOSE" text screen width()/2-text width(a$)/2,screen height()-text height(a$)*3,a$ text screen width()/2-text width(b$)/2,screen height()-text height(a$)*2,b$ set text size 40 text screen width()/2-text width(c$)/2,screen height()/2-text height(a$),c$ wait 50 for i=1 to 50 move object i,1 next i right=right+1 if right>140 then end sync loop duel: move object up 98,24 roll object right 98,180 if a=1 then fix object pivot 98 if a=2 make camera 2 pitch camera up 2,90 turn camera right 2,180 set camera view 1,0,0,screen width(),screen height()/2 set camera view 2,0,screen height()/2,screen width(),screen height() color backdrop 2,0 scale object 100,100,100,250 scale object 98,100,100,250 endif do if a=2 position camera 1,object position x(100),object position y(100),object position z(100)-4 position camera 2,object position x(98),object position y(98),object position z(98)-4 endif ship=2 if keystate(30)=1 then gosub left if keystate(32)=1 then gosub right if keystate(31)=1 then gosub dfire2 ship=0 if rightkey()=1 then gosub right if leftkey()=1 then gosub left if spacekey()=1 then gosub dfire1 if fire(0)>0 then move object up 101,03 if fire(0)=1 then delete object 101 if fire(0)>0 then fire(0)=fire(0)-1 if fire(2)>0 then move object up 102,03 if fire(2)=1 then delete object 102 if fire(2)>0 then fire(2)=fire(2)-1 if fire(3)>0 then move object down 103,03 if fire(3)=1 then delete object 103 if fire(3)>0 then fire(3)=fire(3)-1 if fire(4)>0 then move object down 104,03 if fire(4)=1 then delete object 104 if fire(4)>0 then fire(4)=fire(4)-1 gosub dhit wait 50 sync loop dfire1: if object exist(101)=0 make object box 101,.1,1,.1 play sound 16 set object radius 101,.3 position object 101,object position x(100), object position y(100),object position z(100) color object 101,rgb(150,0,0) fire(0)=35 goto dfire1exit endif if object exist(101)=1 and object exist(102)=0 and fire(0)<31 make object box 102,.1,1,.1 play sound 16 set object radius 102,.3 position object 102,object position x(100), object position y(100),object position z(100) color object 102,rgb(150,0,0) fire(2)=35 endif dfire1exit: return dfire2: if object exist(103)=0 make object box 103,.1,1,.1 play sound 16 set object radius 103,.3 position object 103,object position x(98), object position y(98),object position z(98) color object 103,rgb(150,0,0) fire(3)=35 goto dfire2exit endif if object exist(103)=1 and object exist(104)=0 and fire(3)<31 make object box 104,.1,1,.1 play sound 16 set object radius 104,.3 position object 104,object position x(98), object position y(98),object position z(98) color object 104,rgb(150,0,0) fire(4)=35 endif dfire2exit: return dhit: if object exist(101)=1 set object collision to polygons 101 if object collision(101,98) goto p1wins endif endif if object exist(102)=1 set object collision to polygons 102 if object collision(102,98) goto p1wins endif endif if object exist(103)=1 set object collision to polygons 103 if object collision(103,100) goto p2wins endif endif if object exist(104)=1 set object collision to polygons 104 if object collision(104,100) goto p2wins endif endif return p1wins: if sprite exist(2) then delete sprite 2 if sprite exist(3) then delete sprite 3 cls set text size 40 a$="Player 1 Wins!" text screen width()/2-text width(a$)/2,screen height()/2-text height(a$)/2,a$ sync suspend for key end p2wins: if sprite exist(2) then delete sprite 2 if sprite exist(3) then delete sprite 3 cls set text size 40 a$="Player 2 Wins!" text screen width()/2-text width(a$)/2,screen height()/2-text height(a$)/2,a$ sync suspend for key end screenshot: get image 2,0,0,screen width(),screen height() save image "image.jpg",2 end `Ric's sound creator its awsome!!! function createsound(name$,soundnumber,frequency#,length#,loudness#,bend#,decay#,vibratospeed#,vibratodepth#,tremelospeed#,tremelodepth#,attack#) outWord as word dword1 as dword: dword2 as dword: dword3 as dword: dword4 as dword dword5 as dword: dword6 as dword: dword7 as dword samples=int((length#/1000)*44100) if memblock exist(1) then delete memblock 1 make memblock 1,samples*2+28 ` write 28 memblock header bytes dword1=1 ` gg query: is this the number of channels? dword2=2 ` gg query: is this the number of bytes per sample? dword3=22050 ` gg query: seems to be half the number of samples per second - why? dword4=88200 ` gg query: is this the number of bytes per second? dword5=4 ` gg query: what does this represent? dword6=16 ` gg query: (ditto) ? dword7=0 ` gg query: (ditto) ? position=0 write memblock dword 1, position, dword1 : inc position,4 write memblock dword 1, position, dword2 : inc position,4 write memblock dword 1, position, dword3 : inc position,4 write memblock dword 1, position, dword4 : inc position,4 write memblock dword 1, position, dword5 : inc position,4 write memblock dword 1, position, dword6 : inc position,4 write memblock dword 1, position, dword7 : inc position,4 rem generate and write wave riseinloudness#=loudness# for x=1 to samples outInteger=int(sin((x/122.5)*(frequency#+vibratodepth#*sin(theta#)))*(loudness#-fallinloudness#-riseinloudness#+tremelodepth#*sin(phi#)))*3.0 if outInteger <-32767 then outInteger=-32767 ` gg query: is this the valid range? if outInteger>32767 then outInteger=32767 ` gg query: (ditto) ? outWord=outInteger inc theta#,vibratospeed# inc phi#,tremelospeed# dec frequency#,bend# if fallinloudness#<loudness# inc fallinloudness#,decay# endif if riseinloudness#>0 dec riseinloudness#,attack# endif write memblock word 1, position, outWord : inc position,2 next x if sound exist(soundnumber)=1 then delete sound soundnumber make sound from memblock 999, 1 ` assumes you won't need sound number 999! clone sound soundnumber, 999 delete sound 999 ` memblock no longer required delete memblock 1 endfunction function song(songnumber,playafter,endingnumber,note1,note2,note3,note4,note5,note6,note7,note8,note9,note10) if pa=songnumber if sound exist(finnalnote)=0 if p1=-1 play sound note1 global finnalnote=note1 p1=0 endif endif if sound exist(finnalnote)=1 if sound playing(finnalnote)=0 and p1=-1 play sound note1 p1=0 global finnalnote=note1 endif endif if 1=endingnumber goto outofsongunct endif if sound playing(note1)=0 and p1=0 and sound exist(note2)=1 play sound note2 global finnalnote=note2 p1=1 endif if 2=endingnumber goto outofsongunct endif if sound playing(note2)=0 and p1=1 and sound exist(note3)=1 play sound note3 global finnalnote=note3 p1=2 endif if 3=endingnumber goto outofsongunct endif if sound playing(note3)=0 and p1=2 and sound exist(note4)=1 play sound note4 global finnalnote=note4 p1=3 endif if 4=endingnumber goto outofsongunct endif if sound playing(note4)=0 and p1=3 and sound exist(note5)=1 play sound note5 global finnalnote=note5 p1=4 endif if 5=endingnumber goto outofsongunct endif if sound playing(note5)=0 and p1=4 and sound exist(note6)=1 play sound note6 global finnalnote=note6 p1=5 endif if 6=endingnumber goto outofsongunct endif if sound playing(note6)=0 and p1=5 and sound exist(note7)=1 play sound note7 global finnalnote=note7 p1=6 endif if 7=endingnumber goto outofsongunct endif if sound playing(note7)=0 and p1=6 and sound exist(note8)=1 play sound note8 global finnalnote=note8 p1=7 endif if 8=endingnumber goto outofsongunct endif if sound playing(note8)=0 and p1=7 and sound exist(note9)=1 play sound note9 global finnalnote=note9 p1=8 endif if 9=endingnumber goto outofsongunct endif if sound playing(note9)=0 and p1=8 and sound exist(note10)=1 play sound note10 p1=9 global finnalnote=note10 endif outofsongunct: if p1=endingnumber-1 and sound playing(endingnumber)=0 global pa=playafter global p1=-1 global check=0 endif endif endfunction