back from a hiatus of insanity,
IBOL returns to the 20-line challenge.
this 3d shooter features innovative action, progressively harder levels,
timer-based movement, and even saves your high scores!
no media, the program does it all in just 18 lines.
screenshot:
Code as 20-Liner:
set display mode 640,480,32 : sync on : sync rate 0 : sync : randomize timer() : autocam off : color backdrop 0 : hide mouse : dim level(50) : level(1)=1 : MGS#=0.01225 : nme=4 : shot#=0.0 : newEX=0 : global gs# : SET TEXT FONT "ARIAL" : SET TEXT SIZE 28 : SET TEXT TO BOLD : shots=1 : hits=1
if file exist("AirborneDefenseHighScores.txt") : open to read 1,"AirborneDefenseHighScores.txt" : read long 1,HiScore : close file 1 : endif : make object cube 1,1 : yrotate object 1,45 : make mesh from object 1,1 : yrotate object 1,0 : scale object 1,250,250,250 : add limb 1,1,1 : offset limb 1,1,-.5,-.5,-.5 : add limb 1,2,1 : offset limb 1,2,.5,-.5,.5 : add limb 1,3,1 : offset limb 1,3,.5,-.5,-.5 : add limb 1,4,1 : offset limb 1,4,-.5,-.5,.5 : scale object 1,180,280,180 : make mesh from object 6,1 : delete object 1
make object sphere 1,4.4 : make object cone 2,3 : xrotate object 2,180 : make mesh from object 3,2 : add limb 1,1,3 : offset limb 1,1,0,-3,0 : make object cone 3,3 : scale object 3,100,100,10 : make mesh from object 4,3 : add limb 1,2,4 : add limb 1,3,4 : rotate limb 1,3,0,90,0 : offset limb 1,2,0,-3,0 : offset limb 1,3,0,-3,0 : make mesh from object 5,1 : delete object 1 : delete object 2 : delete object 3
create bitmap 1,16,16 : box 0,0,15,15,0,0,0,0 : for g=1 to 300 : dot rnd(15),rnd(15),rgb(rnd(50),100+rnd(100),rnd(100)) : next g : get image 11,0,0,15,15 : delete bitmap 1 : make object cone 10,5 : scale object 10,35,150,35 : make object cone 11,9 : scale object 11,120,45,120 : make mesh from object 11,11 : add limb 10,1,11 : scale limb 10,1,50,50,50 : offset limb 10,1,0,3,0 : add limb 10,2,11 : add limb 10,3,11 : scale limb 10,3,135,135,135 : offset limb 10,3,0,-3,0 : make mesh from object 10,10
for g=2001 to 2050 : make object g,10,11 : scale object g,150+rnd(150),150+rnd(150),150+rnd(150) : repeat : a=rnd(300)-150 : b=rnd(300)-150 : until (a>50 or a<-50) or (b>50 or b<-50) : position object g,a,0,b : set object light g,0 : next g
delete object 10 : delete object 11 : create bitmap 1,16,16 : box 0,0,15,15 : ink rgb(173,23,223),0 : for t=0 to 16 step 4 : for u=0 to 16 step 4 : box t,u,t+2,u+2 : next u : next t : get image 1,0,0,15,15 : delete bitmap 1 :create bitmap 1,16,16 : ink RGB(255,128,64),0 : box 0,0,15,15 : ink RGB(0,128,64),0 : circle 7,7,3 : circle 7,7,5 : get image 2,0,0,15,15 :delete bitmap 1
create bitmap 1,640,480 : for t=0 to 5 : ink rgb(255-t*30,255-t*30,255-t*30),0 : box t,t,640-t,480-t : next t : for y=5 to 475 : ink rgb(y/3,y/5,y/2),0 : line 5,y,635,y : next y : ink 0,0 : box 150,0,490,400 : get image 3,0,0,640,480 : delete bitmap 1 : create bitmap 1,16,16 : ink rgb(0,255,0),0 : box 0,0,15,15 : for t=1 to 100 : dot rnd(15),rnd(15),rgb(rnd(50),100+rnd(100),rnd(50)) : next t : get image 4,0,0,15,15 : delete bitmap 1
create bitmap 1,32,32 : ink rgb(0,0,200),0 : box 0,0,31,31 : ink rgb(255,255,255),0 : for g=1 to 500 : dot rnd(31),rnd(31) : next g : for t=15 to 20 : ink RGB(128+rnd(32),64+rnd(16),0),0 : line 0,t,31,t : next t : blur bitmap 1,1.25 : get image 5,0,0,31,31 : delete bitmap 1 : create bitmap 1,2,2 : dot 0,0,rgb(255,0,0) : get image 6,0,0,1,1 : delete bitmap 1 : make object sphere 500,300 : set object cull 500,0 : set object light 500,0 : texture object 500,5 : set object collision off 500
ink rgb(155,155,255),0 : for t=1 to 10 : for u=1 to 10 : inc x : make object x,6,1 : set object collision to boxes x : position object x,t*7-35,0,u*7-35 : next u : next t : for t=0 to 9 : for u=0 to 9 : x=1000+(t*10)+u : make object sphere x,0.55 : set object collision off x : texture object x,6 : next u : next t : make matrix 1,400,400,48,48 : position matrix 1,-200,-7,-200 : prepare matrix texture 1,4,1,1 : fill matrix 1,0,1 : randomize matrix 1,6 : update matrix 1
MOVE CAMERA -75 : sync : INK 0,0 : paste image 3,0,0,1 : center text 320,20,"AIRBORNE DEFENSE" : center text 320,60,"Use mouse and left click to" : center text 320,80,"shoot enemies as they" : center text 320,100,"try to steal your blocks." : center text 320,140,"Score more points for" : center text 320,160,"enemies carrying blocks." : center text 320,270,"Game ends when you have" : center text 320,290,"less than 10 blocks left." : center text 320,330,"Click Mouse To Begin!" : sync : repeat : until mouseclick() : t1#=timer() : position mouse 320,120
do : paste image 3,0,0,1 : gs#=((timer()-t1#)*MGS#) : t1#=timer() : walk#=wrapvalue(walk#+gs#) : position camera 0,sin(walk#)*115,55,cos(walk#)*115 : point camera 0,0,0,0 : for t=1 to 100 : if object visible(t) : if object position y(t)>0 : move object down t,gs# : endif : endif : next t : for t=101 to 100+nme : if object exist(t)=0 : make object t,5,2 : set object collision to boxes t : set object light t,0 : position object t,(rnd(9)+1)*7-35,70+rnd(9),(rnd(9)+1)*7-35 : endif : if object exist(t) : if object visible(t) : move object down t,gs#*2 : v=object collision(t,0)
if v>0 and v<101 : move object up t,gs#*6 : move object up v,gs#*5.1 : endif : if object position y(t)>80 or object position y(t)<-10 : if v>0 and v<101 : hide object v : position object v,-999,-999,-999 : set object collision off v : endif : position object t,(rnd(9)+1)*7-35,70+rnd(9),(rnd(9)+1)*7-35 : endif : endif : endif : next t
dec shot#,gs# : if shot#>0 : ink rgb(0,0,100),0 : else : ink rgb(255,0,0),0 : endif : for t=3 to 5 : circle mousex(),mousey(),t : next t : if mouseclick() : if shot#<0.0 : shot#=3.75 : inc shots : a=pick object(mousex(),mousey(),101,100+nme) : if a>99 : if NewEX>8 : NewEX=0 : endif
inc score,10+(level/5)*5 : inc hits : for f=1 to 100 : if object visible(f) : if object collision(a,f)=1 : inc score,10+(level*5) : exit : endif : endif : next f : for u=1 to 10 : x=1000+(NewEX*10)+u : position object x,object position x(a),object position y(a),object position z(a) : rotate object x,rnd(359),rnd(359),rnd(359) : next u : inc NewEX : position object a,0,90,0 : endif : endif : endif
for t=0 to 9 : for u=0 to 9 : x=1000+(t*10)+u : move object x,gs#*3.357 : next u : next t : level=score/250+1 : if level>50 : level=50 : endif : if level(level)=0 : level(level)=1 : if level mod 2=0 : inc nme : else : inc MGS#,0.0025 : endif : endif : ink rgb(155,155,255),0 : cubes=0 : for t=1 to 100 : if object visible(t) : inc cubes : endif : next t
center text 70,50,"SCORE" : CENTER TEXT 70,68,STR$(SCORE) : center text 70,100,"BLOCKS" : CENTER TEXT 70,118,STR$(CUBES) : center text 70,150,"LEVEL" : CENTER TEXT 70,168,STR$(LEVEL) : center text 560,50,"SHOTS" : CENTER TEXT 560,68,STR$(SHOTS-1) : center text 560,100,"HITS" : CENTER TEXT 560,118,STR$(HITS-1) : center text 560,150,"RATIO" : R#=(100.0*(HITS))/(SHOTS) : CENTER TEXT 560,168,STR$(int(r#))+"%" : center text 320,420,"HIGH SCORE" : center text 324,440,str$(hiscore)
if cubes<10 : ink 0,0 : center text 320,70,"GAME OVER!" : center text 320,95,"Your Final Score:" : center text 320,115,str$(score) : center text 320,305,"(click mouse to exit)" : if score>HiScore : center text 320,200,"YOU GOT THE" : CENTER TEXT 320,220,"NEW HIGH SCORE!" : if file exist("AirborneDefenseHighScores.txt") : delete file "AirborneDefenseHighScores.txt" : endif : open to write 1,"AirborneDefenseHighScores.txt" : write long 1,score : close file 1 : endif : sync : wait 3000 : repeat : until mouseclick() : end : endif
sync : loop
and here's the code all spread out so you can look at it:
set display mode 640,480,32
sync on
sync rate 0
sync
randomize timer()
autocam off
color backdrop 0
hide mouse
dim level(50)
level(1)=1
MGS#=0.01225
nme=4
shot#=0.0
newEX=0
global gs#
SET TEXT FONT "ARIAL"
SET TEXT SIZE 28
SET TEXT TO BOLD
shots=1
hits=1
if file exist("AirborneDefenseHighScores.txt")
open to read 1,"AirborneDefenseHighScores.txt"
read long 1,HiScore
close file 1
endif
make object cube 1,1
yrotate object 1,45
make mesh from object 1,1
yrotate object 1,0
scale object 1,250,250,250
add limb 1,1,1
offset limb 1,1,-.5,-.5,-.5
add limb 1,2,1
offset limb 1,2,.5,-.5,.5
add limb 1,3,1
offset limb 1,3,.5,-.5,-.5
add limb 1,4,1
offset limb 1,4,-.5,-.5,.5
scale object 1,180,280,180
make mesh from object 6,1
delete object 1
make object sphere 1,4.4
make object cone 2,3
xrotate object 2,180
make mesh from object 3,2
add limb 1,1,3
offset limb 1,1,0,-3,0
make object cone 3,3
scale object 3,100,100,10
make mesh from object 4,3
add limb 1,2,4
add limb 1,3,4
rotate limb 1,3,0,90,0
offset limb 1,2,0,-3,0
offset limb 1,3,0,-3,0
make mesh from object 5,1
delete object 1
delete object 2
delete object 3
create bitmap 1,16,16
box 0,0,15,15,0,0,0,0
for g=1 to 300
dot rnd(15),rnd(15),rgb(rnd(50),100+rnd(100),rnd(100))
next g
get image 11,0,0,15,15
delete bitmap 1
make object cone 10,5
scale object 10,35,150,35
make object cone 11,9
scale object 11,120,45,120
make mesh from object 11,11
add limb 10,1,11
scale limb 10,1,50,50,50
offset limb 10,1,0,3,0
add limb 10,2,11
add limb 10,3,11
scale limb 10,3,135,135,135
offset limb 10,3,0,-3,0
make mesh from object 10,10
for g=2001 to 2050
make object g,10,11
scale object g,150+rnd(150),150+rnd(150),150+rnd(150)
repeat
a=rnd(300)-150
b=rnd(300)-150
until (a>50 or a<-50) or (b>50 or b<-50)
position object g,a,0,b
set object light g,0
next g
delete object 10
delete object 11
create bitmap 1,16,16 :
box 0,0,15,15 :
ink rgb(173,23,223),0 :
for t=0 to 16 step 4 :
for u=0 to 16 step 4 :
box t,u,t+2,u+2 :
next u :
next t :
get image 1,0,0,15,15 :
delete bitmap 1 :
create bitmap 1,16,16 :
ink RGB(255,128,64),0 :
box 0,0,15,15 :
ink RGB(0,128,64),0 :
circle 7,7,3 :
circle 7,7,5 :
get image 2,0,0,15,15 :
delete bitmap 1 :
create bitmap 1,640,480
for t=0 to 5
ink rgb(255-t*30,255-t*30,255-t*30),0
box t,t,640-t,480-t
next t
for y=5 to 475
ink rgb(y/3,y/5,y/2),0
line 5,y,635,y
next y
ink 0,0
box 150,0,490,400
get image 3,0,0,640,480
delete bitmap 1
create bitmap 1,16,16
ink rgb(0,255,0),0
box 0,0,15,15
for t=1 to 100
dot rnd(15),rnd(15),rgb(rnd(50),100+rnd(100),rnd(50))
next t
get image 4,0,0,15,15
delete bitmap 1
create bitmap 1,32,32
ink rgb(0,0,200),0
box 0,0,31,31
ink rgb(255,255,255),0
for g=1 to 500
dot rnd(31),rnd(31)
next g
for t=15 to 20
ink RGB(128+rnd(32),64+rnd(16),0),0
line 0,t,31,t
next t
blur bitmap 1,1.25
get image 5,0,0,31,31
delete bitmap 1
create bitmap 1,2,2
dot 0,0,rgb(255,0,0)
get image 6,0,0,1,1
delete bitmap 1
make object sphere 500,300
set object cull 500,0
set object light 500,0
texture object 500,5
set object collision off 500
ink rgb(155,155,255),0
for t=1 to 10
for u=1 to 10
inc x
make object x,6,1
set object collision to boxes x
position object x,t*7-35,0,u*7-35
next u
next t
for t=0 to 9
for u=0 to 9
x=1000+(t*10)+u
make object sphere x,0.55
set object collision off x
texture object x,6
next u
next t
make matrix 1,400,400,48,48
position matrix 1,-200,-7,-200
prepare matrix texture 1,4,1,1
fill matrix 1,0,1
randomize matrix 1,6
update matrix 1
t1#=timer()
MOVE CAMERA -75
sync
INK 0,0
paste image 3,0,0,1
center text 320,20,"AIRBORNE DEFENSE"
center text 320,60,"Use mouse and left click to"
center text 320,80,"shoot enemies as they"
center text 320,100,"try to steal your blocks."
center text 320,140,"Score more points for"
center text 320,160,"enemies carrying blocks."
center text 320,270,"Game ends when you have"
center text 320,290,"less than 10 blocks left."
center text 320,330,"Click Mouse To Begin!"
sync
repeat
until mouseclick()
do
paste image 3,0,0,1
gs#=((timer()-t1#)*MGS#) : t1#=timer()
walk#=wrapvalue(walk#+gs#)
position camera 0,sin(walk#)*115,55,cos(walk#)*115
point camera 0,0,0,0
for t=1 to 100 : if object visible(t)
if object position y(t)>0
move object down t,gs#
endif
endif
next t
for t=101 to 100+nme
if object exist(t)=0
make object t,5,2
set object collision to boxes t
set object light t,0
position object t,(rnd(9)+1)*7-35,70+rnd(9),(rnd(9)+1)*7-35
endif : if object exist(t)
if object visible(t)
move object down t,gs#*2
v=object collision(t,0)
if v>0 and v<101
move object up t,gs#*6
move object up v,gs#*5.1
endif
if object position y(t)>80 or object position y(t)<-10
if v>0 and v<101
hide object v
position object v,-999,-999,-999
set object collision off v
endif
position object t,(rnd(9)+1)*7-35,70+rnd(9),(rnd(9)+1)*7-35
endif
endif
endif
next t
dec shot#,gs#
if shot#>0
ink rgb(0,0,100),0
else
ink rgb(255,0,0),0
endif
for t=3 to 5
circle mousex(),mousey(),t
next t
if mouseclick()
if shot#<0.0
shot#=3.75
inc shots
a=pick object(mousex(),mousey(),101,100+nme)
if a>99
if NewEX>8
NewEX=0
endif
inc score,10+(level/5)*5
inc hits
for f=1 to 100
if object visible(f)
if object collision(a,f)=1
inc score,10+(level*5) : exit
endif
endif
next f
for u=1 to 10
x=1000+(NewEX*10)+u
position object x,object position x(a),object position y(a),object position z(a)
rotate object x,rnd(359),rnd(359),rnd(359)
next u
inc NewEX
position object a,0,90,0
endif
endif
endif
for t=0 to 9
for u=0 to 9
x=1000+(t*10)+u
move object x,gs#*3.357
next u
next t
level=score/250+1
if level>50 then level=50
if level(level)=0
level(level)=1
if level mod 2=0
inc nme
else
inc MGS#,0.0025
endif
endif
ink rgb(155,155,255),0
cubes=0
for t=1 to 100
if object visible(t) then inc cubes
next t
center text 70,50,"SCORE"
CENTER TEXT 70,68,STR$(SCORE)
center text 70,100,"BLOCKS"
CENTER TEXT 70,118,STR$(CUBES)
center text 70,150,"LEVEL"
CENTER TEXT 70,168,STR$(LEVEL)
center text 560,50,"SHOTS"
CENTER TEXT 560,68,STR$(SHOTS-1)
center text 560,100,"HITS"
CENTER TEXT 560,118,STR$(HITS-1)
center text 560,150,"RATIO"
R#=(100.0*(HITS))/(SHOTS)
CENTER TEXT 560,168,STR$(int(r#))+"%"
center text 320,420,"HIGH SCORE"
center text 324,440,str$(hiscore)
if cubes<10
ink 0,0
center text 320,70,"GAME OVER!"
center text 320,95,"Your Final Score:"
center text 320,115,str$(score)
center text 320,305,"(click mouse to exit)"
if score>HiScore
center text 320,200,"YOU GOT THE"
CENTER TEXT 320,220,"NEW HIGH SCORE!"
if file exist("AirborneDefenseHighScores.txt") THEN delete file "AirborneDefenseHighScores.txt"
open to write 1,"AirborneDefenseHighScores.txt"
write long 1,score
close file 1
endif
sync
wait 3000
repeat
until mouseclick()
end
endif
sync
loop