01-23-2008, 09:39 AM

Actually, it's probably not mad skills needed, but I have next to none =o)

I've been messing around with a "gravity" test today, and although I came up with something cool to look at, it's not what I was trying for.

I can get the x,y position of the mouse, the x,y position of the object I want to move, and from there get the distance between the two points:

xdistance=math.abs(Fl:event_x()-object:x())

ydistance=math.abs(Fl:event_y()-object:y())

distance=math.sqrt(xdistance*xdistance+ydistance*ydistance)

What I would really like to do now is use that distance as a way to increase the motion of the object toward the mouse as the distance gets shorter. Essentially I'm looking for a single (floating point?) value that gradually increases as distance decreases. The problems I'm having are as follows:

1) I suck at math

2) The target speed should get larger as the distance gets smaller

3) The target speed should always be a fairly small non-negative number

Is there anyone who might be able to help?

Thanks.

This is the last thing I do before releasing the widgets-demo beta1

I've been messing around with a "gravity" test today, and although I came up with something cool to look at, it's not what I was trying for.

I can get the x,y position of the mouse, the x,y position of the object I want to move, and from there get the distance between the two points:

xdistance=math.abs(Fl:event_x()-object:x())

ydistance=math.abs(Fl:event_y()-object:y())

distance=math.sqrt(xdistance*xdistance+ydistance*ydistance)

What I would really like to do now is use that distance as a way to increase the motion of the object toward the mouse as the distance gets shorter. Essentially I'm looking for a single (floating point?) value that gradually increases as distance decreases. The problems I'm having are as follows:

1) I suck at math

2) The target speed should get larger as the distance gets smaller

3) The target speed should always be a fairly small non-negative number

Is there anyone who might be able to help?

Thanks.

This is the last thing I do before releasing the widgets-demo beta1