Hello Colin
I was dead to the world and I just awake after a Pythagorean dream...
It's easy to know the number of pixels beetween two points with this formula
(In french schools we have this pretty counting song:
"Le carr� de l'hypoth�nuse
Est �gale si je ne m'abuse
A la somme des carr�s
Des deux autres c�t�s"):

a = abs (oldloc[1] -newloc[1])
b = abs(oldloc[2] -newloc[2])
c = power(a, 2) +  power(b, 2)
hyp = sqrt(c)

so, I added it to yours:

 on mouseUp
 s = the currentspritenum
 oldloc = the loc of sprite s
 newloc = point(random(640),random(480))
--
a = abs (oldloc[1] -newloc[1])
b = abs(oldloc[2] -newloc[2])
c = power(a, 2) +  power(b, 2)
hyp = sqrt(c)
--
 locdifx = float(newloc[1] - oldloc[1])/hyp
 locdify = float(newloc[2] - oldloc[2])/hyp
 repeat with a = 1 to (hyp-1)
 sprite(s).loch = oldloc[1] + locdifx * a
 sprite(s).locv = oldloc[2] + locdify * a
 updatestage
 starttimer
 repeat while the timer < 2
 end repeat
 end repeat
 sprite(s).loc = newloc
 end

Now, if I put the trails on, I get all the dots I need, no more, no less.
Of course I don't teach you anything but Thank you again for your great
help!
jean-louis valero

> superb! thanks a lot,Colin, for your suggestion...I failed effectively with
> accumulating errors. Customarily I prefer to  do something relentlessly but as
> I was in a hurry, you saved me hours of sleep...
> regards
> jean-louis valero
> 
> 
>> Using baplacecursor(from xtra "budapi") I'd like to simulate the cursor
>> drawing (slowly) an invisible but exact line beetween two arbitrary points.
>> But I've not the math for the angle. Any suggestion?
> 
> 
> It doesn't take much math, just divide the difference between the two
> locations by the number of steps you want to take, and then
> repeatedly move the cursor by that much. Keep the arithmetic as
> floating point, otherwise you'll get an accumulating error. The way I
> tend to do it is to do the movement one less times that you need, and
> then at the end lock it to the destination point. That way you don't
> risk a rounding mistake.
> 
> Here's an example which you can put on a sprite to see the effect:
> 
> on mouseUp
> s = the currentspritenum
> oldloc = the loc of sprite s
> newloc = point(random(640),random(480))
> locdifx = float(newloc[1] - oldloc[1])/50
> locdify = float(newloc[2] - oldloc[2])/50
> repeat with a = 1 to 49
> sprite(s).loch = oldloc[1] + locdifx * a
> sprite(s).locv = oldloc[2] + locdify * a
> updatestage
> starttimer
> repeat while the timer < 2
> end repeat
> end repeat
> sprite(s).loc = newloc
> end


[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