[A83] Re: Angles


[Prev][Next][Index][Thread]

[A83] Re: Angles




i think the most simple way to do it would be like this:

 l = distense between the two points ( ==  sqrt( (enemy_x-player_x)^2 +
(enemy_y-player_y)^2) ), devided by the speed ( == 3 for 3 pixels per
frame )
 dx = (enemy_x-player_x) / l
 dy = (enemy_y-player_y) / l

then when you want to let your bullet travel, let is start at (player_x,
player_y), and add (dx,dy) to that point every frame...

you could use some fixed-point values to speed up a bit... i'm not sure if
it is posible to use a look-up-table for the SRQT thing...

---

an other way to do it, would be to use sin/cos/tan calculations...

angle = arctan( (y2-y1)/(x2-x1) )
dx = 3 * sin(angle)
dy = 3 * cos(angle)

the sin and cos can be calculated with a single lookuptable ( cos(a) ==
sin(a + .5 Pi) ), using fixed-point values..

> -----Oorspronkelijk bericht-----
> Van: assembly-83-bounce@lists.ticalc.org
> [mailto:assembly-83-bounce@lists.ticalc.org]Namens Joe Pemberton
> Verzonden: Thursday, September 20, 2001 14:55
> Aan: assembly-83@lists.ticalc.org
> Onderwerp: [A83] Angles
>
>
>
> How would I determine the angle needed for an enemy bullet fired from
> (enemy_x), (enemy_y) so it would hit the player (player_x),
> (player_y) at a
> constant speed of 3 pixels per frame?  I saw the routine in Pheonix that
> did this but I can't understand it.  help?..
>
> _____________________________________________
> Free email with personality! Over 200 domains!
> http://www.MyOwnEmail.com
>
>
>





References: