Snusmumriken
local a={}function a.aabb(b,d,e,f,g,h,i,j)return not(g>b+e or g+i<b or h>d+f or h+j<d)end;function a.collide(b,d,e,f,g,h,i,j)if not a.aabb(b,d,e,f,g,h,i,j)then return false,0,0 end;local k=b+e*.5-g-i*.5;local l=d+f*.5-h-j*.5;k=k>0 and g+i-b or g-b-e;l=l>0 and h+j-d or h-d-f;local m=math.abs(k)<math.abs(l)return true,m and k or 0,m and 0 or l end;local n=love;local o=love.graphics;local p=love.keyboard;local q=love.mouse;local r=a.collide;local s={w=16,h=16}function c(t,u)return{x=t*s.w,y=u*s.h,w=s.w,h=s.h}end;local v={}for w=0,32 do v[#v+1]=c(w,0)v[#v+1]=c(0,w)v[#v+1]=c(w,32)v[#v+1]=c(32,w)end;for w=1,3 do v[#v+1]=c(w+20,30)v[#v+1]=c(w+5,30)v[#v+1]=c(w+25,27)v[#v+1]=c(w+10,27)v[#v+1]=c(w+15,25)v[#v+1]=c(w+10,22)end;local x={x=100,y=100,vx=0,vy=0,w=s.w,h=s.h}local y=math.abs;local p=love.keyboard;function n.update(z)local A,B=q.getPosition()local C,D=o.getDimensions()C,D=C/2,D/2;x.x=x.x+x.vx*z;x.y=x.y+x.vy*z;x.vy=x.vy+250*z;x.floor=false;x.slow=true;if p.isDown("left")or q.isDown(1)and A<C and B>D then x.vx=x.vx-200*z;x.slow=false end;if p.isDown("right")or q.isDown(1)and A>C and B>D then x.vx=x.vx+200*z;x.slow=false end;local E,F,G,H=0,0,0,0,0;for w,I in ipairs(v)do local J,k,l=r(x.x,x.y,x.w,x.h,I.x,I.y,I.w,I.h)if J then E,F=E+k,F+l;if k~=0 then G=G+1 end;if l~=0 then H=H+1 end end end;E,F=E/(G>0 and G or 1),F/(H>0 and H or 1)print(E,F)x.x,x.y=x.x+E,x.y+F;if y(F)<0.5 then F=0 end;if y(E)<0.5 then E=0 end;if F<0 then x.floor=true end;if y(F)>0.5 then x.vy=0 end;if y(E)>0.5 then x.vx=0 end;if x.slow then x.vx=x.vx-x.vx*z end;if x.floor and x.slow then x.vx=x.vx-x.vx*10*z end;if x.floor and(p.isDown("up")or q.isDown(1)and B<D)then x.vy=x.vy-170 end end;function n.draw()for w,I in ipairs(v)do o.rectangle("line",I.x,I.y,I.w,I.h)end;o.rectangle("fill",x.x,x.y,x.w,x.h)end