I have a passion to create useless code snippets for me, so I decide to share the most useful for others (or not ;) ).
-- script: moon export width=240 export height=136 export tilesize=8 export fontsize=6 btnAxis=(a,b)-> if btn(a) and btn(b) return 0 elseif btn(a) return -1 elseif btn(b) return 1 else return 0 class Menu new:(x=0,y=0,index=1)=> @x=x @y=y @index=index @items={} add:(text)=> table.insert(@items,text) prev:=> i=@index-1 if i<1 @index=#@items else @index=i next:=> i=@index+1 if i>#@items @index=1 else @index=i draw:(sel="> ",usel=" ",spc=10,col=15)=> for k,v in ipairs(@items) dy=@y+(k-1)*spc if @index==k print(sel..v,@x,dy,col) else print(usel..v,@x,dy,col) class Spr new:(id=0,x=0,y=0,alpha=-1,scale=1,flip=0,rotate=0)=> @id=id @x=x @y=y @alpha=alpha @scale=scale @flip=flip @rotate=rotate draw:=> spr(@id,@x,@y,@alpha,@scale,@flip,@rotate) class RectCollider new:(x=0,y=0,w=1,h=1)=> @x=x @y=y @w=w @h=h draw:(col=8)=> rectb(@x,@y,@w,@h,col) collide:(B)=> if @x>(B.x+B.w) or (@x+@w-1)<B.x or @y>(B.y+B.h) or (@y+@h-1)<B.y return false else return true class CircCollider new:(x=0,y=0,r=1)=> @x=x @y=y @r=r draw:(col=8)=> circb(@x,@y,@r,col) collide:(B)=> d=(@x-B.x)^2+(@y-B.y)^2 r=(@r+B.r)^2 if @x>=(B.x-B.r) and @y>=(B.y-B.r) r=(@r+B.r+1)^2 if d>r return false else return true -------------------- cls! t=Spr(1,104,24,2,4) export TIC=-> --update t.y+=btnAxis(0,1) t.x+=btnAxis(2,3) t.id=time()%1000//500+1 --draw cls(12) t\draw! print("HELLO WORLD!",84,64)