After seeing LokiStriker's and Achie's shmups made in 1024 compressed bytes, I wanted to give it a go.
Here's the uncompressed source code.
--1k shmup --werxzy -- enemy data ty=split("⁶:425affffe7662400,0.01,0,7,0,0.3,0,-0.0001,2,5,5`⁶:425affffe7662400,0.01,0,7,0,1.1,0,-0.01,1,3,3`⁶:22227f7f2a361c08,0,0,9,0,0.3,0,0.02,4,1,3`⁶:425affffe7662400,0,0,13,0,0.1,0,0,3,30,20`⁶:3c42bdbdbda5423c,0,0,5,0,0.25,0,-0.0005,5,20,25","`") -- bullet data bty=split("●,1,0,0,0.8,1,60`✽,1,-15,15,0.4,3,200`✽,0,-120,10,0.4,7,100`\feミ,0,0,180,1,2,20`✽,1,0,36,1,10,30","`") cartdata"shm1k_werx" function _init() en,bul,pb,px,py,ph,pi,pc,sc = {},{},{},64,80,3,0,0,0 end function _update60() cls() if ph ~= 0 then -- spawn regular enemy if t() % 2 == 1 then e=add(en, split(ty[rnd{1,2,3}])) e[7]=rnd(e[2])-e[2]/2 e.r,e[2]=rnd(20),rnd(100)+10 end -- spawn boss enemy if t() % 20 == 1 then e=add(en, split(ty[rnd{4,5}])) e.r,e[2]=rnd(20),64 end -- player movement and drawing p_=btn(4)and 0.5or 1.2 px+=(tonum(btn(1))-tonum(btn(0)))*p_ py+=(tonum(btn(3))-tonum(btn(2)))*p_ px=mid(px,120) py=mid(py,120) ?(pi%20<=10and"⁶:081c362a7f7f3614"or""),px,py,11 -- player fires if pc<=0 and btn(4)then pc+=10 add(pb,{"⁶:1c3e3e1c1c080800",px,py,3,0,-3.5,0,0}) ?"\as3i7gc",0,0 end -- update bullets, and enemy ships for t in all{pb,en,bul} do for o in all(t) do o[2]+=o[5] o[3]+=o[6] o[5]+=o[7] o[6]+=o[8] if(not col(o,0,0,128,128))del(t,o) if o.r then o.r-=1 if o.r<0then b=split(bty[o[9]]) o.r=b[7] nb(o[2],o[3],unpack(b)) end end ?unpack(o) -- draws ship or bullet -- check player collision with enemy ships or bullets if pget(px+3,py+2) ~= 0 and pi==0 and t ~= pb then ph-=1 pi=90 if(t==bul)del(t,o) ?ph==0 and "\a<i6g1g2g1g2g1g2g1" or "\a<i6g1",0,0 end if t==en then -- check collision with each bullet for b in all(pb) do if col(o,b[2],b[3],5,5)then del(pb,b) o[10]-=1 ?o[10]==0 and "\a<i6g1g2g1g2g1g2g1" or "\a<i6g1",0,0 if o[10]==0 then del(t,o) sc += (o[11]>>16)*50 end end end end end if t == pb then pset(px+3,py+2,0) end end for i = 1,ph do ?"♥",i*6,118,8 end -- high scores ?tostr(sc,2),6,1 ?tostr($0x5e00,2) poke4(0x5e00, max($0x5e00, sc)) -- cooldowns pi = max(pi-1) pc = max(pc-1) else ?"game over\n"..tostr(sc,2),50,50 if(btnp(5))_init() end end function col(o,x,y,w,h) x-=o[2]y-=o[3] return x<8and x+w>0and y<5and y+h>0 end -- bullet generation function function nb(x,y,ch,pt,as,ad,sp,c) a=atan2(px-x,py-y)*pt+as/360 for _=1,c do add(bul,{ch,x,y,8,cos(a)*sp,sin(a)*sp,0,0}) a+=ad/360 end end |
[Please log in to post a comment]