well, i did it, i think it works decent.
the distance traveled by the object starts to count when the mouse is released.
SetErrorMode(2)
SetWindowTitle("Distance")
SetWindowSize(1280, 720, 0)
SetWindowAllowResize(1)
SetVirtualResolution(1280, 720)
SetOrientationAllowed(1, 1, 1, 1)
SetSyncRate(60, 0)
SetScissor(0,0,0,0)
UseNewDefaultFonts(1)
setPhysicsGravity(0, 100)
SetPhysicsScale(0.01)
SetPhysicsDebugOn()
global spr as integer
spr = CreateSprite(0)
SetSpritePosition(spr, 150, 150)
SetSpriteSize(spr, 50, 50)
SetSpriteOffset(spr, GetSpriteWidth(spr)/2, GetSpriteHeight(spr)/2)
SetSpritePhysicsOn(spr, 2)
SetSpritePhysicsRestitution(spr, 0.60)
global distance as float
global px as float
global py as float
do
print(distance)
print(RateApp
moveSpr()
Getdistance()
Sync()
loop
function moveSpr()
if GetPointerstate() = 1
obj = getspritehit(GetPointerX(),GetPointerY())
if obj = spr and not getjointexists(1)
CreateMouseJoint(1, spr, GetPointerX(), GetPointerY(), 100)
distance = 0
endif
if getjointexists(1)
SetJointMouseTarget(1, GetPointerX(), GetPointerY())
endif
else
if getjointexists(1)
DeleteJoint(1)
px = GetSpriteXByOffset(spr)
py = GetSpriteYByOffset(spr)
distance = 0
endif
endif
endfunction
function Getdistance()
distance = distance + Sqrt(pow(GetSpriteXByOffset(spr) - px, 2) + pow(GetSpriteYByOffset(spr) - py, 2))
px = GetSpriteXByOffset(spr)
py = GetSpriteYByOffset(spr)
endfunction