Very neat. Crazy how well it works for so little code. Is the array a randomized position for each joint when moving?
Play game
Ragdoll's itch.io pageCompressed Bytes used
730
Source Code (OPTIONAL)
function f(n)local c,t,a,l,r=unpack(n)local o,d=i[c],i[t]local n={o[1]-d[1],o[2]-d[2]}local f=sqrt(n[1]^2+n[2]^2)local e=(f-a)/f if(r==2and f>=a)return
local f=1-l i[c]={o[1]-n[1]*l*e,o[2]-n[2]*l*e}i[t]={d[1]+n[1]*f*e,d[2]+n[2]*f*e}end function c()for n=1,10do for n=1,#i do i[n]={mid(0,i[n][1],127),mid(0,i[n][2],127)}end for n in all(a)do f(n)end end end function n(n,o,d)line(i[n][1],i[n][2],i[o][1],i[o][2],d)end function o(n)local n=split(n,"|")for o in pairs(n)do n[o]=split(n[o])end return n end a=o"1,2,4,0.7|1,3,8,1,2|2,3,8,0.6|2,4,6,0.2|2,5,6,0.2|3,6,8,0.3|3,7,8,0.3|3,9,8,0.3,2|3,8,8,0.3,2|2,7,8,0.1,2|2,6,8,0.1,2|7,6,2,0.5,2|6,8,8,0.25|7,9,8,0.25|4,10,6,0.2|5,11,6,0.2"i=o("64,117|"..64-rnd(3)..","..119-rnd().."|"..64-rnd()..","..122-rnd().."|63,122|63,124|63,123|66,123|63,127|66,127|63,123|66,123")l=o"64,117|64,119|64,123|63,123|66,123|63,126|66,127|63,123|66,123|63,127|66,127|63,123|66,123"r={}t=.01function _update60()for o=1,#i do local n,d,e=i[o],l[o],{0,5}if(n[2]>=127)e={(d[1]-n[1])*.5/t,(d[2]-n[2])*.5/t}
l[o],i[o]=n,{n[1]+n[1]-d[1]+e[1]*t,n[2]+n[2]-d[2]+e[2]*t}end c()if(btnp(❎))for n=1,#i do i[n]={i[n][1]+(rnd(6)-3),i[n][2]-2-rnd(2)}end
if(btnp(🅾️))t=.01-t
cls(5)d="❎ to apply force!"e="🅾️ to toggle gravity: "..(t>0and"on"or"off")?d,4,5,0
?d,4,4,6
?e,4,13,0
?e,4,12,6
n(2,4,3)n(10,4,3)circfill(i[1][1],i[1][2],2,15)n(2,3,8)n(7,3,1)n(7,9,1)n(6,3,12)n(6,8,12)n(2,5,11)n(11,5,11)end
Leave a comment
Log in with itch.io to leave a comment.