ÐÝÝ ÐÎÌÌì2#á2#áÎÌÌì ÐÐÝÝ >          @`````````` ` ` ` ` ` ` `` ` ````````` `` ` ` ` ` ` ` ` ` ` ` ` ` ````````````` `` `` `` ` ` ``` `` `` `` ` ` ` ` ` ` ` ` ` `````` ```````` `¨?````PPPPPP```P   Q"P P` P fP "P`P P ` PP` `PP  `"`@DD`f@@00@`0`0 3`f3 @Df 0``3UÐÝÝ @ Ð@3DÎÌÌì2#áP2#á0ÎÌÌì Ð@ÐÝÝ @3PUP D0 0UP0 @PP00P"PP@ @ @PU0"PUP @"D 03   @ @D000@D@ -- title: A bullet hell game -- author: Sava -- desc: A bullet hell made in a day. Has exactly 150 lines of spaghetti code -- license: MIT License -- version: 0.1 -- script: lua w=240 h=136 bult = {} pat = { {length=10000, func=function() if t%5 == 0 then bult[#bult+1]={x=0, y=math.random(0, h), spdx=2, spdy=0, rad=2, col=5} end end}, {length=10000, func=function() if t%5 == 0 then bult[#bult+1]={x=-5, y=t%h, spdx=1, spdy=0, rad=3, col=2} end end}, {length=10000, func=function() if t%5 == 0 then bult[#bult+1]={x=0, y=t%h, spdx=1, spdy=0, rad=1, col=4} bult[#bult+1]={x=w-t*w/h%w, y=0, spdx=0, spdy=1, rad=1, col=4} end end}, {length=10000, func=function() if t%2==0 then local py = math.abs((t/60/2)%1-0.5) py = py+0.5 py = py*h bult[#bult+1]={x=0, y=py, spdx=1, spdy=0, rad=1, col=6} bult[#bult+1]={x=w, y=h-py, spdx=-1, spdy=0, rad=1, col=2} end end}, {length=10000, func=function() if t%2==0 then local py = math.sin(t/60) py = py/2+0.5 py = py*h bult[#bult+1]={x=0, y=py, spdx=1, spdy=0, rad=1, col=6} bult[#bult+1]={x=w, y=h-py, spdx=-1, spdy=0, rad=1, col=2} end end}, {length=10000, func=function() if t%5==0 then local px = math.sin(t/60) px = px/2+0.5 px = px*w/5 for i=-1, 10 do bult[#bult+1]={x=px+i*w/10, y=0, spdx=0, spdy=1, rad=1, col=3} end end end}, {length=30000, func=function() local t1 = (time()-lastC)/5000000 local posx, posy = rotate2d(120, 0, t*(math.pi/3-t1)) bult[#bult+1]={x=posx+w/2, y=posy+h/2, spdx=-posx/100, spdy=-posy/100, rad=0, col=1+t%6} end} } curPat=1 lastC=0 start=0 t=0 x=w/2-4 y=h/2-4 done=false lost=false function BOOT() if start == 0 then music(0, -1, -1, true, true) end done=false lost=false curPat=1 lastC=time() start=time() t=0 bult={} end function TIC() if btn(0) then y=y-1 end if btn(1) then y=y+1 end if btn(2) then x=x-1 end if btn(3) then x=x+1 end if keyp(50) then BOOT() end x=(x+w)%w y=(y+h)%h if done then cls(0) if not lost then print("You won!", w/2-20, h/2-3, 12) else print(" You lost!\nRestart with enter", w/2-45, h/2-3, 2) end spr(0, x, y, 0) else update() cls(0) spr(0, x, y, 0) draw() t=t+1 end end function update() if time()-lastC>pat[curPat].length then curPat=curPat+1 lastC=time() bult = {} if curPat > #pat then done=true return end end pat[curPat].func() for i=#bult, 1, -1 do bult[i].x, bult[i].y = bult[i].x+bult[i].spdx, bult[i].y+bult[i].spdy if bult[i].x > x-bult[i].rad and bult[i].x < x+8+bult[i].rad and bult[i].y > y-bult[i].rad and bult[i].y < y+8+bult[i].rad then done=true lost=true return end if bult[i].x > w*2 or bult[i].x < -w or bult[i].y > h*2 or bult[i].y < -h then table.remove(bult, i) end end end function draw() for i,j in ipairs(bult) do if j.rad == 0 then line(j.x, j.y, j.x+(j.spdx*0.8), j.y+(j.spdy*0.8), j.col) else circ(j.x, j.y, j.rad, j.col) end end end function rotate2d(x, y, a) return x*math.cos(a)-y*math.sin(a), x*math.sin(a)+y*math.cos(a) end