¸?À ÌÌ À ÌÌÌ ÌÌÌÌ Ì À ÌÌÀÌÌÀ À ÌÌÌÀÌÌÀÌÀ ÀÌÀ À ÀÌÀÌ À ÌÌ À ÀÌ ÌÌÌÌÌÀÌÌÀÌ ÀÌ Ì ÌÌÌÌ ÌÌ ÀÌÌÌÌÌÀ ÌÌÀÌÀÌÌÌÀÌÌ ÀÌ ÀÌÌÌÀÌÀ ÌÀ À ÌÌÌ ÌÀ Ì ÌÀÌÌÀ ÀÀ ÌÌÀÌÀÌÌÌÌ ÌÌ ÀÀ ÀÀ ÀÌÀÌ Ì Ì Ì ÌÌ Ì ÌÀ ÌÌÌÌ Ì Ì Ì Ì ÌÀ Ì À ÌÀ Ì Ì À ÌÌÌ Ì ÀÌÌÀÌÀÌÌÀÌ À À ÀÀ ÀÌÀÌ Ì ÌÌÌÌÌ À Ì ÌÌÌÌ ÌÌ Ì Ì Ì ÌÌ À Ì Ì ÌÀ ÀÌÌÌÀ ÀÌÀÌ ÀÌ ÀÌÌÌÀÌ ÀÌ ÌÌÌ Ì À ÌÌÀÌÌÌÌ ÀÌÌ ÌÌÀ Ì ÌÀÀÌÌÀÌÌÌÀÌ ÀÌÌÀÌÀ ÀÌÀÌ Ì À À ÀÌ À ÌÌÀÌ À ÀÀ ÀÀÀÀ À À À ÀÀÀÌ ÀÀÀÀ ÌÀÀ ÌÀ ÀÀ ÀÀÀÌ ÀÌ ÌÀÀÀÀÌ ÀÀ ÀÀ ÌÌÀÌÀÌ ÌÀÀ ÀÌÌÀ ÌÌ ÀÀÀ À ÀÀ ÀÀ ÀÀÀ Ì À À ÀÀÀ ÀÀÌÌ À ÀÀÀ Ì ÀÀ ÀÀÀ ÌÀÀ ÀÀÌÌÀ À ÌÀÀÀÌÌÀÌÀ Ì ÀÌ ÀÌ Ì À À Ì ÀÌÌÌ À ÀÀÀÀÌ À ÌÌÀ À ÀÀ À ÀÀ ÀÀÀ À À ÀÀ ÌÀ À ÌÀ ÀÌÀÌÌÌÀÀ Ì ÀÀÀÌ ÀÀ À ÀÀ ÀÌÌÀ ÀÀÀ À ÀÀ ÌÀ ÌÌÀÌÌÌÌÌÌÌÌÀÀ ÀÀ ÌÀÌÀÌÀÀÀÀÌÌÌÌÌ ÀÀÀÌÌÀÌ ÀÀÌÀ ÌÀ ÀÌÀÌÀ Ì Ì À ÀÌÌÌÌÌÌ Ì À À ÀÌÀÌ À ÀÀ À À À À À ÀÀ À ÀÀÀÀÌÌÌ ÀÀÌÌ ÀÌÀ @ÀÌÌÀ ÀD ÀÀÀ @À @ÀÌÌÀÌ@ÀÌÌÀ@@ @@ @@ÀÀÀÌ @À Ì  Ì ÌÀ À Ì ÀÀÌÀÀÀÌ ÌÌÌ À À ÌÌÌ Ì ÀÀ À ÀÀ ÀÌÌÀÀ ÌÌÌÌ À ÌÀÀÌ ÀÀ Ì ÌÌ ÀÀ Ì À ÀÀ ÀÀ ÀÌÌÀÀ ÀÀ Ì À ÀÀÀÌ ÀÌÀÌÀÌ Ì ÀÌ ÌÀÀ ÌÀ ÌÌÀÌ À ÀÀ À Ì À Ì ÀÀÀÌ À Ì ÌÀ ÀÌÌÌ À ÌÌÀ À À ÌÀÌÀ ÀÀ ÀÀ ÀÀ ÀÌÌÀ ÀÀÀ ÀÀÌÀÌ Ì À ÀÀÀÌ ÀÀ À À À IÈ-- title: AsteroidsTV -- author: RodrigoDornelles -- desc: made with gly engine 0.0.21 -- script: lua local tic80game = function() local function H(H,m)return{["\112\116-\066\082"]={["\108\105\102\101\115\058"]="\118\105\100\097\115\058";Continue="\067\111\110\116\105\110\117\097\114",["\078\101\119 \071\097\109\101"]="\078\111\118\111 \074\111\103\111",Dificulty="\068\105\102\105\099\117\108\100\097\100\101",Invincibility="\073\109\111\114\116\097\098\105\108\105\100\097\100\101",["\079\098\106\101\099\116 \076\105\109\105\116"]="\076\105\109\105\116\097\100\111\114";Graphics="\071\114\097\102\105\099\111\115";fast="\114\097\112\105\100\111",pretty="\098\111\110\105\116\111",Language="\073\100\105\111\109\097",Credits="\067\114\101\100\105\116\111\115",Exit="\083\097\105\114"}}end local function m(H,m,L,R)R=R or 0 H.text.font_size(H.math.max(m.height/24,m.width/36,4))H.draw.color(H.color.white)local M=H.text.mensure("\065\115\116\101\114\111\105\100\115\084\118")local n=H.text.mensure("\084\118")H.text.print(m.width/2-M/2,L+R,"\065\115\116\101\114\111\105\100\115")H.draw.color(H.color.red)H.text.print((m.width/2+M/2)-n,L-R,"\084\118")return M end local function L(H,m,L,R,M,n,r)local S=(R-m)/(L-H)local V=m-S*H local c=1+S^2 local G=2*((S*V-S*n)-M)local f=(((M^2+n^2)+V^2)-(2*V)*n)-r^2 local I=G^2-(4*c)*f return I>=0 end local function R(H,m,L)if m==H.asteroid_small_mini then return 0,-1,50 end if m==H.asteroid_small_size and L<=3 then return 0,-1,15 end if m==H.asteroid_mid_size and L<=3 then return 2,H.asteroid_small_size,10 end if m==H.asteroid_large_size and L<=3 then return 1,H.asteroid_mid_size,5 end if m==H.asteroid_small_size and L<=6 then return 1,H.asteroid_mini_size,20 end if m==H.asteroid_mid_size and L<=6 then return 2,H.asteroid_small_size,15 end if m==H.asteroid_large_size and L<=6 then return 1,H.asteroid_mid_size,10 end if m==H.asteroid_small_size and L<=9 then return 1,H.asteroid_mini_size,25 end if m==H.asteroid_mid_size and L<=9 then return 3,H.asteroid_small_size,20 end if m==H.asteroid_large_size and L<=9 then return 1,H.asteroid_mid_size,15 end if m==H.asteroid_small_size then return 1,H.asteroid_mini_size,40 end if m==H.asteroid_mid_size then return 3,H.asteroid_small_size,30 end if m==H.asteroid_large_size then return 2,H.asteroid_mid_size,20 end return 0,-1,0 end local function M(H,m,L,R,M)local n=1 while n<#m.asteroid_size do if n~=M and m.asteroid_size[n]~=-1 then local M=m.asteroid_size[n]/2 local r=H.math.dis(L,R,m.asteroid_pos_x[n]+M,m.asteroid_pos_y[n]+M)if r<=M then return true end end n=n+1 end return false end local function n(H,m)if m.width<=400 then local L=function(L)return H.math.ceil(L*(m.width/800))end m.asteroid_large=H.array.map(m.asteroid_large,L)m.asteroid_mid=H.array.map(m.asteroid_mid,L)m.asteroid_small=H.array.map(m.asteroid_small,L)m.asteroid_mini=H.array.map(m.asteroid_mini,L)end end local function r(H,m)local L=1 local R=1 local n=.5*H.math.min(m.level/3,1)local r=1.0*H.math.min(m.level/3,1)local S=2.0*H.math.min(m.level/3,1)local V=2.5*H.math.min(m.level/3,1)local c={-n;0,0;0,0;0;n}local G={-V,-S;-r;r;S,V}local f=m.width/4 local I=(m.width/4)*3 while L<=m.asteroids_max and L<=10 do repeat local n=true R=R+1 m.asteroid_size[L]=m.asteroid_large_size m.asteroid_pos_x[L]=H.math.random(1,m.width)m.asteroid_pos_y[L]=H.math.random(1,m.height)m.asteroid_spd_x[L]=c[H.math.random(1,#c)]m.asteroid_spd_y[L]=G[H.math.random(1,#G)]if m.asteroid_pos_x[L]>f and m.asteroid_pos_x[L]100 then n=true end until n L=L+1 end end local function S(H,m,L)local M=1 local n={-1;1}local r={-2,-1;1,2}local S=#m.asteroid_size local V=m.asteroid_size[L]local c,G,f=R(m,V,m.level)m.asteroid_size[L]=-1 while M<=c and m.asteroids_count+M<=m.asteroids_max+1 do m.asteroid_size[S+M]=G m.asteroid_pos_x[S+M]=m.asteroid_pos_x[L]m.asteroid_pos_y[S+M]=m.asteroid_pos_y[L]m.asteroid_spd_x[S+M]=n[H.math.random(1,#n)]*H.math.min(m.level/5,1)m.asteroid_spd_y[S+M]=r[H.math.random(1,#r)]*H.math.min(m.level/5,1)M=M+1 end return f end local function V(H,m)m.boost=.12 m.speed_max=5 m.asteroids_count=0 m.state=m.state or 1 m.lifes=m.lifes or 3 m.level=m.level or 1 m.score=m.score or 0 m.imortal=m.imortal or 0 m.highscore=m.highscore or 0 m.asteroids_max=m.asteroids_max or 60 m.graphics_fastest=m.graphics_fastest or 0 m.player_size=H.math.clamp(m.width/100,1,3)m.player_pos_x=m.width/2 m.player_pos_y=m.height/2 m.player_spd_x=0 m.player_spd_y=0 m.player_angle=0 m.player_last_teleport=0 m.laser_enabled=false m.laser_pos_x1=0 m.laser_pos_y1=0 m.laser_pos_x2=0 m.laser_pos_y2=0 m.laser_last_fire=0 m.laser_time_fire=50 m.laser_time_recharge=300 m.laser_distance_fire=300 m.asteroid_pos_x={}m.asteroid_pos_y={}m.asteroid_spd_x={}m.asteroid_spd_y={}m.asteroid_size={}m.asteroid_large={27,0,27,15;15;12,0;30;18,39,9;48;15;60,30;66;48;66;57,57,60,51;66;42,66;33,54;12}m.asteroid_mid={6;0,0;21,9;33;9;48;24,51;36,45;48;42,36;12;48;3;18,0}m.asteroid_small={3;0,0;3,3;9,3,12,0,18;6;21;12;21,18;18,21,15,21;3;12;3,9,6}m.asteroid_mini={6,0,6,6,0;6;0;12,3,18;6;18,6;15,15,15;18;9,12;6,12;0}m.spaceship={-2;3,0;-2;2;3}n(H,m)m.asteroid_large_size=H.math.max(m.asteroid_large)m.asteroid_mid_size=H.math.max(m.asteroid_mid)m.asteroid_small_size=H.math.max(m.asteroid_small)m.asteroid_mini_size=H.math.max(m.asteroid_mini)m.menu=2 m.menu_time=0 r(H,m)end local function c(H,m)if m.state==1 then local L=H.key.axis.x+H.key.axis.a if H.key.axis.y~=0 and H.milis>m.menu_time+250 then m.menu=H.math.clamp(m.menu+H.key.axis.y,m.player_pos_x==m.width/2 and 2 or 1,9)m.menu_time=H.milis end if L~=0 and H.milis>m.menu_time+100 then m.menu_time=H.milis if m.menu==1 then m.state=4 elseif m.menu==2 then H.app.reset()m.state=4 m.score=0 elseif m.menu==3 then m.level=H.math.clamp2(m.level+L,1,99)elseif m.menu==4 then m.imortal=H.math.clamp(m.imortal+L,0,1)elseif m.menu==5 then m.asteroids_max=H.math.clamp2(m.asteroids_max+L,5,60)elseif m.menu==6 then m.graphics_fastest=H.math.clamp(m.graphics_fastest+L,0,1)m.fps_max=100 elseif m.menu==7 then H.i18n.next()elseif m.menu==8 then m.state=2 elseif m.menu==9 then H.app.exit()end end return elseif m.state==2 and(H.key.press.d or H.key.press.menu)then m.menu_time=H.milis m.state=1 return end if H.key.press.d or H.key.press.menu then m.state=1 end m.player_angle=(m.player_angle+H.key.axis.x*.1)%(H.math.pi*2)m.player_pos_x=m.player_pos_x+(m.player_spd_x/16)*H.delta m.player_pos_y=m.player_pos_y+(m.player_spd_y/16)*H.delta if not(H.key.press.up or H.key.press.b)and H.math.abs(m.player_spd_x)+H.math.abs(m.player_spd_y)<.45 then m.player_spd_x=0 m.player_spd_y=0 end if H.key.press.up or H.key.press.b then m.player_spd_x=m.player_spd_x+m.boost*H.math.cos(m.player_angle-H.math.pi/2)m.player_spd_y=m.player_spd_y+m.boost*H.math.sin(m.player_angle-H.math.pi/2)local L=H.math.abs(m.speed_max*H.math.cos(m.player_angle-H.math.pi/2))local R=H.math.abs(m.speed_max*H.math.sin(m.player_angle-H.math.pi/2))m.player_spd_x=H.math.clamp(m.player_spd_x,-L,L)m.player_spd_y=H.math.clamp(m.player_spd_y,-R,R)end if m.player_pos_y<3 then m.player_pos_y=m.height end if m.player_pos_x<3 then m.player_pos_x=m.width end if m.player_pos_y>m.height then m.player_pos_y=3 end if m.player_pos_x>m.width then m.player_pos_x=3 end if(H.key.press.down or H.key.press.c)and H.milis>m.player_last_teleport+1000 then m.player_last_teleport=H.milis m.laser_pos_x1=m.player_pos_x m.laser_pos_y1=m.player_pos_y m.player_spd_x=0 m.player_spd_y=0 repeat m.player_pos_x=H.math.random(1,m.width)m.player_pos_y=H.math.random(1,m.height)until not M(H,m,m.player_pos_x,m.player_pos_y,-1)end if not m.laser_enabled and(m.state==4 and H.key.press.a)then local R=1 local M=#m.asteroid_size local n=H.math.cos(m.player_angle-H.math.pi/2)local r=H.math.sin(m.player_angle-H.math.pi/2)local V=m.player_pos_x-m.laser_distance_fire*n local c=m.player_pos_y-m.laser_distance_fire*r m.laser_pos_x2=m.player_pos_x+m.laser_distance_fire*n m.laser_pos_y2=m.player_pos_y+m.laser_distance_fire*r m.laser_pos_x1=m.player_pos_x+12*n m.laser_pos_y1=m.player_pos_y+12*r m.laser_last_fire=H.milis m.laser_enabled=true while R<=M do if m.asteroid_size[R]~=-1 then local M=m.asteroid_size[R]/2 local n=m.asteroid_pos_x[R]+M local r=m.asteroid_pos_y[R]+M local G=H.math.dis(m.laser_pos_x1,m.laser_pos_y1,n,r)local f=H.math.dis(m.laser_pos_x2,m.laser_pos_y2,n,r)local I=H.math.dis(V,c,n,r)local D=L(m.laser_pos_x1,m.laser_pos_y1,m.laser_pos_x2,m.laser_pos_y2,n,r,M*2)if D and(fm.laser_last_fire+m.laser_time_recharge then m.laser_enabled=false end if m.imortal~=1 and(m.state==4 and M(H,m,m.player_pos_x,m.player_pos_y,-1))then m.menu_time=H.milis m.lifes=m.lifes-1 m.state=5 end local R=1 m.asteroids_count=0 while R<=#m.asteroid_size do if m.asteroid_size[R]~=-1 then m.asteroids_count=m.asteroids_count+1 m.asteroid_pos_x[R]=m.asteroid_pos_x[R]+m.asteroid_spd_x[R]m.asteroid_pos_y[R]=m.asteroid_pos_y[R]+m.asteroid_spd_y[R]if m.asteroid_pos_y[R]<1 then m.asteroid_pos_y[R]=m.height end if m.asteroid_pos_x[R]<1 then m.asteroid_pos_x[R]=m.width end if m.asteroid_pos_y[R]>m.height then m.asteroid_pos_y[R]=1 end if m.asteroid_pos_x[R]>m.width then m.asteroid_pos_x[R]=1 end end R=R+1 end if m.state==4 and m.asteroids_count==0 then m.menu_time=H.milis m.state=6 end if m.state==6 and H.milis>m.menu_time+3000 then H.app.reset()m.level=m.level+1 m.state=4 end if m.state==5 and H.milis>m.menu_time+3000 then H.app.reset()m.state=4 if m.lifes==0 then m.score=0 m.lifes=3 m.level=1 end end end local function G(H,L)local R=L.state==5 and H.milis0 then N.lib_optional[k]=true else N.lib_required[k]=true end end until not j return N end local N={loadgame=c;require=g}return N end R=function()local function j(j,k,Q,R)j=j or{}j[R]={encode=Q.encode;decode=Q.decode}return{[R]=j[R]}end local k={install=j}return k end c=function()local j=Y()local function k(j,k)if j.node then j.bus.emit("\101\120\105\116")j.bus.emit("\105\110\105\116")else k.root.callbacks.exit(j,k.root.data)k.root.callbacks.init(j,k.root.data)end end local function Q(j)j.bus.emit("\101\120\105\116")j.bus.emit("\113\117\105\116")end local function R(j,k)if j then j(k)end end local function c(c,x,g)c=c or{}g=g or{}c.app=c.app or{}c.bus.listen("\112\111\115\116\095\113\117\105\116",function()if g.quit then g.quit()end end)c.app.title=j.prefix1(g.set_title,R)c.app.exit=j.prefix1(c,Q)c.app.reset=j.prefix2(c,x,k)c.app.get_fps=g.get_fps return c.app end local x={install=c}return x end x=function()local function j(j)local k=1 local Q=5381 while k<=#j do local R=string.byte(j,k)Q=Q*33+R k=k+1 end Q=string.format("\037\048\056\120",Q)Q=tonumber(Q:sub(#Q-7),16)return Q end local function k(k,Q,R)local c=j(R.get_secret())k=k or{}k.hash=k.hash or{}k.hash.djb2=j k.hash.fingerprint=function()return c end end local Q={install=k}return Q end g=function()local j=b()local function k(j)j.options.json=true return j end local function Q(j)j.options.noforce=true return j end local function R(j)j.speed="\095\102\097\115\116"return j end local function c(j,k,Q)local R=#j.param_list+1 j.param_list[R]=tostring(k)j.param_dict[k]=tostring(Q)return j end local function x(j,k,Q)local R=#j.header_list+1 j.header_list[R]=tostring(k)j.header_dict[k]=tostring(Q)return j end local function g(j,k,Q)if type(k)=="\116\097\098\108\101"then x(j,"\067\111\110\116\101\110\116-\084\121\112\101","\097\112\112\108\105\099\097\116\105\111\110\047\106\115\111\110")k=Q(k)end j.body_content=k return j end local function N(j,k)j.success_handler=k return j end local function T(j,k)j.failed_handler=k return j end local function p(j,k)j.error_handler=k return j end local function e(e,M,G,I)local l=function()if M.node then M.node.emit(G.current,"\104\116\116\112")elseif G.current.callbacks.http then G.current.callbacks.http(M,G.current.data)end end return function(K)if I.has_callback then G.http_count=G.http_count+1 end local o=M.json and M.json.encode local m=M.json and M.json.decode local U=function(j,k)return g(j,k,o)end local H=G.current.data local d={id=G.http_count,url=K,speed="";options={};method=e,body_content="",header_list={},header_dict={};param_list={};param_dict={},success_handler=function(j,k) end,failed_handler=function(j,k) end,error_handler=function(j,k) end;fast=R;json=k;noforce=Q;body=U,param=c;header=x;success=N,failed=T,error=p;run=j.run}d.promise=function()j.stop(d)end d.resolve=function()j.resume(d)end d.set=function(j,k)M.http[j]=k end d.pipeline={function()if not I.force or d.options.noforce then return end d.url=K:gsub("\094\091\094\058\093\043\058\047\047",I.force.."\058\047\047")end;function()if I.has_callback then G.http_requests[d.id]=d end I.handler(d,d.id)end;function()if d.options.json and(m and M.http.body)then pcall(function()local j=m(M.http.body)M.http.body=j end)end end,function()l(M,H)if M.http.ok then d.success_handler(M,H)elseif M.http.error then d.error_handler(M,H)elseif not M.http.status then d.set("\101\114\114\111\114","\109\105\115\115\105\110\103 \112\114\111\116\111\099\111\108 \114\101\115\112\111\110\115\101")d.error_handler(M,H)else d.failed_handler(M,H)end end,function()M.http.ok=nil M.http.body=nil M.http.error=nil M.http.status=nil M.http.body_is_table=nil end,function()if I.has_callback then G.http_requests[d.id]=nil end j.reset(d)end}return d end end local function M(j,k,Q)assert(Q and Q.handler,"\109\105\115\115\105\110\103 \112\114\111\116\111\099\111\108 \104\097\110\100\108\101\114")if Q.has_callback then k.http_count=0 k.http_requests={}end j.http=j.http or{}j.http.get=e("\071\069\084",j,k,Q)j.http.head=e("\072\069\065\068",j,k,Q)j.http.post=e("\080\079\083\084",j,k,Q)j.http.put=e("\080\085\084",j,k,Q)j.http.delete=e("\068\069\076\069\084\069",j,k,Q)j.http.patch=e("\080\065\084\067\072",j,k,Q)if Q.install then Q.install(j,k)end end local G={install=M}return G end N=function()local j="\101\110-\085\083"local k="\101\110-\085\083"local Q={}local R={}local c={}local function x(j)local x=1 c=j Q={k}R={[k]=1}repeat local k=next(j)if k then x=x+1 R[k]=x Q[#Q+1]=k end until k end local function g(k)local Q=c[j]and c[j][k]return Q or k end local function N()return j end local function T(Q)if R[Q]then j=Q else j=k end end local function p(k)local c=R[j]local x=k or 1 if c then c=c+x if c>#Q then c=1 end if c<=0 then c=#Q end c=c==0 and 1 or c T(Q[c])end end local function e()p(-1)end local function M(j)return function(k,Q,R,c,x,N)return j(k,Q,g(R),c,x,N)end end local function G(j,k,Q)if not(j and(j.text and j.text.print))then error("\109\105\115\115\105\110\103 \100\114\097\119 \116\101\120\116")end local R=j.text.put local c=j.text.print local G=j.text.print_ex local I=function(j)x(j)if Q and Q.get_language then T(Q.get_language())end end if not j.node and k.root.callbacks.i18n then I(k.root.callbacks.i18n())else j.bus.listen("\114\101\116\095\105\049\056\110",I)j.bus.emit_next("\105\049\056\110")end j.text.put=M(R)j.text.print=M(c)j.text.print_ex=M(G)j.i18n={}j.i18n.get_text=g j.i18n.get_language=N j.i18n.set_language=T j.i18n.back=e j.i18n.next=p end local I={install=G}return I end T=function()local function j(j,k,Q,R)local c=R==1 or R==true local x=k.key_bindings[Q]or j.key.axis[Q]and Q if x then j.key.axis[x]=c and 1 or 0 j.key.press[x]=c if x=="\114\105\103\104\116"or x=="\108\101\102\116"then j.key.axis.x=j.key.axis.right-j.key.axis.left end if x=="\100\111\119\110"or x=="\117\112"then j.key.axis.y=j.key.axis.down-j.key.axis.up end j.bus.emit("\107\101\121")end local g=j.key.axis j.key.press.any=(((((((g.left+g.right)+g.down)+g.up)+g.a)+g.b)+g.c)+g.d)+g.menu>0 end local function k(k,Q,R)j(k,Q,R,1)end local function Q(k,Q,R)j(k,Q,R,0)end local function R(R,c)R.bus.listen_std_engine("\114\107\101\121",j)R.bus.listen_std_engine("\114\107\101\121\049",k)R.bus.listen_std_engine("\114\107\101\121\048",Q)end local function c(k,Q,R)Q.key_bindings=R or{}Q.keyboard=j end local x={event_bus=R;install=c}return x end p=function()local j=Y()local k={"\110\111\110\101";"\102\097\116\097\108";"\101\114\114\111\114";"\119\097\114\110","\100\101\098\117\103","\105\110\102\111"}local function Q(j,Q,R,c)local x=Q[c]or R[c]or c if type(x)~="\110\117\109\098\101\114"or x<=0 or x>#k then error("\108\111\103\103\105\110\103 \108\101\118\101\108 \110\111\116 \101\120\105\115\116\058 "..tostring(c))end j.loglevel=x end local function R(R,c,x)local g=1 local N={}local T={}while g<=#k do local j=k[g]local Q=function() end if g>1 and x[j]then Q=(function(k)return function(Q)if c.loglevel>=k then x[j](Q)end end end)(g-1)end N[Q]=g-1 T[j]=g-1 R.log[j]=Q g=g+1 end R.log.level=j.prefix3(c,N,T,Q)end local function c(Q,c,x)Q.log=Q.log or{}c.loglevel=#k Q.log.init=j.prefix2(Q,c,R)Q.log.init(x)end local x={install=c}return x end e=function()local function k(j)if j<0 then return-j end return j end local function Q(j,k,Q)if jQ then return Q else return j end end local function R(j,k,Q)return(j-k)%((Q-k)+1)+k end local function c(j,k)k=k or 0 if j<-k then return-1 elseif j>k then return 1 else return 0 end end local function x(j,k,Q,R)local c=.5 return((Q-j)^2+(R-k)^2)^(c~=0 and c or 1)end local function g(j,k,Q,R)return(Q-j)^2+(R-k)^2 end local function N(j,Q,R,c)return k(j-R)+k(R-c)end local function T(j,k,Q)return j+Q*(k-j)end local function p(j,k,Q,R,c)return((j-k)*(c-R))/(Q-k)+R end local function e(...)local j={...}local k=1 local Q=nil local R=nil if#j==1 then j=j[1]end while k<=#j do Q=j[k]if R==nil or Q>R then R=Q end k=k+1 end return R end local function M(...)local j={...}local k=1 local Q=nil local R=nil if#j==1 then j=j[1]end while k<=#j do Q=j[k]if R==nil or QQ and 1 or-1 end local function m(j,k)return o(j,k,.5)end local function U(j)j.math=j.math or{}j.math.abs=k j.math.clamp=Q j.math.clamp2=R j.math.dir=c j.math.dis=x j.math.dis2=g j.math.dis3=N j.math.lerp=T j.math.map=p j.math.max=e j.math.min=M end local function H(j)j.math=j.math or{}j.math.sine=G j.math.saw=l j.math.square=m j.math.triangle=K end local function d(k)k.math=k.math or{}k.math.acos=j.acos k.math.asin=j.asin k.math.atan=j.atan k.math.atan2=j.atan2 k.math.ceil=j.ceil k.math.cos=j.cos k.math.cosh=j.cosh k.math.deg=j.deg k.math.exp=j.exp k.math.floor=j.floor k.math.fmod=j.fmod k.math.frexp=j.frexp k.math.huge=j.huge k.math.ldexp=j.ldexp k.math.log=j.log k.math.log10=j.log10 k.math.modf=j.modf k.math.pi=j.pi k.math.pow=j.pow k.math.rad=j.rad k.math.sin=j.sin k.math.sinh=j.sinh k.math.sqrt=j.sqrt k.math.tan=j.tan k.math.tanh=j.tanh end local function b(k)k.math=k.math or{}k.math.random=function(k,Q)k=k and j.floor(k)Q=Q and j.floor(Q)return j.random(k,Q)end end local Y={install=U;wave={install=H};clib={install=d};clib_random={install=b}}return Y end M=function()local j=Y()local function k(j,k)local Q={}local R=1 local c=#j while R<=c do Q[#Q+1]=k(j[R],R)R=R+1 end return Q end local function Q(j,k)k=k or function(j)return j and j~=0 end local Q={}local R=1 local c=#j while R<=c do local c=j[R]if k(c,R)then Q[#Q+1]=c end R=R+1 end return Q end local function R(j)local k={}local Q=1 local R=#j local c={}while Q<=R do local R=j[Q]if not c[R]then k[#k+1]=R end c[R]=true Q=Q+1 end return k end local function c(j,k)local Q=1 local R=#j while Q<=R do k(j[Q],Q)Q=Q+1 end end local function x(j,k,Q)local R=Q and 1 or 2 local c=#j Q=Q or j[1]while R<=c do Q=k(Q,j[R],R)R=R+1 end return Q end local function g(j,k,Q)k=k or function()return true end local R,c,x=1,1,#j if Q then R,c,x=#j,-1,1 end repeat if k(j[R],R)then return R end R=R+c until Q and Rx return nil end local function N(j,k)local Q=g(j,k)if Q then return j[Q]end return nil end local function T(j,k)local Q=g(j,k,true)if Q then return j[Q]end return nil end local function p(j,k,Q)local R,c,x=1,1,#j if Q then R,c,x=#j,-1,1 end repeat if k(j[R],R)then return true end R=R+c until Q and Rx return false end local function e(j,k)local Q=1 local R=#j while Q<=R do if not k(j[Q],Q)then return false end Q=Q+1 end return true end local function M(j,M)local G=function(j)return function(k,Q,R)k.array=j(k.array,Q,R)return k end end local I=function(j,k)return function(Q,R,c)local x=j(Q.array,R,c)return k and Q or x end end local l={array=M,map=G(k),filter=G(Q),unique=G(R);each=I(c,true);reducer=I(x);index=I(g),first=I(N),last=I(T),some=I(p);every=I(e),table=function(j)return j.array end;json=function(k)return j.json.encode(k.array)end}return l end local function G(G,I,l,K)local o=G[K]or{}o.map=k o.filter=Q o.unique=R o.each=c o.reducer=x o.index=g o.first=N o.last=T o.some=p o.every=e o.from=j.prefix1(G,M)G[K]=o end local I={install=G}return I end G=function()local function j(j,k,Q)local R=function(j)j=j or function() end return function(k,Q,R,c)j(0,Q,R,c)return k end end local c={src=R(Q.source),play=R(Q.play),pause=R(Q.pause),resume=R(Q.resume);stop=R(Q.stop);position=R(Q.position);resize=R(Q.resize);in_mutex=Q.mutex or function()return false end;get_error=Q.error or function()return nil end;node=j;apply=function() end}return function()return c end end local function k(k,Q,R,c)k.media=k.media or{}local x=c:match("\037\119\043\037\046\040\037\119\043\041")if R.install then R.install(k,Q,x,c)end if not k.media[x]then local Q=R.bootstrap and R.bootstrap(x)if(not Q or Q==0)and R.bootstrap then error("\109\101\100\105\097 "..(x.." \105\115 \110\111\116 \115\117\112\112\111\114\116\101\100\033"))end local c=k.node and k.node.load({})k.media[x]=j(c,Q,R)end end local Q={install=k}return Q end I=function()local function k(k,Q,R,c,x)if R<1 then return end local g=Q.current.config.offset_x+c local N=Q.current.config.offset_y+x local T=4 k.draw.color(4294902015)if R>=1 then k.draw.rect(0,g,N,40,24)end if R>=2 then k.draw.rect(0,g+48,N,40,24)end if R>=3 then k.draw.rect(0,g+96,N,40,24)end k.draw.color(255)k.text.font_size(16)if R>=3 then local Q=k.math.floor or j.floor or function()return"\088\088"end local R=Q((1/k.delta)*1000)k.text.print(g+T,N,R)T=T+46 end if R>=1 then k.text.print(g+T,N,Q.fps)T=T+46 end if R>=2 then k.text.print(g+T,N,Q.root.config.fps_max)T=T+46 end end local function Q(j,Q)j.bus.listen("\112\111\115\116\095\100\114\097\119",function()Q.current=Q.root k(j,Q,Q.root.config.fps_show,8,8)end)end local function R(j,k)j.app=j.app or{}j.app.fps_show=function(j)k.root.config.fps_show=j end end local c={event_bus=Q;install=R}return c end l=function()local j=Y()local function k(j,k,Q,R,c,x,g)g=g or 2 local N=k.current.data.width/80 local T=k.current.data.height/24 local p=N*g j.text.font_default(0)j.text.font_size(p)j.text.print(R*N,c*T,x)Q()end local function Q(j,k,Q,R,c,x,g)local N,T=j.text.mensure(c)local p,e={N;N/2;0},{T;T/2;0}j.text.print(Q-p[(x or 1)+2],R-e[(g or 1)+2],c)return N,T end local function R(R,c,x)R.text.print_ex=j.prefix2(R,c,Q)R.text.put=j.prefix3(R,c,x.font_previous,k)end local c={install=R}return c end K=function()local function j(j,k)if not j or not k then return k end return function(Q,R,c,x)return k(j,Q,R,c,x)end end local function k(j)return function(k,Q)local R=4 while R<=#Q do j(Q[R-3],Q[R-2],Q[R-1],Q[R])R=R+2 end end end local function Q(j,k,Q)if not Q then return j end local R=function(j,Q,R,c,x,g,N,T)local p=(j+((N-R)*-x)*k.math.cos(g))-((N-c)*-x)*k.math.sin(g)local e=(Q+((T-R)*-x)*k.math.sin(g))+((T-c)*-x)*k.math.cos(g)return p,e end return function(k,c,x,g,N,T,p,e)if#c~=6 then return j(k,c,x,g,N,T,p,e)end p=p or 0 e=e or p or 0 local M,G=R(x,g,c[1],c[2],N,T,p,e)local I,l=R(x,g,c[3],c[4],N,T,p,e)local K,o=R(x,g,c[5],c[6],N,T,p,e)return Q(k,M,G,I,l,K,o)end end local function R(j,k,Q,R)local c=function(j,k)if R and R[k+1]then j[#j+1]=j[1]j[#j+1]=j[2]end end return function(R,x,g,N,T,p,e,M)if#x<6 or#x%2~=0 then return end local G=Q and Q[R+1]or R local I=k.math.cos and(p and p~=0)e=e or 0 M=M or e or 0 if g and(N and not I)then local k=1 local Q={}T=T or 1 while k<=#x do if k%2~=0 then Q[k]=g+x[k]*T else Q[k]=N+x[k]*T end k=k+1 end c(Q,R)j(G,Q)elseif g and N then local Q=1 local I={}while Q<#x do local j=x[Q]local R=x[Q+1]local c=(g+((e-j)*-T)*k.math.cos(p))-((e-R)*-T)*k.math.sin(p)local G=(N+((M-j)*-T)*k.math.sin(p))+((M-R)*-T)*k.math.cos(p)I[Q]=c I[Q+1]=G Q=Q+2 end c(I,R)j(G,I)else j(G,x)end end end local function c(j,k)return function(Q,R,c,x,g,N,T,p)local e=j.current.config.offset_x+(c or 0)local M=j.current.config.offset_y+(x or 0)T=T or 0 p=T or p or 0 g=g or 1 N=N or 0 return k(Q,R,e,M,g,N,T,p)end end local function x(x,g,N)local T=j(N.object,N.line)local p=j(N.object,N.poly)or k(T)local e=N.poly2 or R(p,x,N.modes,N.repeats)local M=Q(e,x,N.triangle)x.draw.poly=c(g,M)end local g={install=x}return g end o=function()local j={}local k={}local Q={}local function R(j)return k[j]end local function c(R,c,x)local g=c()Q[#Q+1]=R j[R]=x k[R]=g end local function x(j,k,Q)local x=R(j)if x==nil then c(j,k,Q)x=R(j)end return x end local function g(Q)if j[Q]then j[Q](k[Q])end k[Q]=nil end local function N()local j=1 local k=#Q while j<=k do g(Q[j])j=j+1 end Q={}return k end local function T(j)j=j or{}j.mem=j.mem or{}j.mem.cache=x j.mem.cache_get=R j.mem.cache_set=c j.mem.unset=g j.mem.gc_clear_all=N return{mem=j.mem}end local p={install=T}return p end m=function()local j=F()local k={["\097\115\121\110\099-\112\114\111\109\105\115\101"]=function(j)return j:promise()end;["\097\115\121\110\099-\114\101\115\111\108\118\101"]=function(j)return j:resolve()end,["\103\101\116-\117\114\108"]=function(j)return j.url end;["\103\101\116-\102\117\108\108\117\114\108"]=function(k)return k.url..j.url_search_param(k.param_list,k.param_dict)end,["\103\101\116-\109\101\116\104\111\100"]=function(j)return j.method end,["\103\101\116-\098\111\100\121"]=function(j)return j.body_content end,["\103\101\116-\112\097\114\097\109-\099\111\117\110\116"]=function(j)return#j.param_list end;["\103\101\116-\112\097\114\097\109-\110\097\109\101"]=function(j,k)return j.param_list[j.data]end,["\103\101\116-\112\097\114\097\109-\100\097\116\097"]=function(j,k)return j.param_dict[j.data]or j.param_dict[j.param_list[j.data]]end,["\103\101\116-\104\101\097\100\101\114-\099\111\117\110\116"]=function(j)return#j.header_list end;["\103\101\116-\104\101\097\100\101\114-\110\097\109\101"]=function(j,k)return j.header_list[j.data]end,["\103\101\116-\104\101\097\100\101\114-\100\097\116\097"]=function(j,k)return j.heeader_dict[j.data]or j.heeader_dict[j.header_list[j.data]]end;["\115\101\116-\115\116\097\116\117\115"]=function(k,Q)k.set("\115\116\097\116\117\115",Q)k.set("\111\107",j.is_ok(Q))end;["\115\101\116-\101\114\114\111\114"]=function(j,k)j.set("\101\114\114\111\114",k)end,["\115\101\116-\111\107"]=function(j,k)j.set("\111\107",k)end;["\115\101\116-\098\111\100\121"]=function(j,k)j.set("\098\111\100\121",k)end;["\097\100\100-\098\111\100\121-\100\097\116\097"]=function(j,k,Q)j.set("\098\111\100\121",(Q.http.body or"")..k)end}local function Q(j,Q,R,c)if not k[Q]then error("\104\116\116\112 \101\118\116 "..(Q.." \110\111\116 \101\120\105\115\116\033"))end return k[Q](j,R,c)end local R={func=Q}return R end U=function()local j={data={width=1280;height=720};meta={id="";title="",author="",company="",description="";tizen_package="",version=""};config={offset_x=0;offset_y=0,require="";fps_max=60;fps_show=0;fps_drop=5,fps_time=5};callbacks={}}return j end H=function()local function j(j)j.color=j.color or{}j.color.white=4294967295 j.color.lightgray=3368865023 j.color.gray=2189591295 j.color.darkgray=1347440895 j.color.yellow=4260954367 j.color.gold=4291494143 j.color.orange=4288741631 j.color.pink=4285383423 j.color.red=3861460991 j.color.maroon=3189848063 j.color.green=14954751 j.color.lime=10366975 j.color.darkgreen=7679231 j.color.skyblue=1723858943 j.color.blue=7991807 j.color.darkblue=5418239 j.color.purple=3363504127 j.color.violet=2268905215 j.color.darkpurple=1881112319 j.color.beige=3551560703 j.color.brown=2137673727 j.color.darkbrown=1279209471 j.color.black=255 j.color.blank=0 j.color.magenta=4278255615 end local k={install=j}return k end d=function()local j={milis=0;delta=0;math={},draw={image=function() end,clear=function() end,color=function() end;rect=function() end;line=function() end,poly=function() end;tui_text=function() end};text={put=function() end,print=function() end,mensure=function() end,font_size=function() end,font_name=function() end;font_default=function() end},image={load=function() end;draw=function() end};app={width=1280;height=720,title=function() end,reset=function() end;load=function() end;exit=function() end};key={axis={x=0;y=0;menu=0;up=0,down=0,left=0,right=0;a=0,b=0,c=0;d=0},press={menu=false;up=false;down=false,left=false,right=false,a=false,b=false;c=false,d=false;any=false}}}return j end b=function()local function j(j)return function()j:run()end end local function k(j)if j.pipeline and not j.pipeline2 then j.pipeline2=j.pipeline j.pipeline=nil end end local function Q(j)if not j.pipeline and j.pipeline2 then j.pipeline=j.pipeline2 j.pipeline2=nil j:run()end end local function R(j)j.pipeline_current=j.pipeline_current or 1 while j.pipeline and(j.pipeline_current and j.pipeline_current<=#j.pipeline)do j.pipeline[j.pipeline_current]()if j.pipeline_current then j.pipeline_current=j.pipeline_current+1 end end return j end local function c(j)j.pipeline=j.pipeline or j.pipeline2 j.pipeline2=nil j.pipeline_current=nil end local function x(j)j.pipeline_current=nil j.pipeline2=nil j.pipeline=nil end local g={reset=c;clear=x,pipe=j;stop=k;resume=Q;run=R}return g end Y=function()local function j(j,k,Q,R)return function(c,x,g,N,T,p)return R(j,k,Q,c,x,g,N,T,p)end end local function k(j,k,Q)return function(R,c,x,g,N,T)return Q(j,k,R,c,x,g,N,T)end end local function Q(j,k)return function(Q,R,c,x,g,N)return k(j,Q,R,c,x,g,N)end end local function R(j,k)return function(Q,R,c,x,g,N)local T=j.offset_x+(R or 0)local p=j.offset_y+(c or 0)return k(Q,T,p,x,g,N)end end local function c(j,k)return function(Q,R,c,x,g,N)local T=j.offset_x+Q local p=j.offset_y+R local e=j.offset_x+c local M=j.offset_y+x return k(T,p,e,M,g,N)end end local function x(j,k)return function(Q,R,c,x,g,N)local T=j.offset_x+Q local p=j.offset_y+R return k(T,p,c,x,g,N)end end local function g(j,k)local R={}for k,c in pairs(k)do R[k]=Q(j,c)end return R end local N={offset_xy1=x,offset_xy2=R,offset_xyxy1=c;prefix3=j,prefix2=k,prefix1=Q;prefix1_t=g}return N end F=function()local function j(j)return j and(200<=j and j<300)or false end local function k(k)local Q=tonumber(k:match("\072\084\084\080\047\037\100\046\037\100 \040\037\100\037\100\037\100\041"))local R=Q and j(Q)or false return R,Q end local function Q(j)return j and(300<=j and j<400)or false end local function R(j)local k,Q=j:match("\094\040\046-\r\n\r\n\041\040\046\042\041")if not k or not Q then return nil end local R=tonumber(k:match("\067\111\110\116\101\110\116\037-\076\101\110\103\116\104\058\037\115\042\040\037\100\043\041"))if not R then return nil end if#Q=R do local c=j[R]local x=k[c]if Q.header_imutable[c]==nil then Q.header_list[#Q.header_list+1]=c Q.header_imutable[c]=false Q.header_dict[c]=x elseif Q.header_imutable[c]==false then Q.header_dict[c]=x end R=R+1 end return Q end Q.not_status=function()Q.print_http_status=false return Q end Q.to_http_protocol=function()local R=1 local c=j..(" "..(k.." \072\084\084\080\047\049\046\049\r\n"))while R<=#Q.header_list do local j=Q.header_list[R]local k=Q.header_dict[j]c=c..(j..("\058 "..(k.."\r\n")))R=R+1 end c=c.."\r\n"if j~="\071\069\084"and(j~="\072\069\065\068"and#Q.body_content>0)then c=c..(Q.body_content.."\r\n\r\n")end return c,function() end end Q.to_curl_cmd=function()local R=1 local c="\099\117\114\108 -\076 --\115\105\108\101\110\116 --\105\110\115\101\099\117\114\101 "if Q.print_http_status then c=c.."-\119 \"\n\037\123\104\116\116\112\095\099\111\100\101\125\" "end if j=="\072\069\065\068"then c=c.."--\072\069\065\068 "else c=c..("-\088 "..(j.." "))end while R<=#Q.header_list do local j=Q.header_list[R]local k=Q.header_dict[j]c=c..("-\072 \""..(j..("\058 "..(k.."\" "))))R=R+1 end if j~="\071\069\084"and(j~="\072\069\065\068"and#Q.body_content>0)then c=c..("-\100 \'"..(Q.body_content.."\' "))end c=c..k return c,function() end end Q.to_wget_cmd=function()local R="\119\103\101\116 --\113\117\105\101\116 --\111\117\116\112\117\116-\100\111\099\117\109\101\110\116\061-"if j=="\072\069\065\068"then R=R.." --\109\101\116\104\111\100\061\072\069\065\068"elseif j~="\071\069\084"then R=R..(" -"..("-\109\101\116\104\111\100\061"..j))end for j,k in ipairs(Q.header_list)do local c=Q.header_dict[k]if c then local j=c:gsub("\"","\092\"")R=R..(" -"..("-\104\101\097\100\101\114\061\""..(k..("\058 "..(j.."\"")))))end end if j~="\071\069\084"and(j~="\072\069\065\068"and#Q.body_content>0)then local j=Q.body_content:gsub("\"","\092\"")R=R..(" -"..("-\098\111\100\121-\100\097\116\097\061\""..(j.."\"")))end R=R..(" "..k)return R,function() end end return Q end return{is_ok=j;is_ok_header=k,is_redirect=Q,get_content=R,get_user_agent=c,url_search_param=x;create_request=g}end return E() end local started = false local current_color = 12 local font_size, font_previous = 5, 5 local delta, last = 0, time() local keypress = {} local keymap = { 'up', 'down', 'left', 'right', 'a', 'b', 'c', 'd' } local colormap = { [0x000000] = 0, [0x1A1C2C] = 0, [0xFF00FF] = 1, [0xFF6DC2] = 1, [0xC87AFF] = 1, [0x701F7E] = 1, [0x873CBE] = 1, [0x5D275D] = 1, [0xFF0000] = 2, [0xE62937] = 2, [0xBE2137] = 2, [0xB13E53] = 2, [0xFFA100] = 3, [0xFFCB00] = 3, [0xEF7D57] = 3, [0xFDF900] = 4, [0xFFCD75] = 4, [0x00E430] = 5, [0xA7F070] = 5, [0x009E2F] = 6, [0x38B764] = 6, [0x00752C] = 7, [0x38B764] = 7, [0x0052AC] = 8, [0x29366F] = 8, [0x0000FF] = 9, [0x3B5DC9] = 9, [0x0079F1] = 10, [0x41A6F6] = 10, [0x66BFFF] = 11, [0x73EFF7] = 11, [0xFFFFFF] = 12, [0xF4F4F4] = 12, [0xC8CCCC] = 13, [0x94B0C2] = 13, [0xD3B083] = 13, [0x828282] = 14, [0x566C86] = 14, [0x7F6A4F] = 14, [0x505050] = 15, [0x333C57] = 15, [0x4C3F2F] = 15 } local function colorid(c) local colornew = colormap[c>>8] if not colornew then local r,g,b = (c>>24) & 255, (c>>16) & 255, (c>>8) & 255 local best,d = nil, math.huge for k,v in pairs(colormap) do local kr,kg,kb = (k>>16)&255, (k>>8)&255, k&255 local dist = ((r-kr)^2 + (g-kg)^2 + (b-kb)^2) if dist < d then d,best = dist,v end end colornew = best end return colornew end function native_draw_start() end function native_draw_flush() end function native_draw_clear(c) cls(colorid(c)) end function native_draw_color(c) current_color = colorid(c) end function native_draw_line(x1, y1, x2, y2) line(x1, y1, x2, y2, current_color) end function native_draw_rect(mode, x, y, w, h) if mode == 0 then rect(x, y, w, h, current_color) else local x2, y2 = x + w, y + h line(x, y, x2, y, current_color) line(x2 , y, x2, y2, current_color) line(x , y2, x2, y2, current_color) line(x , y, x, y2, current_color) end end function native_text_font_previous() font_size, font_previous = font_previous, font_size end function native_text_font_default() end function native_text_font_name() end function native_text_font_size(n) font_size = math.ceil(n/5) if font_size < 1 then font_size = 1 end end function native_text_mensure(text) local s = font_size * 5 local t = tostring(text) local a = #t > 1 and 1 or 0 return #t * (a + s), s end function native_text_print(x, y, t) print(tostring(t), x, y, current_color, true, font_size) end native_cfg_poly_repeat_0 = true native_cfg_poly_repeat_1 = true tic80engine = tic80engine() tic80game = tic80game() function TIC() if not started then started = true if tic80engine and type(tic80engine) == 'table' and tic80engine.meta and tic80engine.meta.title then trace('engine: '..tic80engine.meta.title..' '..tostring(tic80engine.meta.version)) end if tic80game and type(tic80game) == 'table' and tic80game.meta and tic80game.meta.title then trace('game: '..tic80game.meta.title..' '..tostring(tic80game.meta.version)) end native_callback_init(240, 136, tic80game) else do local now = time() delta = now - last last = now end do local index = 1 while index <= #keymap do local keyname = keymap[index] local pressed = btn(index - 1) if not keypress[index] and pressed then keypress[index] = true native_callback_keyboard(keyname, pressed) elseif keypress[index] and not pressed then keypress[index] = false native_callback_keyboard(keyname, pressed) end index = index + 1 end end native_callback_loop(delta) native_callback_draw() end end