Hello!
This is my first "20 line" program/game, I know the coding's pretty sloppy but it should work (does for me).
This took me about 5 hours to make (I'm a n00b
). Please feel free to improve the code where you see fit and post it here, looking forward to seeing improved versions of this
(My best score is 122 blocks with 258 bullets)
How to play:
Your gun is positioned at the bottom right side of the screen, you are to defend the entire right side of the screen by shooting the blocks that come from the left side of the screen.
Each block you kill, the spawn delay's reduced. After a little while, the speed will start to increase. There's no winning, just surviving as long as possible
Controls:
Mouse to aim, left click to shoot, esc to exit.
sync on : sync rate 60 : set display mode desktop width(), desktop height(), screen depth() : maximize window : autocam off : position camera 0,0,25,-50 : color backdrop RGB(0,0,0) : hide mouse
make object box 1,200,1,30 : make object box 2,10,10,10 : position object 2,45,5,0 : make object box 3,1,1,5 : position object 3,41,5,0 : offset limb 3,0,0.5,0.5,2.5 : shootdelay=15 : makedelay=100 : score=0 : hit=0 : speed#=0.2 : shots=0
DO : pick screen mousex(),mouseY(),1 : PickX#=get pick vector x() : PickY#=get pick vector y() : PickZ#=get pick vector z() : PickDistance#=-camera position z()/PickZ# : PickX#=PickX#*PickDistance#+camera position x() : PickY#=PickY#*PickDistance#+camera position y() : point object 3,PickX#,PickY#,0
inc shoot : IF Mouseclick()=1 AND shoot>=shootdelay : bullet=9999 : ObjectEnd=0 : REPEAT INC bullet : INC Shots : IF Object exist(bullet)=0 THEN Inc ObjectEnd,1
UNTIL ObjectEnd=1 : make object sphere bullet,1; position object bullet,40,6,1; shoot=0; point object bullet,PickX#,PickY#,0 : set Object collision on bullet : ENDIF
FOR A = 0 to 20 : IF Object exist(10000+A)=1 THEN move object 10000+A,5
NEXT A : FOR B = 0 to 20 : IF Object exist(100+B)=1 THEN Move object 100+B,speed#
NEXT B : ObjectEnd=0 : badman=99 : REPEAT : INC badman : IF Object exist(badman)=0 THEN Inc ObjectEnd,1
UNTIL ObjectEnd=1 OR badman=120 : IF badman=120 THEN ELSE IF make>=makedelay THEN Make object box badman,RND(3)+2,RND(5)+2,RND(2)+3 : set Object collision on badman : rotate object badman,0,90,0 : position object badman,-75,RND(40)+7,0 : make=0
inc make : FOR C = 0 to 20 : FOR D = 0 to 20 : IF Object exist(100+C)=1 AND Object exist(10000+D)=1 THEN IF Object collision(100+C,10000+D)=1 THEN Delete object 100+C; Delete object 10000+D; IF makedelay<=30 : inc speed#,0.01 : IF speed#>0.4 : speed#=0.4 : ENDIF ELSE Dec makedelay,2 : ENDIF : inc score,1
IF Object exist(10000+D)=0 THEN ELSE IF Object position X(10000+D)<-100 OR Object position X(10000+D)>100 OR Object position Y(10000+D)>100 OR Object position Y(10000+D)<-20 THEN Delete object 10000+D
NEXT D : IF Object exist(100+C)=0 THEN ELSE IF Object position X(100+C)>=60 THEN Delete object 100+C; inc hit,1
NEXT C : Circle MouseX(),MouseY(),5 : Dot MouseX(),MouseY(),RGB(255,20,20)
TEXT 10,10,"Kills: "+Str$(score) : TEXT 10,30,"Pass: "+Str$(hit)+"/5" : IF hit>=5 THEN Show mouse : CENTER TEXT desktop width()/2,desktop height()/2,"GAME OVER! You killed "+Str$(score)+" blocks with "+Str$(shots)+" bullets, You monster..." : sync : REPEAT UNTIL escapekey()=1
`text 10,100,"Box make delay: "+Str$(makedelay) : text 10,120,"Box speed: "+Str$(speed#) : text 10,140,"Current bullet: "+Str$(bullet)
SYNC : LOOP