a simple verlet integration scheme with decaying energy would work to get an almost physically accurate "gravity" effect.
you'll have to create a few instance variables, i put them in square brackets for clarity, i named the point which stuff moves towards point so its position would be point.x, point.y
{ for each object: }
- set [tempx] to: self.x
- set [tempy] to: self.y
- set object position to:
{
>X: self.x+(self.x-lastx)*0.95+(point.x-self.x)*0.1
>Y: self.y+(self.y-lasty)*0.95+(point.y-self.y)*0.1
}
- set [lastx] to: tempx
- set [lasty] to: tempy
you could also try something like:
{ for each object: }
- set [dist] to: distance( self.x , self.y , point.x , point.y )
- set [tempx] to: self.x
- set [tempy] to: self.y
- set object position to:
{
>X: self.x+(self.x-lastx)*0.95+(point.x-self.x)*1/dist
>Y: self.y+(self.y-lasty)*0.95+(point.y-self.y)*1/dist
}
- set [lastx] to: tempx
- set [lasty] to: tempy
or something like:
{ for each object: }
- set [dist] to: distance( self.x , self.y , point.x , point.y )
- set [tempx] to: self.x
- set [tempy] to: self.y
- set object position to:
{
>X: self.x+(self.x-lastx)*0.95+(point.x-self.x)*2/(dist^2)
>Y: self.y+(self.y-lasty)*0.95+(point.y-self.y)*2/(dist^2)
}
- set [lastx] to: tempx
- set [lasty] to: tempy
play with the constant multipliers that appear in these equations like *0.95, *0.1, *1, *2 to vary energy conservation, spring force, traction force, gravity strength respectively, try to do the same thing to the X Y equations or you'll get strange behavior.