0+S~%S‡Q«b6_WOÂÃÇÿñèÿMÿ£ÿì'ä6­ÿúÿÿw¨ÿ̪ àÿÿÿÿÿÿÿÿ2Tv˜ºÜþïÍ«‰gE#2Tv˜ºÜþ2Tv˜ºÜþÿÿÿÿÿÿÿÿ"3DUfwˆ™ª»ÌÝîÿÿÿÿÿÿÿÿÿÿÿÿÿ¼ €‚  ª °±»± °ÛÑ»°ÛÑ»»± °±ÀÌÀÇÀÌpppppw °±  ˆ  €ˆ€€ˆ€€ØÐ ØÐ€€€ˆ€€ˆ €‚˜ pqpqpq‰(È̉ˆˆˆˆÈÌÌÌȈˆˆÈÈÈÈȈˆˆÌÌ̈ˆˆˆˆˆˆÈÌÌÌȈˆˆÈÈÈȈˆˆÈÌÌ̈ˆˆÌÌ̈ˆˆˆˆˆÌÌ̈ÈÈÈÈÈÈȈÈÈÈÈÈÈÈÈÈÈÈȈˆˆÈÌÌ̈ˆˆˆˆˆˆÌÌ̈ˆˆȈˆˆÈÈÈȈˆˆÈÌÌ̈ˆˆˆˆˆˆˆˆˆÌÌ̈ˆˆÈÈÈÈȈˆˆÈÌÌ̈ˆˆˆˆˆˆÌÌ̈ˆˆÈÈÈÈȈˆˆÈÌÌ̈ˆˆˆˆˆˆÌÌ̈ˆˆˆˆˆˆÈÌÌÌȈˆˆÈÈÈȈˆˆÈÌÌ̈ˆˆÌÌ̈ˆˆˆˆˆÌÌÌ€ˆˆ€ÌÌ€ˆÈÈÈÈÈȈˆÌŒˆˆˆˆˆˆÈÌÌÌȈˆˆÈÈÈȈÈȈˆˆÌÌ̈ˆˆˆˆˆÌÌ̈ÈÈÈÈÈȈˆˆÈÌÌ̈ÈÈÈÈȈˆÈÌÌ̈ˆˆˆÈÌÌ̈ˆˆÈÈÈÈÈȈˆˆÌÌ̈ˆˆˆˆˆˆÈÌÌÌȈˆˆÈÈÈȈˆˆÈÌÌ̈ˆˆÌÌ̈ˆˆˆˆˆÌÌ̈ˆˆˆÈÌÌÌȈˆˆÈÈÈȈˆˆÈÌÌ̈ˆˆÌÌ̈ˆÈÈÈȈˆÈÌÌÌȈˆˆÈÈÈÈȈˆˆˆÈÈÈÈ€ˆÈ€ÌÌ€ˆˆˆˆÌŒˆˆÈˆÈÈÈȈˆˆÈÌÌ̈ˆˆˆˆˆÈÈÈȈˆÈÌÌ̈ˆˆȈˆˆÈÈÈÈȈˆˆÈÈÈÈÈȈÈÈÈÈÈȈȈˆˆÈÈÈȈˆˆÈÌÌ̈ˆˆˆˆˆˆˆˆˆÌÌ̈ˆˆȈˆˆÈÈÈÈȈŒˆˆÈ€ŒÈ€ŒÈ€ +€€€€ € € € € €€€€€€€€€€€€€€€€" ÀÀÀ À À À À À À À À À ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÏÏ@@@@ @ @ @ @ @ @ @ @ @@@@@@@@@@@@@@@@@O      q@@@@@ @@ @@ @@ @@@@@@@@@OOOOOOOOOO   sÐÐÐ Ð Ð Ð Ð Ð Ð Ð Ð Ð ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐß@@@@ @ @ @ @ @@@@@@@@@@@@@@@@@@@OOOÀÀÀÀ ÀÀ ÀÀ ÀÀ ÀÀ ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÏÏÏ@@@@@ @@ @@ @@ @@ @@@@@@@@@@@@@@@@O ÀÀÀÀÀ À ÀÀÀ À ÀÀÀ À ÀÀÀÀÀÀÀÀÀÀÏÏÏÏÏÏ@@@@@ @ @@@ @ @@@ @ @@@@@@@OOOOOOOOOr     00 00 0 0 0 00 0 00 000000000000000???b@@@ @ @ @ @ @ @ @ @ @ @@@@@@@@@@@@@@@@@O      d d ///rPPPPP PP PP PP PP PPPPPPPPPPPPPPP__sPPPPP PP PP PP PP PPPPPPPPPPPPPPP__sk:ffffffffffffffff–™™™™™™–™™™™™™–––ffffff–ffffff––––––––––––––––ffffff––––™™™™™™––––ffffff–––––––––––––––ffffff–ffffff–ffffff–ffffff–™™™™™™–™™™™™™–™™™™™™–™™™™™™fffffffffffffffffffffffffffffffffff`ffffffffffffffffffffffffffffffffff–™™™™™™`™™™i–™™™™™™–––™™™™™™–™™™™™™–™™™™™™–ffffff`f–ff–ffffff––fff–fff–ffffff–fffff–––––––––––––––––––––––––––––ffffff––ffff–fffff–––ffffff–fffff––™™™™™™–––™™™–™™™™™™––™™™™™™–™™™™™™–ffffff––fff––fffff–––ffffff–fffiff–––––––––––––––––––`i–––––––––––`f–ff–fffff–––––ffffff–`i–`™™™i–™™™™™™––––™™™™™™––f`ffffffffffffffffffffff`€ˆ€ˆ€ˆˆˆˆ€ˆˆ€€€ˆˆˆˆˆˆˆˆ€€€€ˆˆˆ€ˆˆ€ˆˆˆ€ˆˆˆˆ€ˆˆ€ˆ€ˆ€€€€€€ˆ€€ˆ€ˆˆˆˆˆ€€€ˆ€ˆˆˆˆˆˆˆ€ˆ€ˆˆˆ€€€€€ˆˆ€ˆ€ˆˆˆˆˆˆˆˆˆˆ€ˆˆˆ€ˆˆˆˆ€ˆˆˆˆˆ€ˆ€ˆˆ€ˆ€ˆ€€ˆ€€ˆˆˆˆˆ€€€ˆˆ€ˆˆ€ˆˆˆˆˆˆˆˆ€ˆ€€€€€€€€€ˆˆ€ˆ€ˆˆ€€ˆˆˆˆˆˆˆ€€€€ˆ€ˆ€ˆˆ€ˆˆˆˆˆ€€ˆˆˆ€ˆˆ€ˆˆ €‰Ì €‰Ì €‰Ì €‰Ì €‰Ì €‰Ì €‰Ì €‰Ì €‰Ì €‰Ì `f`f`fffffff```fffff`f`fffffff`f`fffff``````f`f```f``ff`fff````ffff``````fff```ff`ffff`ffff```ffff``f`f``f`f`ff`ffff`fff`````ffffff`````ff`f`f````fff`f`f`ff`f`ffff`™ ™™™™™ ™™ ™™™™™ ™ ™™™™™™ ™ ™™ ™ ™ ™™ ™™ ™™™ ™™ ™ ™™™ ™™™™ ™ ™ \…-- title: Cell fighter -- author: Hijong Park -- desc: dogfight and strike the enemies -- script: lua flr=math.floor abs=math.abs ceil=math.ceil sqrt=math.sqrt min=math.min max=math.max colval=0 colval2=0 gamemode=0 level=1 bestscore=pmem(0) function game_init() mapsize=7*32 mapheight=259 groundheight=5 nogravzone=20 waveshow=1 aceshow=0 wavedelay=120 dif=0 airnum=0 maxairnum=0 targetnum=0 acetimer=-1 itemsp=10 itemnum=0 score=0 live=2 hitmark=0 respawn=0 screenmode=0 scrval=68 bonus=1 gameover=0 newrecord=0 spawntime=0 bossspawn=0 player={} player.bomblevel=0 init_player() enemy={} bullet={} particle={} item={} mountain={} mountain2={} gen=0 end function init_player(t) player.dir=0 player.team=0 player.sp=0 player.col=9 player.x=0 player.y=flr(mapheight/2)+1 player.dx=0 player.dy=0 player.firedelay=0 player.firenum=0 player.shield=nil player.dead=0 if t==nil then player.hp=2 player.hpcheck=2 player.spbulletnum=0 player.bombtype=0 end player.bulletnum=2+player.bomblevel camerax=player.x cameray=player.y end function generate_planet(grp,ty) local my,mdir,mdelay,off,di=-7*flr(rnd(groundheight+1)),-1,5,mapheight,1 local inithe=my if ty==1 then off=1 di=-1 end for i=0,mapsize/7 do if mdelay==0 then mdir,mdelay=tablernd({-1,0,1}),2+flr(rnd(2)) if my<=-7*groundheight then tablernd({0,1}) end if my>=0 then tablernd({0,-1}) end if i>mapsize/7-8 then if my>inithe then mdir=-1 end if my=0 and mdir==1 then mdir=0 end for a=1,7 do my=my+mdir table.insert(grp,(my*di)+off) end mdelay=mdelay-1 end end function spawn_enemy(t,u) if t==0 or t==-1 then local spx,spy=camerax+mapsize/2-8+rnd(16), flr(mapheight/2)+1-nogravzone+rnd(nogravzone*2) local e={ team=1, etype=0, evar=0, sp=1, col=11, hp=1, x=spx, y=spy, dx=0, dy=0, movspd=0.6, dirspd=2, shootnum=0, shootspd=1.5, shootdelay=0, dir=rnd(360), avoidsize=20+rnd(6), avoiddir=-1, avoidhe=30+rnd(10), scoring=100 } if t==-1 then e.sp=6 e.col=13 e.evar=1 e.scoring=150 end if t==0 or level%6==0 then if level%6==0 then e.targetplus=true end e.airplus=true airnum=airnum+1 end table.insert(enemy,e) end if t==1 then local spx,spy=camerax+mapsize/2-8+rnd(16), flr(mapheight/2)+1-nogravzone+rnd(nogravzone*2) local e={ team=1, etype=t, sp=2, col=11, hp=1, x=spx, y=spy, dx=0, dy=0, movspd=0.5, shootspd=0.7, shootdelay=0, shootnum=0, dir=0, movdir=rnd(360), movdelay=0, avoidhe=30+rnd(10), hitcir=3, scoring=100 } table.insert(enemy,e) e.airplus=true airnum=airnum+1 end if t==2 then local spx,spy,grp=0,0,0 repeat spx,grp=7*flr(rnd(mapsize/7))+3,tablernd({mountain,mountain2}) spy=grp[spx+1] until enemy_check(spx,spy,3) local e={ team=1, etype=t, sp=3, hp=1, x=spx, y=spy, dx=0, dy=0, movdir=tablernd({1,-1}), dir=rnd(360), movspd=0.3, shootspd=1, shootdelay=0, col=12, hitcir=4, scoring=250 } if level%6~=0 then e.targetplus=true targetnum=targetnum+1 end table.insert(enemy,e) end if t==3 then local spx,spy,grp=0,0,0 if u~=nil then spx=u.x spy=u.y else repeat spx,grp=7*flr(rnd(mapsize/7))+3,tablernd({mountain,mountain2}) spy=grp[spx+1] until enemy_check(spx,spy,3) end local e={ team=1, etype=t, sp=16, ani=0, hp=1, x=spx, y=spy, dx=0, dy=0, setspd=0.4, shootspd=1, shootdelay=0, col=8, hitcir=2, grav=true, scoring=50 } if level%6~=0 then e.targetplus=true targetnum=targetnum+1 end table.insert(enemy,e) end if t==4 or t==5 then local spx,spy,grp,tdir=0,0,0,0 repeat spx,grp=7*flr(rnd(mapsize/7))+3,tablernd({mountain,mountain2}) spy=grp[spx+1] until enemy_check(spx,spy,3) if grp==mountain then if grp[spx]==grp[spx+2] then tdir=90 end if grp[spx]>grp[spx+2] then tdir=135 end if grp[spx]grp[spx+2] then tdir=315 end if grp[spx]mapsize/2 then if ex>cx then ex=ex-mapsize else ex=ex+mapsize end end if dst(cx,cy,ex,ey)<=s+enemy[e].hitcir then c=false end end end return c end function TIC() colval=colval+0.2 if colval>24 then colval=0 end colval2=colval2+1 if colval2>15 then colval2=0 end if gamemode==0 then if btnp(5) or btnp(4) or btnp(6) or btnp(7) then game_init() gamemode=1 end end if gamemode==1 then if score>=25000*bonus and gameover==0 then bonus=bonus+1 live=live+1 sfx(18) end if screenmode==1 and scrval<68 then if scrval==-1 then sfx(22) end scrval=scrval+1 end if screenmode==0 and scrval>-1 then if scrval==68 then sfx(23) end scrval=scrval+1 if scrval>136 then scrval=-1 end end if respawn>0 and waveshow~=2 then if respawn>1 then respawn=respawn-1 end if respawn==1 then if live>=0 then if scrval==-1 then screenmode=1 end if scrval==68 then respawn=0 screenmode=0 aceshow=0 if bossspawn==2 then bossspawn=1 end bullet={} item={} for i = #enemy, 1, -1 do if enemy[i].bulletnum~=nil then enemy[i].bulletnum=1 end if enemy[i].etype==3 then local grp=mountain if enemy[i].ybestscore then bestscore=score newrecord=1 pmem(0,bestscore) end gameover=gameover+1 if gameover>=180 then gameover=0 newrecord=0 gamemode=0 end end end end if hitmark>0 then hitmark=hitmark-1 end if wavedelay>0 then wavedelay=wavedelay-1 if wavedelay==0 then if waveshow==1 then waveshow=0 end end end if aceshow>0 then aceshow=aceshow-1 end if waveshow==2 and wavedelay==0 then if scrval==-1 then screenmode=1 end if scrval==68 then level=level+1 dif=level-1 if dif>12 then dif=12 end gen=0 waveshow=1 wavedelay=120 screenmode=0 end end if targetnum==0 and waveshow==0 and wavedelay==0 then waveshow=2 aceshow=0 wavedelay=120 end if acetimer==-99 then acetimer=300+#enemy*(240-170*(dif/12)) end if waveshow==0 and respawn==0 and acetimer>-1 then if acetimer>0 then acetimer=acetimer-1 if acetimer==0 then spawn_enemy(-1) aceshow=120 sfx(20,nil,-1,3) acetimer=-99 end end end if gen==0 then mountain={} mountain2={} enemy={} bullet={} particle={} item={} spawntime=0 airnum=0 if level%6==3 or level%6==0 then if level%6==3 then mapsize=7*(42+dif*2) mapheight=131 nogravzone=5 groundheight=5 else mapsize=7*26 mapheight=181 nogravzone=50 groundheight=2 end else mapsize=7*(30+flr(dif*1.5)) mapheight=259 nogravzone=20 groundheight=5 end if level>1 then respawn=0 if player.dead==0 then init_player(1) else init_player() end end generate_planet(mountain,0) generate_planet(mountain2,1) for i=1,30 do create_particle(nil,3) end local aanum,samnum,tanknum,basenum=0,0,0,0 if level%6~=0 then maxairnum=flr(6+dif/2) acetimer=-99 bossspawn=0 aanum=3+dif basenum=2+dif tanknum=0+flr(dif/2) samnum=-3+dif if level%6==2 then tanknum=3+dif aanum=0 end if level%6==5 then samnum=0+dif aanum=-6+dif end else maxairnum=flr(5+dif/4) acetimer=-1 targetnum=30 aanum=flr(dif/2) samnum=-2+flr(dif/2) bossspawn=1 end if aanum>0 then for i=1,aanum do spawn_enemy(4) end end if samnum>0 then for i=1,samnum do spawn_enemy(5) end end if tanknum>0 then for i=1,tanknum do spawn_enemy(2) end end if basenum>0 then for i=1,basenum do spawn_enemy(6) end end gen=1 end if spawntime==0 and airnum0 then spawntime=spawntime-1 if spawntime==0 then if level%6==3 or level%6==0 then if level%6==0 then spawn_enemy(0) else spawn_enemy(1) end else spawn_enemy(tablernd({0,1})) end end end if bossspawn==1 and airnum==0 and targetnum==1 and scrval==-1 then bossspawn=2 spawn_enemy(-2) end if screenmode~=1 then for id,p in ipairs(particle) do update_unit(p,3) end for id,i in ipairs(item) do update_unit(i,4) end for id,b in ipairs(bullet) do if b.projty~=-2 and b.bombtype~=1 then col_blt(b,player) for id,b2 in ipairs(bullet) do if b2~=b and b2.projty==2 then col_blt(b,b2) end end for id,e in ipairs(enemy) do col_blt(b,e) end end update_unit(b,2) end for id,e in ipairs(enemy) do col_unit(player,e) update_unit(e,1) end update_unit(player,0) end end _draw() end function update_unit(u,t) u.x=u.x+u.dx u.y=u.y+u.dy if u.grav==true and abs(u.y-flr(mapheight/2)+1)>=nogravzone-1 then local comp=flr(mapheight/2)+1-nogravzone-1 if u.y>flr(mapheight/2)+1 then comp=flr(mapheight/2)+1+nogravzone-1 end local g=(u.y-comp)/1200 if g>0.013 then g=0.013 end if g<-0.013 then g=-0.013 end u.dy=u.dy+g end if u.x<0 then u.x=u.x+mapsize if u==player then camerax=camerax+mapsize end elseif u.x>=mapsize then u.x=u.x-mapsize if u==player then camerax=camerax-mapsize end end if t==0 then if u.dead==0 then if btn(0) or btn(1) or btn(2) or btn(3) then local movdir=0 if btn(0) then movdir=90 end if btn(1) then movdir=270 end if btn(2) then movdir=180 end if btn(3) then movdir=0 end if btn(1) and btn(2) then movdir=225 end if btn(0) and btn(2) then movdir=135 end if btn(0) and btn(3) then movdir=45 end if btn(1) and btn(3)then movdir=315 end u.dir=angle_lerp(u.dir, movdir, 5) end u.dx=cos(u.dir/360)*0.7 u.dy=sin(u.dir/360)*0.7 if scrval==-1 then if btnp(5) or btnp(7) then u.firenum=4 end if (btnp(4) or btnp(6)) and u.bulletnum>0 then fire_bullet(u,u.dir,0,1,u.bombtype) sfx(1,nil,-1,0) end end if u.firenum>0 and u.firedelay==0 then fire_bullet(u,u.dir,2.25,0) sfx(0,nil,-1,0) u.firedelay=4 u.firenum=u.firenum-1 end if u.firedelay>0 then u.firedelay=u.firedelay-1 end if u.hp>0 and u.hpcheck>u.hp then u.hpcheck=u.hp u.shield=60 hitmark=4 sfx(4,nil,-1,2) end if u.shield~=nil then u.shield=u.shield-1 if u.shield==0 then u.shield=nil end end if u.bombtype>0 and u.spbulletnum==0 then u.bombtype=0 end col_ground(u,u.x+anglepos(cos,u.dir,3),u.y+anglepos(sin,u.dir,3)) if u.hp<=0 then sfx(5,nil,-1,2) u.dead=1 create_particle(u,1) live=live-1 respawn=60 end end end if t==1 then local tax,tay,scrck=player.x,player.y,screencheck(u) and waveshow==0 if abs(u.x-tax)>mapsize/2 then if tax>u.x then tax=tax-mapsize else tax=tax+mapsize end end local shootdir=di(u.x,u.y,tax,tay) if u.shootspd>0 then local targetspd=dst(0,0,player.dx,player.dy) local alpha=targetspd/u.shootspd local targetdir=di(0,0,player.dx,player.dy) local phi=degtorad(targetdir-shootdir) local beta= alpha * math.sin(phi) shootdir=shootdir+radtodeg(math.asin(beta)) end if u.etype==0 then if u.evar==0 then u.movspd=0.5+0.15*(dif/12) u.dirspd=2.5+0.4*(dif/12) u.shootspd=1.1+0.15*(dif/12) if level%6==0 then u.movspd=0.75 end else u.col=subcol3 u.movspd=0.75+0.1*(dif/12) u.dirspd=3.75+0.5*(dif/12) u.shootspd=1.6+0.2*(dif/12) end local enemydir=di(tax,tay,u.x,u.y) if dst(tax,tay,u.x,u.y)<=13 or angle_difference(player.dir,enemydir,u.avoidsize)==true then if (player.dir>enemydir and abs(player.dir-enemydir) >= 180) or (player.dir<=enemydir and abs(player.dir-enemydir) < 180) then u.avoiddir=(player.dir+(90+rnd(80)))%360 else u.avoiddir=(player.dir-(90+rnd(80)))%360 end u.avoidsize=20+rnd(6) end if u.y+(u.dy*10)>=mountain[flr(u.x)+1]-u.avoidhe then u.avoiddir=70+rnd(40) u.avoidhe=30+rnd(10) end if u.y+(u.dy*10)<=mountain2[flr(u.x)+1]+u.avoidhe then u.avoiddir=250+rnd(40) u.avoidhe=30+rnd(10) end if u.avoiddir~=-1 then u.dir=angle_lerp(u.dir,u.avoiddir,u.dirspd) if u.dir==u.avoiddir then u.avoiddir=-1 end else if scrck==true then u.dir=angle_lerp(u.dir,shootdir,u.dirspd) else u.dir=angle_lerp(u.dir,shootdir-30+rnd(60),u.dirspd) end end u.dx=cos(u.dir/360)*u.movspd u.dy=sin(u.dir/360)*u.movspd if u.dir==shootdir and scrck==true then if u.shootdelay==0 then u.shootdelay=flr(29-9*(dif/12)) if u.evar==1 then u.shootdelay=flr(20-10*(dif/12)) end else if u.shootdelay>0 then u.shootdelay=u.shootdelay-1 if u.shootdelay==0 then if u.shootnum<3 then if u.evar==0 then u.shootnum=u.shootnum+1 end fire_bullet(u,u.dir,u.shootspd,0) sfx(7,nil,-1,1) else u.shootnum=0 end end end end else u.shootnum=0 u.shootdelay=0 end col_ground(u,u.x+anglepos(cos,u.dir,3),u.y+anglepos(sin,u.dir,3)) end if u.etype==1 then u.movspd=0.4+0.2*(dif/12) u.shootspd=0.725+0.075*(dif/12) if u.movdelay==0 then u.movdelay=flr(60+rnd(120)) end if u.movdelay>0 then u.movdelay=u.movdelay-1 if u.movdelay==0 then u.movdir=(u.dir-60+rnd(120))%360 end end if u.y+(u.dy*10)>=mountain[flr(u.x)+1]-u.avoidhe then u.movdir=70+rnd(40) u.avoidhe=30+rnd(10) u.movdelay=0 end if u.y+(u.dy*10)<=mountain2[flr(u.x)+1]+u.avoidhe then u.movdir=250+rnd(40) u.avoidhe=30+rnd(10) u.movdelay=0 end u.dir=angle_lerp(u.dir,u.movdir,3) u.dx=cos(u.dir/360)*u.movspd u.dy=sin(u.dir/360)*u.movspd if scrck==true then if u.shootdelay==0 then if u.shootnum==0 then u.shootdelay=flr(120-30*(dif/12)) u.shootnum=flr(1+2*(dif/12)) else u.shootdelay=7 end end if u.shootdelay>0 then u.shootdelay=u.shootdelay-1 if u.shootdelay==0 then u.shootnum=u.shootnum-1 fire_bullet(u,shootdir,u.shootspd,0) sfx(7,nil,-1,1) end end else u.shootdelay=0 u.shootnum=0 end col_ground(u,u.x+anglepos(cos,u.dir,3),u.y+anglepos(sin,u.dir,3)) end if u.etype==2 then u.movspd=0.3+0.4*(dif/12) u.shootspd=0.75+0.25*(dif/12) u.dx=u.movspd*u.movdir u.dir=u.dir+u.dx*10 local grp=mountain if u.y0 then u.shootdelay=u.shootdelay-1 if u.shootdelay==0 then fire_bullet(u,shootdir+20-rnd(40),u.shootspd,-1) sfx(13,nil,-1,1) end end else u.shootdelay=0 end end if u.etype==3 then u.setspd=0.2+0.2*(dif/12) u.ani=u.ani+0.25 if u.ani>3 then u.ani=0 end u.sp=16+u.ani if u.y<=mountain2[flr(u.x+1)] then u.dy=u.setspd+rnd(u.setspd*1.5) u.dx=(u.setspd/2+rnd(u.setspd/2))*tablernd({1,-1}) end if u.y>=mountain[flr(u.x+1)] then u.dy=-(u.setspd+rnd(u.setspd*1.5)) u.dx=(u.setspd/2+rnd(u.setspd/2))*tablernd({1,-1}) end end if u.etype==4 then if u.wep==0 then u.shootspd=0.9+0.2*(dif/12) u.dirspd=1.4+0.8*(dif/12) else u.shootspd=0.725+0.08*(dif/12) end if scrck==true then if u.wep==0 then u.turretdir=angle_lerp(u.turretdir,shootdir,u.dirspd) local dck=angle_difference(u.turretdir,u.centerdir) if dck>80 then u.turretdir=(u.centerdir+80)%360 end if dck<-80 then u.turretdir=(u.centerdir-80)%360 end end if u.bulletnum>0 and (u.turretdir==shootdir or u.wep==1) then if u.shootdelay==0 then u.shootdelay=flr(30-5*(dif/12)) if u.wep==1 then u.shootdelay=flr(90-60*(dif/12)+rnd(30)) end end if u.shootdelay>0 then u.shootdelay=u.shootdelay-1 if u.shootdelay==0 then fire_bullet(u,u.turretdir,u.shootspd,u.wep*2) sfx(7+u.wep,nil,-1,1) if u.wep==1 then u.shootdelay=240-60*(dif/12) end end end end end end if u.etype==5 then if u.hitmark>0 then u.hitmark=u.hitmark-1 end if u.hp>0 and u.hpcheck>u.hp then u.hpcheck=u.hp u.hitmark=2 sfx(14,nil,-1,3) end end if u.etype==-2 then u.shootspd=0.75+0.15*(dif/12) if scrck==true then if u.shootdelay==0 then u.shootdelay=flr(40-10*(dif/12)) end if u.shootdelay>0 then u.shootdelay=u.shootdelay-1 if u.shootdelay==0 then fire_bullet(u,shootdir,u.shootspd,0) sfx(7,nil,-1,1) end end else u.shootdelay=0 end if u.hitmark>0 then u.hitmark=u.hitmark-1 end if u.hp>0 and u.hpcheck>u.hp then u.hpcheck=u.hp u.hitmark=2 sfx(14,nil,-1,3) end end if u.hp<=0 then if u.etype>1 then local ds,ch=10,2 if u.etype==3 then ds=11 end if u.etype==5 then ds=12 ch=3 end sfx(ds,nil,-1,ch) create_particle(u,-1,u.hitcir*2.5) create_particle(u,2,u.hitcir) if itemsp==0 then local ity=-1 if itemnum==0 and player.hp<3 then ity=0 end if itemnum==1 or itemnum==3 then ity=tablernd({2,3}) end if itemnum==2 and player.bomblevel<3 then ity=1 end if ity~=-1 then create_item(u,ity) end itemsp=20 itemnum=itemnum+1 if itemnum>3 then itemnum=0 end else itemsp=itemsp-1 end else create_particle(u,1) if u.etype==-2 then create_particle(u,-1,u.hitcir*2.5) create_particle(u,2,u.hitcir) sfx(16,nil,-1,2) else sfx(9,nil,-1,2) end end if u.etype==5 then for i=1,2+(dif/7) do spawn_enemy(3,u) end end if u.targetplus~=nil then targetnum=targetnum-1 end if u.airplus~=nil then airnum=airnum-1 end score=score+u.scoring del(enemy,u) end end if t==2 then if u.projty==-2 then local grp=mountain if u.y0 then u.firenum=u.firenum-1 else u.hp=-10 end end if u.firetime>0 then u.firetime=u.firetime-1 end end if u.projty==-1 then u.ani=u.ani+0.5 if u.ani>2 then u.ani=0 end end if u.projty==1 then u.dir=di(0,0,u.dx,u.dy) local pspd=dst(0,0,u.dx,u.dy)*3 if u.trail>pspd then u.trail=u.trail-0.3 else u.trail=u.trail+0.3 end if abs(u.trail-pspd)<=0.15 then u.trail=pspd end if u.bombtype==2 then if u.detotime>0 then u.detotime=u.detotime-1 if u.detotime==0 then u.hp=0 end end end end if u.projty==2 then local tax,tay=player.x,player.y if abs(u.x-tax)>mapsize/2 then if tax>u.x then tax=tax-mapsize else tax=tax+mapsize end end u.dir=angle_lerp(u.dir,di(u.x,u.y,tax,tay),u.dirspd) u.dx=cos(u.dir/360)*u.movspd u.dy=sin(u.dir/360)*u.movspd end if u.projty==3 then u.dir=di(0,0,u.dx,u.dy) end if u.projty~=-2 then u.lx=anglepos(cos,u.dir,u.len) u.ly=anglepos(sin,u.dir,u.len) col_ground(u,u.x,u.y,u.x+u.lx,u.y+u.ly) end if screencheck(u)==false then u.hp=-10 end if u.hp<=0 then if u.hp>-10 and u.projty>=1 and u.expdamage>0 then create_particle(u,0,u.expsize,u.expdamage) if u.expsize<=4 then sfx(17,nil,-1,1) else sfx(2,nil,-1,1) end end if u.hp>-10 and u.projty==1 and u.bombtype==2 then create_particle(u,-1,u.expsize) sfx(3,nil,-1,1) for i=1,20 do fire_bullet(u,u.dir-160+rnd(320),0.05+rnd(0.25),3) end end if u.hp>-10 and u.projty==1 and u.bombtype==1 then fire_bullet(u,0,-1,-2) fire_bullet(u,0,1,-2) end if u.owner~=nil then u.owner.bulletnum=u.owner.bulletnum+1 end del(bullet,u) end end if t==3 then if u.damage~=nil and u.damage>0 then if dst(u.x,u.y,player.x,player.y)<=u.size then player.hp=player.hp-u.damage end for e=1,#enemy do local myh=0 if enemy[e].hitcir~=nil then myh=enemy[e].hitcir end if dst(u.x,u.y,enemy[e].x,enemy[e].y)<=u.size+myh then enemy[e].hp=enemy[e].hp-u.damage end end u.damage=0 end if u.ptype==0 then if u.size>0 then u.size=u.size-0.5 else u.hp=0 end end if u.ptype==1 then u.dx=u.dx-u.dx/45 u.dy=u.dy-u.dy/45 if u.size>0 then u.size=u.size-1 else u.hp=0 end col_ground(u,u.x+u.dx*2,u.y+u.dy*2) end if u.ptype==2 then if u.tim>0 then u.tim=u.tim-1 if u.tim==0 then u.x=rnd(mapsize) u.y=flr(mapheight/2)+1-(nogravzone-1)+rnd((nogravzone-1)*2) u.tim=120+flr(rnd(120)) end end end if u.hp~=nil and u.hp<=0 then del(particle,u) end end if t==4 then if abs(u.y-flr(mapheight/2)+1)>=nogravzone-1 then local comp=0.01 if u.y>flr(mapheight/2)+1 then comp=-0.01 end u.dy=u.dy+comp if u.dy>0.2 then u.dy=0.2 end if u.dy<-0.2 then u.dy=-0.2 end end if dst(u.x,u.y,player.x,player.y)<=8 and player.dead==0 then if u.itype==0 then if player.hp<4 then player.hp=player.hp+1 player.hpcheck=player.hp end end if u.itype==1 then if player.bulletnum<5 then player.bomblevel=player.bomblevel+1 player.bulletnum=player.bulletnum+1 end end if u.itype==2 then player.bombtype=1 player.spbulletnum=5 end if u.itype==3 then player.bombtype=2 player.spbulletnum=5 end sfx(15,nil,-1,2) del(item,u) end end end function fire_bullet(u,sdir,spd,ty,subty) local bul = { projty=ty, hp=1, x=u.x+anglepos(cos,sdir,5), y=u.y+anglepos(sin,sdir,5), dx=cos(sdir/360)*spd, dy=sin(sdir/360)*spd, len=2, dir=sdir, team=u.team, col=10-u.team*3 } if ty==-2 then bul.x=u.x bul.y=u.y bul.dx=spd bul.firetime=0 bul.firenum=6 end if ty==-1 then bul.ani=0 bul.grav=true bul.len=1 end if ty==1 then bul.x=u.x bul.y=u.y bul.bombtype=subty if subty==0 then u.bulletnum=u.bulletnum-1 bul.owner=u bul.expdamage=12 bul.expsize=9 else u.spbulletnum=u.spbulletnum-1 if subty==1 then bul.expdamage=12 bul.expsize=7 end if subty==2 then bul.detotime=30 bul.expdamage=0 bul.expsize=5 end end bul.dx=bul.dx+u.dx bul.dy=bul.dy+u.dy bul.grav=true bul.trail=0 bul.len=1 end if ty==2 then bul.owner=u u.bulletnum=u.bulletnum-1 bul.movspd=spd bul.dirspd=1.5+0.25*(dif/12) bul.len=5 bul.expsize=6 bul.expdamage=14 end if ty==3 then bul.x=u.x bul.y=u.y bul.dx=bul.dx+u.dx bul.dy=bul.dy+u.dy bul.grav=true bul.expsize=4 bul.expdamage=4 end bul.lx=anglepos(cos,sdir,bul.len) bul.ly=anglepos(sin,sdir,bul.len) table.insert(bullet,bul) end function create_item(u,ty) local i = { itype=ty, x=u.x, y=u.y, dx=0, dy=0, } table.insert(item,i) end function create_particle(u,ty,si,dam) if ty<=0 then local p = { hp=1, ptype=0, x=u.x, y=u.y, dx=0, dy=0, size=si } if u.lx~=nil then p.x=p.x+u.lx p.y=p.y+u.ly end if ty==0 then p.damage=dam end table.insert(particle,p) end if ty==1 then local psp,pdir=0.6,0 for i=0,15 do local p = { hp=1, ptype=1, size=30, x=u.x, y=u.y, dx=cos(pdir/360)*psp, dy=sin(pdir/360)*psp, } table.insert(particle,p) pdir=pdir+45 if pdir>=360 then pdir=0 psp=psp*2 end end end if ty==2 then local pdir=0 local psp=0 local pnum=si*6 for i=1,pnum do pdir=i*(360/pnum) psp=si/5 local p = { hp=1, ptype=1, size=30, x=u.x, y=u.y, dx=cos(pdir/360)*psp, dy=sin(pdir/360)*psp, } table.insert(particle,p) end end if ty==3 then local p = { ptype=2, x=rnd(mapsize), y=flr(mapheight/2)+1-(nogravzone-1)+rnd((nogravzone-1)*2), dx=0, dy=0, tim=120+flr(rnd(120)), } table.insert(particle,p) end end function col_blt(b,u,t) if b.team~=u.team and b.hp>0 and u.hp>0 then local col=nil local ux=u.x if abs(u.x-b.x)>mapsize/2 then if u.x>b.x then ux=ux-mapsize else ux=ux+mapsize end end if u.hitcir==nil then if (abs(b.x-ux)<2 and abs(b.y-u.y)<2) or (abs(b.x-(ux+anglepos(cos,u.dir,3)))<2 and abs(b.y-(u.y+anglepos(sin,u.dir,3)))<2) or (abs(b.x+b.lx-ux)<2 and abs(b.y+b.ly-u.y)<2) or (abs(b.x+b.lx-(ux+anglepos(cos,u.dir,3)))<2 and abs(b.y+b.ly-(u.y+anglepos(sin,u.dir,3)))<2) then col=true end else if t==nil then if dst(b.x,b.y,ux,u.y)<=u.hitcir or dst(b.x+b.lx,b.y+b.ly,ux,u.y)<=u.hitcir then col=true end else if intercept_line(b.x,b.y,b.x+b.lx,b.y+b.yx,ux,u.y,ux+u.lx,u.y+u.yx)==true then col=true end end end if col==true then b.hp=b.hp-1 if u.shield==nil then u.hp=u.hp-1 end end end end function col_unit(b,u) if b.team~=u.team and b.hp>0 and u.hp>0 then local col=nil local ux=u.x if abs(u.x-b.x)>mapsize/2 then if u.x>b.x then ux=ux-mapsize else ux=ux+mapsize end end if u.hitcir==nil then if (abs(b.x-ux)<2 and abs(b.y-u.y)<2) or (abs(b.x-(ux+anglepos(cos,u.dir,3)))<2 and abs(b.y-(u.y+anglepos(sin,u.dir,3)))<2) or (abs(b.x+anglepos(cos,b.dir,3)-ux)<2 and abs(b.y+anglepos(sin,b.dir,3)-u.y)<2) or (abs(b.x+anglepos(cos,b.dir,3)-(ux+anglepos(cos,u.dir,3)))<2 and abs(b.y+anglepos(sin,b.dir,3)-(u.y+anglepos(sin,u.dir,3)))<2) then col=true end else if dst(b.x,b.y,ux,u.y)<=u.hitcir+1 or dst(b.x+anglepos(cos,b.dir,3),b.y+anglepos(sin,b.dir,3),ux,u.y)<=u.hitcir+1 then col=true end end if col==true then b.hp=-1 u.hp=-1 end end end function col_ground(u,x1,y1,x2,y2) local ck=1 local grp=mountain local coli=nil if y1=mapsize then x1=x1-mapsize end if y1*ck>=(grp[flr(x1)+1]-ck)*ck then coli=true end if x2~=nil then if x2<0 then x2=x2+mapsize elseif x2>=mapsize then x2=x2-mapsize end if y2*ck>=(grp[flr(x2)+1]-ck)*ck then coli=true end end if coli==true then u.hp=-1 end end function screencheck(u) local px=u.x if abs(px-camerax)>mapsize/2 then if px>camerax then px=px-mapsize else px=px+mapsize end end if abs(px-camerax)<=68+5 and abs(u.y-cameray)<=67+5 then return true else return false end end function _draw() cls() backcol,maincol,maincol2,subcol,subcol2,subcol3,subcol4,subcol5 =0 ,7+colval%8 ,14-colval%8 ,0 ,8 ,12 ,10 ,1 if level%6==0 then subcol4=13 end if colval%8>=1 then subcol=5 subcol2=10 subcol3=12 subcol4=10 if level%6==0 then subcol4=13 end subcol5=1 end if colval%8>=2 then subcol=6 subcol2=8 subcol3=13 subcol4=9 if level%6==0 then subcol4=12 end subcol5=3 end if colval%8>=3 then subcol=7 subcol2=10 subcol3=13 subcol4=9 if level%6==0 then subcol4=12 end subcol5=3 end if colval%8>=4 then subcol=7 subcol2=8 subcol3=8 subcol4=4 if level%6==0 then subcol4=1 end subcol5=2 end if colval%8>=5 then subcol=6 subcol2=10 subcol3=8 subcol4=4 if level%6==0 then subcol4=1 end subcol5=2 end if colval%8>=6 then subcol=5 subcol2=8 subcol3=14 subcol4=9 if level%6==0 then subcol4=12 end subcol5=5 end if colval%8>=7 then subcol=0 subcol2=10 subcol3=14 subcol4=9 if level%6==0 then subcol4=12 end subcol5=5 end if gamemode==0 then local t1,t2,t3="PRESENTED BY HIJONG PARK, 2022", "PRESS ANY BUTTON TO START", "BEST : "..bestscore print(t1,centerx(t1),50,subcol2) print(t2,centerx(t2),100,subcol) print(t3,centerx(t3),120,maincol) pal(12,maincol) pal(8,subcol) spr(48,64,10,0,1,0,0,14,4) pal() pal(2,subcol4) for i=0,12 do spr(34,-40+i*24+colval*2,72,0,1) end pal() end if gamemode==1 then if hitmark>0 then backcol=8 end rect(50,0,150,150,backcol) line(0, flr(mapheight/2)+1-nogravzone-(cameray-68), mapsize+20, flr(mapheight/2)+1-nogravzone-(cameray-68), subcol5) line(0, flr(mapheight/2)+1+nogravzone-(cameray-68), mapsize+20, flr(mapheight/2)+1+nogravzone-(cameray-68), subcol5) camerax=player.x cameray=player.y for i=flr(camerax)-70,flr(camerax)+70 do local mx=i if i<0 then mx=i+mapsize end if i>mapsize-1 then mx=i-mapsize end pix(i-(camerax-119),mountain[mx+1]-(cameray-68),subcol4) pix(i-(camerax-119),mountain2[mx+1]-(cameray-68),subcol4) end for id,p in ipairs(particle) do draw_unit(p,3) end for id,i in ipairs(item) do draw_unit(i,4) end for id,b in ipairs(bullet) do draw_unit(b,2) end for id,e in ipairs(enemy) do if e.etype==0 then draw_unit(e,-1) else draw_unit(e,-2) end end if player.dead==0 then draw_unit(player,0) end rect(0,0,51,136,1) rect(239-51,0,52,136,1) local t1,t2,t3,t4,t5,t6,t7,t8,t9,t10= "SCORE",""..score,"SHIPS","BOMB","SHIELD","NONE","LEVEL",""..level,"TARGET",""..targetnum if player.bombtype==1 then t4="NAPALM" end if player.bombtype==2 then t4="CLUSTER" end print(t1,centerx(t1)-96,10,7) print(t2,centerx(t2)-96,20,maincol) print(t3,centerx(t3)-96,35,7) print(t4,centerx(t4)-96,75,7) print(t5,centerx(t5)-96,105,7) print(t7,centerx(t7)+96,10,7) print(t8,centerx(t8)+96,20,maincol) print(t9,centerx(t9)+96,105,7) print(t10,centerx(t10)+96,115,subcol3) rect(239-49,40,50,50,0) local rs=(flr(colval*2))+1 local rsize=flr(67/(mapsize/50)) if rs>24 then rs=rs-24 end rectb(214-rs,64-rs,2+rs*2,2+rs*2,2) rectb(214-rsize,64-rsize,2+rsize*2,2+rsize*2,2) rect(214,64,2,2,8) for id,e in ipairs(enemy) do radar_draw(e,e.col) end local livenum,livex,livey=live,0,0 if livenum>15 then livenum=15 end pal(2,subcol4) for i=0,livenum do spr(32,-1+livex,44+livey,0) livex=livex+6 if livex>42 then livex=0 livey=livey+10 end end if player.bombtype==0 then for i=0,player.bulletnum-1 do circ(4+i*10,87,3,subcol2) end else for i=0,player.spbulletnum-1 do circ(4+i*10,87,3,subcol3) end end pal(1,subcol) if player.hp>1 then for i=0,player.hp-2 do spr(33,15+i*10,113,0) end else print(t6,centerx(t6)-96,115,8) end pal() line(51,0,187,0,backcol) if gameover>0 then local t1,t2="GAME OVER","NEW HIGH SCORE" if newrecord==1 then print(t1,centerx(t1),56,maincol) print(t2,centerx(t2),76,maincol) else print(t1,centerx(t1),66,maincol) end else if aceshow>0 then local t1="ACE FIGHTER INCOMING" print(t1,centerx(t1),46,maincol) end if waveshow==1 then local t1,t2="LEVEL "..level,"CLEAN THE SURFACE" if level%6==0 then t2="ELIMINATE THE FIGHTERS" end print(t1,centerx(t1),46,maincol) print(t2,centerx(t2),86,7) end if waveshow==2 then local t1="LEVEL COMPLETED" print(t1,centerx(t1),46,maincol) end end line(188,39,240,39,maincol) line(188,90,240,90,maincol) rect(49,0,2,136,maincol) rect(188,0,2,136,maincol) if scrval>=0 then local c1,c2=scrval,-1 if scrval>68 then c1=68 c2=scrval-68 end for i=0,c1 do if i>c2 then rectb(119-i,68-i,1+i*2,1+i*2,i-colval2) end end end end end function draw_unit(u,t) local ux,uy=u.x,u.y if t==0 then ux=119 uy=68 else if abs(ux-camerax)>mapsize/2 then if ux>camerax then ux=ux-mapsize else ux=ux+mapsize end end if uy0 then udir=u.dir+45+i*90 len=3 col=u.col end local dx,dy=anglepos(cos,udir,len),anglepos(sin,udir,len) line(ux,uy, ux+dx,uy+dy,col) end pal(2,subcol4) pal(1,subcol) spr(u.sp,ux-4,uy-4,0) pal() if u.shield~=nil then circb(ux,uy,4,5+(u.shield/3)%3) end end if t==-2 then if u.etype==2 then for i=0,3 do line(ux,uy,ux+cos((u.dir+i*90)/360)*u.hitcir,uy+sin((u.dir+i*90)/360)*u.hitcir,subcol2) end end if u.etype<=3 then pal(13,maincol) pal(1,subcol) spr(u.sp,ux-4,uy-4,0) pal() end if u.etype==4 then circ(ux,uy,u.hitcir,u.col) if u.wep==0 then pix(ux+anglepos(cos,u.turretdir,u.hitcir),uy+anglepos(sin,u.turretdir,u.hitcir),7) elseif u.bulletnum>0 then line(ux,uy,ux+cos(u.centerdir/360)*6,uy+sin(u.centerdir/360)*6,subcol3) end circ(ux,uy,1,8) end if u.etype==5 or u.etype==-2 then local c=u.col if u.hitmark>0 then c=5 end circ(ux,uy,u.hitcir,c) if u.etype==-2 then circ(ux,uy,6,0) circ(ux,uy,u.hp/4,maincol) else circ(ux,uy,3,0) circ(ux,uy,u.hp/4,maincol) end end end if t==2 then if u.projty==-1 then spr(4+u.ani,ux-4,uy-4,0) pix(ux,uy,maincol) end if u.projty==0 or u.projty==3 then local c=u.col if u.projty==3 then c=subcol2 end line(ux,uy, ux+u.lx, uy+u.ly,c) end if u.projty==1 then local pdir,col=di(u.dx,u.dy,0,0),subcol2 if u.bombtype==1 then col=10 end if u.bombtype==2 then col=subcol3 end line(ux,uy, ux+anglepos(cos,pdir,u.trail), uy+anglepos(sin,pdir,u.trail),6) circ(ux,uy,1,col) if u.bombtype==1 then pix(ux,uy,subcol) end end if u.projty==2 then line(ux,uy, ux+u.lx, uy+u.ly,subcol3) circ(ux,uy,1,subcol2) end end if t==3 then if u.ptype==0 then local c=maincol2 if u.damage~=nil then c=subcol2 end circ(ux,uy,u.size,c) end if u.ptype==1 then pix(ux,uy,maincol2) end if u.ptype==2 then pix(ux,uy,subcol5) end end if t==4 then local nam,ucol="S",subcol if u.itype==1 then nam="B" ucol=subcol2 end if u.itype==2 then nam="N" ucol=subcol3 end if u.itype==3 then nam="C" ucol=subcol3 end circb(ux,uy,5,ucol) print(nam,ux-2,uy-2,ucol) end end function radar_draw(u,c) local px,py=u.x,u.y if abs(px-camerax)>mapsize/2 then if px>camerax then px=px-mapsize else px=px+mapsize end end local rx,ry=(px-camerax)/(mapsize/50)+215,(py-cameray)/(mapsize/50)+64 if ry<64-24 then ry=64-24 end if ry>64+25 then ry=64+25 end if u.hitcir==nil or u.hitcir<=5 then pix(rx,ry,c) else circ(rx,ry,1,c) end end function centerx(m) return 120-#m*2.75 end function sget(x, y) local addr = (16384 + (((x // 8) + ((y // 8) * 16)) * 32)) return peek4(((addr * 2) + (x % 8) + ((y % 8) * 8))) end function rnd(a) a=a or 1 return math.random()*a end function cos(a) return math.cos(2*math.pi*a) end function sin(a) return -math.sin(2*math.pi*a) end function atan2(a,b) b=b or 1 return math.atan(a,b)/(2*math.pi) end function di(o1,o2,o3,o4) return ((atan2(o4-o2,o1-o3)*360)+180)%360 end function pset(x,y,c) c=c or __p8_color c=peek4(0x7FE0+c) x,y=__p8_coord(x,y) poke4(y*240+x,c) end function pal(c0,c1) c0=c0 or -1 c1=c1 or -1 if c0<0 and c1<0 then for i=0,15 do poke4(0x7FE0+i,i) end else c0=flr(c0%16) if c1<0 then c1=c0 end c1=flr(c1%16) poke4(0x7FE0+c0,c1) end end function tablernd(tb) local tab=tb return tab[math.random(#tab)] end function angle_lerp(angle1, angle2, t) local ang1=angle1%360 local ang2=angle2%360 if angle_difference(ang1,ang2,t)~=true then if ang1>ang2 then if abs(ang1-ang2) <= 180 then ang1=ang1-t else ang1=ang1+t end else if abs(ang1-ang2) < 180 then ang1=ang1+t else ang1=ang1-t end end else ang1=ang2 end return ang1%360 end function angle_difference(ang1,ang2,t) if t==nil then if abs(ang1-ang2)>180 then if ang1>ang2 then ang2=ang2+360 else ang2=ang2-360 end end return ang1-ang2 else if abs(ang1-ang2)<=t or abs((ang1+360)-ang2)<=t or abs((ang1-360)-ang2)<=t then return true end end end function anglepos(ang,dir,spd) local ss=ang(dir/360)*spd if ss<0 then ss=ceil(ss) end return ss end function dst(o1,o2,o3,o4) if abs(o1-o3)>mapsize/2 then if o3>o1 then o3=o3-mapsize else o3=o3+mapsize end end return sqrt((o1-o3)^2+(o2-o4)^2) end function degtorad(deg) return (deg*math.pi)/180 end function radtodeg(rad) return (rad*180)/math.pi end function del(t,a) for i,v in ipairs(t) do if v==a then table.remove(t,i) return end end end function intercept_line(x1,y1,x2,y2,x3,y3,x4,y4) local ax, ay, bx, by, cx, cy, dx, dy= (x1), (y1), (x2), (y2), (x3), (y3), (x4), (y4) local d = (ax-bx)*(cy-dy)-(ay-by)*(cx-dx) if d ~= 0 then local a, b = ax*by-ay*bx, cx*dy-cy*dx local x = (a*(cx-dx) - b*(ax-bx))/d local y = (a*(cy-dy) - b*(ay-by))/d if x <= max(ax, bx) and x >= min(ax, bx) and x <= max(cx, dx) and x >= min(cx, dx) and y <= max(ay, by) and y >= min(ay, by) and y <= max(cy, dy) and y >= min(cy, dy) then return true end end end