>Hi,
>I am struck with one part I need to know in a rectangle at which 
>angle does diagonal divides the 90 degree. In lingo Tan-1 is not 
>there so I am confused what to do. Actually I wanted to rotate a 
>sprite according to another sprite.
>So any solutions?


Now that you know there is an atan() function, you'll eventually work 
out the routine for getting the angle from one sprite to another. The 
routine is usually about 10 lines long or so, but there's a way of 
using atan() that will cut the routine down to one line:

     angle = atan(p2[1]-p1[1],p2[2]-p1[2])

p1 and p2 would be the locs of the two sprites, and the resulting 
angle would be in radians. You can convert that to degrees by 
dividing by Pi and multiplying by 180. The whole routine to make a 
sprite turn towards the mouse location would be:

on prepareframe me
    p1 = the mouseloc
    p2 = sprite(me.spritenum).loc
    sprite(me.spritenum).rotation = 360-(atan(p2[1]-p1[1],p2[2]-p1[2]))/pi*180
end

This script would be attached to the sprite that needs to turn.

[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