Got a bit of difficulty scaling now, as well as a shield and slightly different effects. The shield only recharges when you're not firing.
sync on
sync rate 30
type spark
x# as float
y# as float
speed# as float
angle# as float
life as integer
fadeout as integer
fadein as integer
fadestart as integer
spritenum as integer
spin# as float
alpha as integer
delay as integer
mechtie as integer
endtype
type aidata
ally as integer
destx# as float
desty# as float
threat as integer
moving as integer
firing as integer
avoiding as integer
entering as integer
determination# as float
range as integer
endtype
type mech
x# as float
y# as float
rot# as float
toprot# as float
legmove# as float
lastmove as integer
speed# as float
move as integer
hpbar as integer
sbar as integer
body as integer
lleg as integer
rleg as integer
lfoot as integer
rfoot as integer
rweapon as integer
lweapon as integer
lfiring as float
rfiring as float
lrecoil# as float
rrecoil# as float
lrecoilvel# as float
rrecoilvel# as float
bodysway as integer
firing as integer
hp# as float
shield# as float
shieldregen# as float
maxshield# as float
ai as aidata
corpsetimer as integer
endtype
type bullet
x# as float
y# as float
accel# as float
vel# as float
spritenum as integer
rot# as float
live as integer
distance as integer
damage# as integer
owner as integer
smoke# as float
hittype as integer
endtype
dim mechs(0) as mech
dim bullets(0) as bullet
dim sparks(0) as spark
//images
//1:blank
//2:body
//3:lfoot
//4:rfoot
ink rgb(255,255,255),0
box 0,0,10,10
get image 1,0,0,1,1,1
blurback=findsprite()
sprite blurback,0,0,1
set sprite alpha blurback,100
set sprite diffuse blurback,0,0,0
set sprite blurback,0,1
size sprite blurback,screen width(),screen height()
cls
//ink rgb(96,128,159),0
//box 90,90,110,110
//box 85,95,115,105
ink rgb(66,88,111),0
vlsetorigin(0,100,100)
vlstartpoly(-10,10)
vlpolyline(10,10)
vlpolyline(15,5)
vlpolyline(15,-5)
vlpolyline(10,-10)
vlpolyline(-10,-10)
vlpolyline(-15,-5)
vlpolyline(-15,5)
vlendpoly()
floodfill(100,100,rgb(96,128,159))
get image 2,85,90,116,111,0
sbody=findsprite()
sprite sbody,0,0,2
offset sprite sbody,15,10
hide sprite sbody
cls
ink rgb(255,0,0),0
box 0,0,200,200
ink rgb(66,88,111),0
vlstartpoly(14,10)
vlpolyline(19,10)
vlpolyline(19,-10)
vlpolyline(14,-10)
vlendpoly()
floodfill(116,100,rgb(96,128,159))
get image 3,114,90,120,111,0
slfoot=findsprite()
sprite slfoot,0,0,3
offset sprite slfoot,-14,10
hide sprite slfoot
cls
ink rgb(255,0,0),0
box 0,0,200,200
ink rgb(66,88,111),0
vlstartpoly(-14,10)
vlpolyline(-19,10)
vlpolyline(-19,-10)
vlpolyline(-14,-10)
vlendpoly()
floodfill(84,100,rgb(96,128,159))
get image 4,81,90,87,111,0
srfoot=findsprite()
sprite srfoot,0,0,4
offset sprite srfoot,19,10
hide sprite srfoot
cls
ink rgb(255,0,0),0
box 0,0,200,200
ink rgb(66,88,111),0
vlstartpoly(-11,12)
vlpolyline(-8,12)
vlpolyline(-8,0)
vlpolyline(-11,0)
vlendpoly()
floodfill(90,105,rgb(96,128,159))
get image 5,89,100,93,113,0
slweapon=findsprite()
sprite slweapon,0,0,5
offset sprite slweapon,11,0
hide sprite slweapon
cls
ink rgb(255,0,0),0
box 0,0,200,200
ink rgb(66,88,111),0
vlstartpoly(11,12)
vlpolyline(8,12)
vlpolyline(8,0)
vlpolyline(11,0)
vlendpoly()
floodfill(110,105,rgb(96,128,159))
get image 6,108,100,112,113,0
srweapon=findsprite()
sprite srweapon,0,0,6
offset sprite srweapon,-8,0
hide sprite srweapon
cls
ink rgb(255,0,0),0
box 0,0,200,200
ink rgb(230,60,0),0
line 1,1,1,20
line 2,1,2,20
get image 15,1,1,2,20,0
sbullet=findsprite()
sprite sbullet,0,0,15
offset sprite sbullet,0,0
hide sprite sbullet
cls
ink rgb(255,0,0),0
box 0,0,200,200
ink rgb(130,130,130),0
line 1,1,1,10
line 2,1,2,11
line 3,1,3,10
ink rgb(200,0,0),0
line 1,2,3,2
line 1,4,3,4
get image 16,1,1,3,11,0
srocket=findsprite()
sprite srocket,0,0,16
offset sprite srocket,1,0
hide sprite srocket
cls
ink rgb(255,0,0),0
box 0,0,200,200
ink rgb(50,200,50),0
box 1,1,5,5
get image 20,1,1,5,5,0
shbar=findsprite()
sprite shbar,0,0,20
offset sprite shbar,0,0
hide sprite shbar
cls
ink rgb(255,0,0),0
box 0,0,200,200
ink rgb(50,100,200),0
box 1,1,5,5
get image 27,1,1,5,5,0
ssbar=findsprite()
sprite ssbar,0,0,27
offset sprite ssbar,0,0
hide sprite ssbar
cls
ink rgb(255,0,0),0
box 0,0,200,200
ink rgb(255,128,0),0
box 1,1,2,3
get image 21,1,1,2,3,0
sspark=findsprite()
sprite sspark,0,0,21
offset sprite sspark,0,0
hide sprite sspark
cls
ink rgb(255,0,0),0
box 0,0,200,200
ink rgb(50,100,200),0
box 1,1,2,3
get image 28,1,1,2,3,0
sbspark=findsprite()
sprite sbspark,0,0,28
offset sprite sbspark,0,0
hide sprite sbspark
cls
ink rgb(0,0,0),0
box 0,0,200,200
ink rgb(50,100,200),0
circle 20,20,19
circle 18,22,17
circle 21,23,17
get image 29,1,1,40,40,0
sshield=findsprite()
sprite sshield,0,0,29
offset sprite sshield,20,20
hide sprite sshield
cls
ink rgb(0,0,0),0
box 0,0,200,200
ink rgb(80,80,80),0
fillcircle(10,10,9)
get image 22,1,1,20,20,0
ssmallsmoke=findsprite()
sprite ssmallsmoke,0,0,22
offset sprite ssmallsmoke,9,9
hide sprite ssmallsmoke
cls
ink rgb(0,0,0),0
box 0,0,200,200
ink rgb(66,88,111),0
vlsetorigin(0,0,0)
vlstartpoly(1,4)
vlpolyline(4,1)
vlpolyline(6,5)
vlpolyline(4,5)
vlpolyline(3,6)
vlendpoly()
floodfill(3,4,rgb(96,128,159))
get image 23,1,1,7,7,0
ssmalldebri=findsprite()
sprite ssmalldebri,0,0,23
offset sprite ssmalldebri,3,3
hide sprite ssmalldebri
cls
ink rgb(0,0,0),0
box 0,0,200,200
ink rgb(255,90,0),0
fillcircle(10,10,9)
get image 24,1,1,20,20,0
sfireball=findsprite()
sprite sfireball,0,0,24
offset sprite sfireball,9,9
hide sprite sfireball
cls
ink rgb(0,0,0),0
box 0,0,200,200
ink rgb(255,255,255),0
fillcircle(10,10,9)
get image 25,1,1,20,20,0
sbrightfireball=findsprite()
sprite sbrightfireball,0,0,25
offset sprite sbrightfireball,9,9
hide sprite sbrightfireball
cls
ink rgb(0,0,0),0
box 0,0,200,200
ink rgb(255,255,255),0
//line 2,1,1,400
line 2,1,2,400
//line 2,1,3,400
get image 26,1,1,4,401,0
slight=findsprite()
sprite slight,0,0,26
offset sprite slight,1,0
hide sprite slight
addmech(screen width()/2,screen height()/2,0,0,80,30)
lastmove=0
killed=0
nextmech=150
gameend=0
ink rgb(255,255,255),0
box 0,0,screen width(),screen height()
do
nextmech=nextmech-1
if nextmech<0
nextmech=300-(killed*5)
if killed<3
hp=20
shield=0
else
if killed<5
hp=40
shield=0
else
if killed<7
hp=30
shield=10
else
if killed<10
hp=70
shield=0
else
hp=30
shield=20
endif
endif
endif
endif
if nextmech<90 then nextmech=90
rx=rnd(screen width()-60)+30
ry=rnd(screen height()-60)+30
select rnd(3)
case 0: addmech(rx,-50,rx,10,hp,shield)
endcase
case 1: addmech(rx,screen height()+50,rx,screen height()-10,hp,shield)
endcase
case 2: addmech(-50,ry,10,ry,hp,shield)
endcase
case 3: addmech(screen width()+50,ry,screen width()-10,ry,hp,shield)
endcase
endselect
endif
mechs(0).move=0
if gameend=0
if downkey()
mechs(0).move=1
mechs(0).lastmove=1
endif
if upkey()
mechs(0).move=1
mechs(0).lastmove=2
endif
if rightkey()
mechs(0).move=1
mechs(0).lastmove=3
endif
if leftkey()
mechs(0).move=1
mechs(0).lastmove=4
endif
lmb=0
mmb=0
rmb=0
mv=mouseclick()
if int(mv/8)=1
mv=mv-8
endif
if int(mv/4)=1
mv=mv-4
mmb=1
endif
if int(mv/2)=1
mv=mv-2
rmb=1
endif
if mv=1
lmb=1
endif
if lmb=1
mechs(0).firing=1
else
if rmb=1
mechs(0).firing=2
else
mechs(0).firing=0
endif
endif
endif
targetangle#=wrapvalue(atanfull(-(mousex()-mechs(0).x#),(mousey()-mechs(0).y#)))
mechs(0).toprot#=wrapvalue(mechs(0).toprot#)
if (wrap180#(mechs(0).rot#+mechs(0).toprot#-targetangle#)>-3)
if (wrap180#(mechs(0).rot#+mechs(0).toprot#-targetangle#)<3)
//mechs(0).firing=1
else
mechs(0).toprot#=mechs(0).toprot#-3
endif
else
mechs(0).toprot#=mechs(0).toprot#+3
endif
for c=1 to array count(mechs(0))-1
mechs(c).move=0
mechs(c).ai.range=400
if mechs(mechs(c).ai.threat).firing
angle#=wrapvalue(atanfull(-(mechs(mechs(c).ai.threat).x#-mechs(c).x#),(mechs(mechs(c).ai.threat).y#-mechs(c).y#)))
if (wrap180#(angle#-180-mechs(mechs(c).ai.threat).rot#-mechs(mechs(c).ai.threat).toprot#)<7) AND (wrap180#(angle#-180-mechs(mechs(c).ai.threat).rot#-mechs(mechs(c).ai.threat).toprot#)>-7)
if (wrap180#(angle#-180-mechs(mechs(c).ai.threat).rot#-mechs(mechs(c).ai.threat).toprot#))>0
angle#=angle#-90
else
angle#=angle#+90
endif
proposedx#=mechs(c).x#-sin(angle#)*40.0
proposedy#=mechs(c).y#+cos(angle#)*40.0
if (mechs(c).ai.determination#<=0) AND (mechs(c).ai.entering=0)
mechs(c).ai.destx#=proposedx#
mechs(c).ai.desty#=proposedy#
mechs(c).ai.moving=1
mechs(c).ai.avoiding=1
mechs(c).ai.determination#=170
else
mechs(c).ai.determination#=mechs(c).ai.determination#-(0.05*sqrt(((mechs(c).ai.destx#-proposedx#)*(mechs(c).ai.destx#-proposedx#))+((mechs(c).ai.desty#-proposedy#)*(mechs(c).ai.desty#-proposedy#))))
endif
endif
endif
if mechs(c).ai.moving=1
if mechs(c).ai.destx#>screen width()-10 then mechs(c).ai.destx#=screen width()-10
if mechs(c).ai.destx#<10 then mechs(c).ai.destx#=10
if mechs(c).ai.desty#>screen height()-10 then mechs(c).ai.desty#=screen height()-10
if mechs(c).ai.desty#<10 then mechs(c).ai.desty#=10
if (((mechs(c).ai.destx#-mechs(c).x#)*(mechs(c).ai.destx#-mechs(c).x#))+((mechs(c).ai.desty#-mechs(c).y#)*(mechs(c).ai.desty#-mechs(c).y#)))>25
targetangle#=wrapvalue(atanfull(-(mechs(c).ai.destx#-mechs(c).x#),(mechs(c).ai.desty#-mechs(c).y#)))
if (wrap180#(mechs(c).rot#-targetangle#)>-3)
if (wrap180#(mechs(c).rot#-targetangle#)<3)
mechs(c).move=1
mechs(c).lastmove=2
else
mechs(c).move=1
mechs(c).lastmove=4
endif
else
mechs(c).move=1
mechs(c).lastmove=3
endif
else
mechs(c).ai.determination#=0
mechs(c).ai.moving=0
endif
else
mechs(c).ai.avoiding=0
mechs(c).ai.entering=0
endif
mechs(c).ai.threat=0
inrange=0
threatdist#=dist#(mechs(c).x#-mechs(mechs(c).ai.threat).x#,mechs(c).y#-mechs(mechs(c).ai.threat).y#)
if (threatdist#< mechs(c).ai.range)
inrange=1
else
if (mechs(c).ai.avoiding=0) AND (mechs(c).ai.entering=0)
mechs(c).ai.destx#=mechs(mechs(c).ai.threat).x#-(((mechs(mechs(c).ai.threat).x#-mechs(c).x#)*(mechs(c).ai.range*0.9))/threatdist#)
mechs(c).ai.desty#=mechs(mechs(c).ai.threat).y#-(((mechs(mechs(c).ai.threat).y#-mechs(c).y#)*(mechs(c).ai.range*0.9))/threatdist#)
mechs(c).ai.moving=1
//mechs(c).ai.determination#=170
endif
endif
holdfire=0
if (mechs(c).shield#<mechs(c).maxshield#) AND (inrange=0)
holdfire=1
endif
targetangle#=wrapvalue(atanfull(-(mechs(mechs(c).ai.threat).x#-mechs(c).x#),(mechs(mechs(c).ai.threat).y#-mechs(c).y#)))
if mechs(c).hp#<=0 then targetangle#=0
mechs(c).toprot#=wrapvalue(mechs(c).toprot#)
mechs(c).firing=0
if (wrap180#(mechs(c).rot#+mechs(c).toprot#-targetangle#)>-3)
if (wrap180#(mechs(c).rot#+mechs(c).toprot#-targetangle#)<3)
if (mechs(c).ai.entering=0) AND (holdfire=0) then mechs(c).firing=1
else
mechs(c).toprot#=mechs(c).toprot#-3
endif
else
mechs(c).toprot#=mechs(c).toprot#+3
endif
if (wrap180#(mechs(c).rot#+mechs(c).toprot#-targetangle#)>-3)
if (wrap180#(mechs(c).rot#+mechs(c).toprot#-targetangle#)<3)
if (mechs(c).ai.entering=0) AND (holdfire=0) then mechs(c).firing=1
endif
endif
if mechs(c).hp#<=0 then mechs(c).firing=0
next c
for c=0 to array count(mechs(0))-1
if (mechs(c).corpsetimer>0)
if (mechs(c).corpsetimer>90)
delete sprite mechs(c).body
delete sprite mechs(c).lfoot
delete sprite mechs(c).rfoot
delete sprite mechs(c).lleg
delete sprite mechs(c).rleg
delete sprite mechs(c).lweapon
delete sprite mechs(c).rweapon
array delete element mechs(0),c
set sprite diffuse blurback,0,0,0
c=c-1
else
if backset>-1
mechs(c).corpsetimer=mechs(c).corpsetimer+1
set sprite diffuse blurback,sprite alpha(backset)/3,sprite alpha(backset)/3,sprite alpha(backset)/3
endif
endif
else
if (mechs(c).move=1) OR ( NOT (((abs(mechs(c).legmove#)-4)<1.1) AND ((abs(mechs(c).legmove#)-5)>-1.1)))
select mechs(c).lastmove
case 1
mechs(c).legmove#=mechs(c).legmove#+mechs(c).speed#
mechs(c).x#=mechs(c).x#+(mechs(c).speed#*sin(mechs(c).rot#))
mechs(c).y#=mechs(c).y#-(mechs(c).speed#*cos(mechs(c).rot#))
endcase
case 2
mechs(c).legmove#=mechs(c).legmove#-mechs(c).speed#
mechs(c).x#=mechs(c).x#-(mechs(c).speed#*sin(mechs(c).rot#))
mechs(c).y#=mechs(c).y#+(mechs(c).speed#*cos(mechs(c).rot#))
endcase
case 3
mechs(c).legmove#=mechs(c).legmove#+mechs(c).speed#
mechs(c).rot#=mechs(c).rot#+3
endcase
case 4
mechs(c).legmove#=mechs(c).legmove#+mechs(c).speed#
mechs(c).rot#=mechs(c).rot#-3
endcase
endselect
else
if mechs(c).legmove#>0 then mechs(c).legmove#=5 else mechs(c).legmove#=-5
endif
if (mechs(c).firing=1)
if mechs(c).lfiring=0
mechs(c).lfiring=8
addbullet(c,mechs(c).x#+getx#(mechs(c).bodysway-10,10,mechs(c).rot#+mechs(c).toprot#),mechs(c).y#+gety#(mechs(c).bodysway-10,10,mechs(c).rot#+mechs(c).toprot#),mechs(c).rot#+mechs(c).toprot#+frnd#(5.0)-2.5-1,sbullet,1500,2,15,0,0,1)
mechs(c).lrecoilvel#=-3
endif
if (mechs(c).rfiring=0) AND (mechs(c).lfiring=4)
mechs(c).rfiring=8
addbullet(c,mechs(c).x#+getx#(mechs(c).bodysway+10,10,mechs(c).rot#+mechs(c).toprot#),mechs(c).y#+gety#(mechs(c).bodysway+10,10,mechs(c).rot#+mechs(c).toprot#),mechs(c).rot#+mechs(c).toprot#+frnd#(5.0)-2.5+1,sbullet,1500,2,15,0,0,1)
mechs(c).rrecoilvel#=-3
endif
endif
if (mechs(c).firing=2)
if mechs(c).lfiring=0
mechs(c).lfiring=30
addbullet(c,mechs(c).x#+getx#(mechs(c).bodysway-10,10,mechs(c).rot#+mechs(c).toprot#),mechs(c).y#+gety#(mechs(c).bodysway-10,10,mechs(c).rot#+mechs(c).toprot#),mechs(c).rot#+mechs(c).toprot#-1,srocket,1500,20,1.7,0.5,0.1,2)
mechs(c).lrecoilvel#=-3
endif
if (mechs(c).rfiring=0) AND (mechs(c).lfiring=15)
mechs(c).rfiring=30
addbullet(c,mechs(c).x#+getx#(mechs(c).bodysway+10,10,mechs(c).rot#+mechs(c).toprot#),mechs(c).y#+gety#(mechs(c).bodysway+10,10,mechs(c).rot#+mechs(c).toprot#),mechs(c).rot#+mechs(c).toprot#+1,srocket,1500,20,1.7,0.5,0.1,2)
mechs(c).rrecoilvel#=-3
endif
endif
if mechs(c).firing=0
if mechs(c).shield#<mechs(c).maxshield#
mechs(c).shield#=mechs(c).shield#+mechs(c).shieldregen#
if c=0
text screen width()/2- (text width("Shield Charging!")/2),100,"Shield Charging!"
endif
endif
endif
while (mechs(c).legmove#>10)
mechs(c).legmove#=mechs(c).legmove#-20
endwhile
while (mechs(c).legmove#<-10)
mechs(c).legmove#=mechs(c).legmove#+20
endwhile
mechs(c).lrecoil#=mechs(c).lrecoil#+mechs(c).lrecoilvel#
if (mechs(c).lrecoil#<-5)
mechs(c).lrecoil#=-5
mechs(c).lrecoilvel#=0.5
endif
if (mechs(c).lrecoil#>0) then mechs(c).lrecoil#=0
if mechs(c).lfiring>0 then mechs(c).lfiring=mechs(c).lfiring-1
mechs(c).rrecoil#=mechs(c).rrecoil#+mechs(c).rrecoilvel#
if (mechs(c).rrecoil#<-5)
mechs(c).rrecoil#=-5
mechs(c).rrecoilvel#=0.5
endif
if (mechs(c).rrecoil#>0) then mechs(c).rrecoil#=0
if mechs(c).rfiring>0 then mechs(c).rfiring=mechs(c).rfiring-1
if mechs(c).lastmove=2
mechs(c).bodysway=(abs(mechs(c).legmove#)-5)*0.6
else
mechs(c).bodysway=(-abs(mechs(c).legmove#)+5)*0.6
endif
copysprite(sbody,mechs(c).body,mechs(c).x#,mechs(c).y#,mechs(c).rot#+mechs(c).toprot#,cos(mechs(c).toprot#)*mechs(c).bodysway,-sin(mechs(c).toprot#)*mechs(c).bodysway)
copysprite(slweapon,mechs(c).lweapon,mechs(c).x#,mechs(c).y#,mechs(c).rot#+mechs(c).toprot#,cos(mechs(c).toprot#)*mechs(c).bodysway,-sin(mechs(c).toprot#)*mechs(c).bodysway-mechs(c).lrecoil#)
copysprite(srweapon,mechs(c).rweapon,mechs(c).x#,mechs(c).y#,mechs(c).rot#+mechs(c).toprot#,cos(mechs(c).toprot#)*mechs(c).bodysway,-sin(mechs(c).toprot#)*mechs(c).bodysway-mechs(c).rrecoil#)
copysprite(slfoot,mechs(c).lfoot,mechs(c).x#,mechs(c).y#,mechs(c).rot#,0,0-abs(mechs(c).legmove#)+5)
copysprite(srfoot,mechs(c).rfoot,mechs(c).x#,mechs(c).y#,mechs(c).rot#,0,abs(mechs(c).legmove#)-5)
//if (mechs(c).hp<mechs(c).maxhp)
if mechs(c).shield#>mechs(c).maxshield# then mechs(c).shield#=mechs(c).maxshield#
if (mechs(c).hp#<0) then mechs(c).hp#=0
size sprite mechs(c).hpbar,mechs(c).hp#,5
offset sprite mechs(c).hpbar,((mechs(c).hp#+mechs(c).shield#)/2.0)+1,0
sprite mechs(c).hpbar,mechs(c).x#,mechs(c).y#-25,20
size sprite mechs(c).sbar,mechs(c).shield#,5
offset sprite mechs(c).sbar,((mechs(c).hp#+mechs(c).shield#)/2.0)-mechs(c).hp#-1,0
sprite mechs(c).sbar,mechs(c).x#,mechs(c).y#-25,27
if (mechs(c).hp#<=0)
if c=0
gameend=1
else
killed=killed+1
endif
delay=0
for e=1 to 5
x#=mechs(c).x#+rnd(30)-15
y#=mechs(c).y#+rnd(30)-15
num=10+rnd(10)
for d=1 to num
addspark(x#,y#,0.5+frnd#(2),frnd#(360),10+rnd(10),delay,10,10,10,sspark,100,0,200,-1)
next d
num=5+rnd(5)
for d=1 to num
addspark(x#,y#,0.2+frnd#(1),frnd#(360),30+rnd(5),delay,35,35,35,ssmallsmoke,40+frnd#(50),frnd#(10)-5.0,130,-1)
next d
num=6+rnd(4)
for d=1 to num
addspark(x#,y#,0.2+frnd#(1),frnd#(360),25,delay,30,30,30,sfireball,50+frnd#(50),frnd#(10)-5.0,130,-1)
next d
num=3+rnd(3)
for d=1 to num
addspark(x#,y#,0.2+frnd#(0.5),frnd#(360),20,delay,20,20,20,sbrightfireball,80+frnd#(50),frnd#(10)-5.0,100,-1)
next d
delay=rnd(70)
next e
num=4+rnd(3)
for d=1 to num
start=rnd(50)
addspark(mechs(c).x#,mechs(c).y#,0,frnd#(360),95,0, 35+start,15+start,rnd(10),slight,400,frnd#(6)-3,100,-1)
next d
num=15+rnd(5)
for d=1 to num
backset=addspark(mechs(c).x#+frnd#(30)-15,mechs(c).y#+frnd#(30)-15,frnd#(0.2),frnd#(360),100,0,80,30,5+rnd(5),sbrightfireball,100+frnd#(80),frnd#(2)-1,70,-1)
next d
num=20+rnd(10)
for d=1 to num
addspark(mechs(c).x#,mechs(c).y#,1+frnd#(3),frnd#(360),15+rnd(5),90,30,30,30,sspark,100,0,255,-1)
next d
num=13+rnd(4)
for d=1 to num
addspark(mechs(c).x#+frnd#(10)-5,mechs(c).y#+frnd#(10)-5,0.6+frnd#(1.2),frnd#(360),30+rnd(5),90,20,20,20,ssmalldebri,100+frnd#(100),frnd#(40)-20.0,255,-1)
next d
num=15+rnd(5)
for d=1 to num
addspark(mechs(c).x#+frnd#(10)-5,mechs(c).y#+frnd#(10)-5,0.7+frnd#(1),frnd#(360),45+rnd(5),90,80,80,80,ssmallsmoke,40+frnd#(100),frnd#(10)-5.0,255,-1)
next d
num=6+rnd(4)
for d=1 to num
addspark(mechs(c).x#,mechs(c).y#,1+frnd#(1),frnd#(360),25,90,30,30,30,sfireball,100+frnd#(100),frnd#(10)-5.0,150,-1)
next d
num=4+rnd(4)
for d=1 to num
addspark(mechs(c).x#,mechs(c).y#,1+frnd#(0.7),frnd#(360),15,90,15,15,15,sbrightfireball,100+frnd#(100),frnd#(10)-5.0,200,-1)
next d
//num=15+rnd(5)
//for d=1 to num
// addspark(mechs(c).x#+frnd#(10)-5,mechs(c).y#+frnd#(10)-5,1.5+frnd#(0.2),frnd#(360),45+rnd(10),90,80,80,80,ssmallsmoke,40+frnd#(70),frnd#(10)-5.0,255)
//next d
mechs(c).corpsetimer=1
endif
endif
//endif
next c
for c=0 to array count(bullets(0))-1
bullets(c).x#=bullets(c).x#-(bullets(c).vel#*sin(bullets(c).rot#))
bullets(c).y#=bullets(c).y#+(bullets(c).vel#*cos(bullets(c).rot#))
bullets(c).distance=bullets(c).distance-bullets(c).vel#
bullets(c).vel#=bullets(c).vel#+bullets(c).accel#
sprite bullets(c).spritenum,bullets(c).x#,bullets(c).y#,sprite image(bullets(c).spritenum)
if (bullets(c).smoke#>0)
for b=0 to int(bullets(c).smoke#*bullets(c).vel#)+1
distance#=frnd#(bullets(c).vel#)
addspark(bullets(c).x#+(distance#*sin(bullets(c).rot#)),bullets(c).y#-(distance#*cos(bullets(c).rot#)),frnd#(0.4),frnd#(360),15+rnd(5),0,20,15,5,ssmallsmoke,40+frnd#(50),frnd#(10)-5.0,100,-1)
next b
endif
if (bullets(c).distance<=0)
delete sprite bullets(c).spritenum
array delete element bullets(0),c
c=c-1
else
if bullets(c).live>0
bullets(c).live=bullets(c).live-1
else
for b=0 to array count(mechs(0))-1
if (sprite hit(bullets(c).spritenum,mechs(b).body)) AND (b<>bullets(c).owner)
if mechs(b).shield#<bullets(c).damage#
mechs(b).hp#=mechs(b).hp#-(bullets(c).damage#-mechs(b).shield#)
mechs(b).shield#=0
else
mechs(b).shield#=mechs(b).shield#-bullets(c).damage#
num=5+rnd(4)
for d=1 to num
addspark(bullets(c).x#,bullets(c).y#,1+frnd#(2),atanfull(bullets(c).y#-mechs(b).y#,bullets(c).x#-mechs(b).x#)+90+90+frnd#(40)-20,10,0,20,20,20,sbspark,150,0,255,-1)
addspark(bullets(c).x#,bullets(c).y#,1+frnd#(2),atanfull(bullets(c).y#-mechs(b).y#,bullets(c).x#-mechs(b).x#)+90-90+frnd#(40)-20,15,0,20,20,20,sbspark,150,0,255,-1)
next d
addspark(mechs(b).x#,mechs(b).y#,0,frnd#(360),15,0,20,20,20,sshield,120+rnd(40),frnd#(5)+1,30,b)
endif
select bullets(c).hittype
case 1:
num=5+rnd(4)
for d=1 to num
addspark(bullets(c).x#,bullets(c).y#,1+frnd#(2),bullets(c).rot#+180+frnd#(140)-70,10,0,20,20,20,sspark,100,0,255,-1)
next d
num=2+rnd(2)
for d=1 to num
addspark(bullets(c).x#,bullets(c).y#,0.2+frnd#(0.5),bullets(c).rot#+180+frnd#(280)-140,20,0,40,40,40,ssmallsmoke,15+frnd#(15),0,255,-1)
next d
endcase
case 2:
x#=bullets(c).x#-(2.0*sin(bullets(c).rot#))+rnd(30)-15
y#=bullets(c).y#+(2.0*cos(bullets(c).rot#))+rnd(30)-15
num=10+rnd(10)
delay=0
for d=1 to num
addspark(x#,y#,0.5+frnd#(2),frnd#(360),10+rnd(10),delay,10,10,10,sspark,100,0,200,-1)
next d
num=5+rnd(5)
for d=1 to num
addspark(x#,y#,0.2+frnd#(1),frnd#(360),30+rnd(5),delay,35,35,35,ssmallsmoke,40+frnd#(50),frnd#(10)-5.0,130,-1)
next d
num=6+rnd(4)
for d=1 to num
addspark(x#,y#,0.2+frnd#(1),frnd#(360),25,delay,30,30,30,sfireball,50+frnd#(50),frnd#(10)-5.0,130,-1)
next d
num=3+rnd(3)
for d=1 to num
addspark(x#,y#,0.2+frnd#(0.5),frnd#(360),20,delay,20,20,20,sbrightfireball,80+frnd#(50),frnd#(10)-5.0,100,-1)
next d
endcase
endselect
//num=rnd(1)
//for d=1 to num
// addspark(bullets(c).x#,bullets(c).y#,1.5+frnd#(0.5),bullets(c).rot#+180+frnd#(60)-30,5,20,ssmalldebri,50+frnd#(100),frnd#(20)-10.0)
//next d
b=array count(mechs(0))
delete sprite bullets(c).spritenum
array delete element bullets(0),c
c=c-1
endif
next b
endif
endif
next c
for c=0 to array count(sparks(0))-1
if sparks(c).delay<=0
show sprite sparks(c).spritenum
if (sparks(c).life<=0)
if backset=sparks(c).spritenum then backset=-1
delete sprite sparks(c).spritenum
array delete element sparks(0),c
c=c-1
else
sparks(c).x#=sparks(c).x#-(sparks(c).speed#*sin(sparks(c).angle#))
sparks(c).y#=sparks(c).y#+(sparks(c).speed#*cos(sparks(c).angle#))
if sparks(c).mechtie>-1
sparks(c).x#=mechs(sparks(c).mechtie).x#
sparks(c).y#=mechs(sparks(c).mechtie).y#
endif
if (sparks(c).life<sparks(c).fadeout)
set sprite alpha sparks(c).spritenum,((sparks(c).life*sparks(c).alpha)/sparks(c).fadeout)
else
if (sparks(c).life>sparks(c).fadein) AND (sparks(c).life<=sparks(c).fadestart)
set sprite alpha sparks(c).spritenum,sparks(c).alpha-(((sparks(c).life-sparks(c).fadein)*sparks(c).alpha)/(sparks(c).fadestart-sparks(c).fadein))
else
if (sparks(c).life>sparks(c).fadestart) then set sprite alpha sparks(c).spritenum,0
endif
endif
rotate sprite sparks(c).spritenum,sprite angle(sparks(c).spritenum)+sparks(c).spin#
sprite sparks(c).spritenum,sparks(c).x#,sparks(c).y#,sprite image(sparks(c).spritenum)
sparks(c).life=sparks(c).life-1
endif
else
sparks(c).delay=sparks(c).delay-1
endif
next c
text 0,0,str$(screen fps())+" fps (should be 30)"
text 200,0,"Move: arrow keys"
text 200,20,"Guns: left click"
text 200,40,"Rockets: right click"
text 200,60,"Shield charges when not firing."
text 0,50,"Killed: "+str$(killed)
text 0,100,"Next enemy: "+str$((nextmech/30)+1)
if gameend=1
text screen width()/2- (text width("You died, but took "+str$(killed)+" of them with you!")/2),screen height()/2,"You died, but took "+str$(killed)+" of them with you!"
endif
sync
loop
function vlsetorigin(rotation#,x#,y#)
global vlrotation#=rotation#
global vlx#=x#
global vly#=y#
endfunction
function getx#(x#,y#,angle#)
ret#=(cos(angle#)*x#)+(-sin(angle#)*y#)
endfunction ret#
function gety#(x#,y#,angle#)
ret#=(sin(angle#)*x#)+(cos(angle#)*y#)
endfunction ret#
function vldrawline(x1#,y1#,x2#,y2#)
line vlx#+((cos(vlrotation#)*x1#)+(-sin(vlrotation#)*y1#)),vly#+((sin(vlrotation#)*x1#)+(cos(vlrotation#)*y1#)),vlx#+((cos(vlrotation#)*x2#)+(-sin(vlrotation#)*y2#)),vly#+((sin(vlrotation#)*x2#)+(cos(vlrotation#)*y2#))
endfunction
function vlstartpoly(x#,y#)
global vlpolyx#=x#
global vlpolyy#=y#
global vlpolystartx#=x#
global vlpolystarty#=y#
endfunction
function vlpolyline(x#,y#)
line vlx#+((cos(vlrotation#)*vlpolyx#)+(-sin(vlrotation#)*vlpolyy#)),vly#+((sin(vlrotation#)*vlpolyx#)+(cos(vlrotation#)*vlpolyy#)),vlx#+((cos(vlrotation#)*x#)+(-sin(vlrotation#)*y#)),vly#+((sin(vlrotation#)*x#)+(cos(vlrotation#)*y#))
vlpolyx#=x#
vlpolyy#=y#
endfunction
function vlendpoly()
line vlx#+((cos(vlrotation#)*vlpolyx#)+(-sin(vlrotation#)*vlpolyy#)),vly#+((sin(vlrotation#)*vlpolyx#)+(cos(vlrotation#)*vlpolyy#)),vlx#+((cos(vlrotation#)*vlpolystartx#)+(-sin(vlrotation#)*vlpolystarty#)),vly#+((sin(vlrotation#)*vlpolystartx#)+(cos(vlrotation#)*vlpolystarty#))
endfunction
function findsprite()
res=1
while sprite exist(res)=1
res=res+1
endwhile
endfunction res
function addmech(x#,y#,tx#,ty#,health#,shield#)
array insert at bottom mechs(0)
index=array count(mechs(0))-1
mechs(index).x#=x#
mechs(index).y#=y#
mechs(index).rot#=0
mechs(index).legmove#=0
mechs(index).hp#=health#
mechs(index).shield#=shield#
mechs(index).maxshield#=shield#
mechs(index).shieldregen#=0.2
mechs(index).speed#=1.2
mechs(index).ai.moving=1
mechs(index).ai.entering=1
mechs(index).ai.destx#=tx#
mechs(index).ai.desty#=ty#
mechs(index).rweapon=findsprite()
sprite mechs(index).rweapon,0,0,1
set sprite mechs(index).rweapon,0,1
set sprite priority mechs(index).rweapon,3
mechs(index).lweapon=findsprite()
sprite mechs(index).lweapon,0,0,1
set sprite mechs(index).lweapon,0,1
set sprite priority mechs(index).lweapon,3
mechs(index).body=findsprite()
sprite mechs(index).body,0,0,1
set sprite mechs(index).body,0,1
set sprite priority mechs(index).body,2
mechs(index).lfoot=findsprite()
sprite mechs(index).lfoot,0,0,1
set sprite mechs(index).lfoot,0,1
set sprite priority mechs(index).lfoot,1
mechs(index).rfoot=findsprite()
sprite mechs(index).rfoot,0,0,1
set sprite mechs(index).rfoot,0,1
set sprite priority mechs(index).rfoot,1
mechs(index).lleg=findsprite()
sprite mechs(index).lleg,0,0,1
set sprite mechs(index).lleg,0,1
mechs(index).rleg=findsprite()
sprite mechs(index).rleg,0,0,1
set sprite mechs(index).rleg,0,1
mechs(index).hpbar=findsprite()
sprite mechs(index).hpbar,0,0,1
set sprite mechs(index).hpbar,0,1
mechs(index).sbar=findsprite()
sprite mechs(index).sbar,0,0,1
set sprite mechs(index).sbar,0,1
endfunction
function addbullet(owner,x#,y#,rot#,sourcesprite,distance,damage#,vel#,accel#,smoke#,hittype)
array insert at bottom bullets(0)
index=array count(bullets(0))-1
bullets(index).x#=x#
bullets(index).y#=y#
bullets(index).rot#=rot#
bullets(index).live=2
bullets(index).distance=distance
bullets(index).damage#=damage#
bullets(index).vel#=vel#
bullets(index).accel#=accel#
bullets(index).owner=owner
bullets(index).smoke#=smoke#
bullets(index).hittype=hittype
bullets(index).spritenum=findsprite()
clone sprite sourcesprite,bullets(index).spritenum
set sprite bullets(index).spritenum,0,1
set sprite priority bullets(index).spritenum,10
rotate sprite bullets(index).spritenum,bullets(index).rot#
show sprite bullets(index).spritenum
endfunction
function addspark(x#,y#,speed#,angle#,life,delay,fadestart,fadein,fadeout,sourcesprite,scale,spin#,alpha,mechtie)
array insert at bottom sparks(0)
index=array count(sparks(0))-1
sparks(index).x#=x#
sparks(index).y#=y#
sparks(index).speed#=speed#
sparks(index).angle#=angle#
sparks(index).life=life
sparks(index).fadein=fadein
sparks(index).fadeout=fadeout
sparks(index).fadestart=fadestart
sparks(index).spin#=spin#
sparks(index).alpha=alpha
sparks(index).delay=delay
sparks(index).mechtie=mechtie
sparks(index).spritenum=findsprite()
clone sprite sourcesprite,sparks(index).spritenum
set sprite sparks(index).spritenum,0,1
set sprite priority sparks(index).spritenum,20
rotate sprite sparks(index).spritenum,sparks(index).angle#
scale sprite sparks(index).spritenum,scale
hide sprite sparks(index).spritenum
ret=sparks(index).spritenum
endfunction ret
function copysprite(source,target,x,y,rot#,ox#,oy#)
offset sprite target,sprite offset x(source)+ox#,sprite offset y(source)+oy#
rotate sprite target,rot#
sprite target,x,y,sprite image(source)
endfunction
function floodfill(x,y,colour)
lock pixels
targetcolour=point(x,y)
floodfillrec(x,y,targetcolour,colour)
unlock pixels
endfunction
function floodfillrec(x,y,targetcolour,colour)
if point(x,y)=targetcolour
dot x,y,colour
floodfillrec(x-1,y,targetcolour,colour)
floodfillrec(x+1,y,targetcolour,colour)
floodfillrec(x,y-1,targetcolour,colour)
floodfillrec(x,y+1,targetcolour,colour)
endif
endfunction
function frnd#(range#)
ret#=rnd(range#*1000.0)/1000.0
endfunction ret#
function wrap180#(angle#)
ret#=wrapvalue(angle#)
if ret#>180 then ret#=ret#-360
if ret#<-180 then ret#=ret#+360
endfunction ret#
function dist#(x#,y#)
ret#=sqrt((x#*x#)+(y#*y#))
endfunction ret#
function FillCircle( CX as integer, CY as integer, R as integer ) `Not mine!!! From somewhere on the DBPro forums
local x as integer
local y as integer
local i as integer
local s as integer
s=R*0.70710678 : ` this number is sin(45) - precalculate!
box CX-s, CY-s, CX+s+1, CY+s+1
s=s+1 : ` Faster than 'inc s'?
i=R*R
for y=s to R
x=sqrt( i-(y*y) )
` Draw top and bottom
box CX-x, CY-y, CX+x+1, CY-y+1
box CX-x, CY+y, CX+x+1, CY+y+1
` Draw left and right
box CX-y, CY-x, CX-y+1, CY+x+1
box CX+y, CY-x, CX+y+1, CY+x+1
next y
endfunction