Verlet ragdoll

@Kirl Thanks for the code above. I looked up Verlet ragdoll and I found some interesting reading. I converted what I could and made up the rest. Here’s what I got out of it. Slide your finger around the screen to move the ragdoll. Thought I’d share this in case anyone wants to see the full working code. I don’t know how this compares to yours.

displayMode(FULLSCREEN)

function setup()
    pt={}   -- point table
    con={}  -- constraint table
    createpoint(200,315,1,1)    -- x val, y val, x movement, y movement
    createpoint(200,300,0,0)
    createpoint(150,300,0,0)
    createpoint(250,300,0,0)
    createpoint(100,200,0,0)
    createpoint(200,200,0,0)
    createpoint(300,200,0,0)
    createconstraint(1,2)       -- constrain which points in pt table
    createconstraint(2,6)
    createconstraint(2,3)
    createconstraint(2,4)
    createconstraint(5,6)
    createconstraint(7,6)
end

function draw()
    background(0)
    updatepoint()
    updateconstraint()
    for z=1,#pt do   -- draw points
        fill(255)
        if z==1 then
            fill(255,0,0)
            ellipse(pt[z].nx,pt[z].ny,25)
        else
            ellipse(pt[z].nx,pt[z].ny,10)
        end
    end    
    stroke(255)
    strokeWidth(2)
    for z=1,#con do -- draw lines between constraint points
        line(pt[con[z].c1].nx,pt[con[z].c1].ny,pt[con[z].c2].nx,pt[con[z].c2].ny)
    end
end

function touched(t)
    if t.state==MOVING then
        pt[1].nx=pt[1].nx+t.deltaX/10
        pt[1].ny=pt[1].ny+t.deltaY/10
    end
end

function updatepoint()
    for z=1,#pt do
        local dx=pt[z].nx-pt[z].ox
        local dy=pt[z].ny-pt[z].oy
        pt[z].ox=pt[z].nx
        pt[z].oy=pt[z].ny
        pt[z].nx=pt[z].nx+dx
        pt[z].ny=pt[z].ny+dy
    end
end

function updateconstraint()
    for j=1,#con do
        t1=con[j].c1
        t2=con[j].c2
        local dist=math.sqrt((pt[t1].nx-pt[t2].nx)^2+(pt[t1].ny-pt[t2].ny)^2)
        local diff=dist-con[j].len                        
        local dx=pt[t1].nx-pt[t2].nx
        local dy=pt[t1].ny-pt[t2].ny
        if con[j].len>0 then
            diff=diff/con[j].len
        else
            diff=0
        end
        dx=dx*.5
        dy=dy*.5
        pt[t1].nx=pt[t1].nx-diff*dx
        pt[t1].ny=pt[t1].ny-diff*dy
        pt[t2].nx=pt[t2].nx+diff*dx
        pt[t2].ny=pt[t2].ny+diff*dy
    end
end

function createpoint(x,y,vx,vy)
    table.insert(pt,{nx=x,ny=y,ox=x-vx,oy=y-vy})
end

function createconstraint(p1,p2)
    length=math.sqrt((pt[p1].nx-pt[p2].nx)^2+(pt[p1].ny-pt[p2].ny)^2)
    table.insert(con,{c1=p1,c2=p2,len=length})
end