>i have 2 sprites independently and at random moving on stage
>in between these 2 moving sprites is a third sprite oscillating between 
>the first 2
>that is to say sprite number 3 moves from one sprite to another and back

Without seeing your code, I can only recommend a general approach.

The third sprite needs to know where the other two are. You could broadcast 
their location with sendSprite, but I would probably do that with some 
globals, e.g.

global gSprite1LocH
global gSprite1LocV
global gSprite2LocH
global gSprite2LocV

Obviously, update those 4 variables continuously as your first two sprites 
move around.

Next, I would have a behavior attached to the third sprite that moves it, 
frame by frame, towards its target sprite, until it has travelled as close 
(or as far) as you want, then start moving back towards the other sprite.

Since the two attracting sprites are changing location, you will need to 
constantly update the direction your third sprite is moving. You might use 
the formula for a line, probably in the Ax + By = C form. Or, you might use 
a more brute-force approach. Here's some pseudocode for the oscillator:

if the target sprite is above me
   y Direction = +1
else if the target sprite has the same y
   y Direction = 0
else
   y Direction = -1
end

if the target sprite is to my left
   x Direction = -1
else if the target sprite has the same x
   x Direction = 0
else
   x Direction = +1
end

Move to current locH + x Direction, current locY + y Direction

As I said, you'll need to keep track also of how far you have travelled, or 
how close you are, and periodically switch target sprites.

Hope this helps.


Cordially,
Kerry Thompson
Learning Network


[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!]

Reply via email to