----- Original Message -----
From: Kerry Thompson <[EMAIL PROTECTED]>
Subject: <lingo-l> Calculus & Vectors
> I want the floating sprite to exert sort of a planetary gravity effect on
> the other sprites. As the floating sprite approaches a fixed sprite, that
> fixed sprite should start moving towards the floating sprite, but stay
> within its 100 x 100 rectangle. Ideally, the closer the floating sprite
> gets, the more the stationary sprite should be attracted--i.e., the faster
> it should move.
Aah, planetary gravity. Y'know we really have a lot to thank that force for. Otherwise
we couldn't hear if we dropped a coin out of the pocket, could we?
Well, the closer two objects get, the more they gravitate to eachother by a certain
factor. Lets say this factor is 100. Moving an object in Lingo could then look
something like this:
on hMove me
lDistance=sprite(me.spritenum).loc-sprite(fixedsprite).loc
sprite(me.spritenum).loc=sprite(me.spritenum).loc+100/lDistance
end
This way the me-sprite will move and accelerate towards the fixed sprite.
If the distance (lDistance) is more than 100 then it won't move at all because
100/(anythingbiggerthan100) will be 0 due to Lingo's <sarcasm> magnificent
numberjuggling </sarcasm>
Just create two forces to pull the moving sprite. The big fixed sprite force and the
go-back-to-orig-pos force. Simply add them.
I would, however, very much advice you to store all positions and movementvectors in
floating variables and only once in a while assign the sprite positions to those
floating values, otherwise you will get ugly, jumpy and irregular movements. I mean
really ugly! But ofcourse you already code that way, Kerry.
Hope this helps
/jonas
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]