[A83] Re: Angles


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

[A83] Re: Angles





----------------------------------------------
Original Message
From: "David Phillips"<david@acz.org>
Subject: [A83] Re: Angles
Date: Thu, 20 Sep 2001 18:28:59 -0700
Ok, I get that.  =) thanks.  But how do I actually (and easily) calculate
the y velocity needed to aim the bullet?
>
>If you want to move objects in any direction, then you'll need to use
16-bit
>fixed point numbers.  Here's how it works: the high byte is the actual
pixel
>position, and the low byte is the fractional position that you discard. 
You
>keep a 16-bit velocity for both the x and y axis, say vel_x and vel_y.  Say
>you want to move something only along the x axis at half a pixel per frame.
>You'd set vel_y to 0, and vel_x to 128.  The positions also must be 16-bit
>values.  Each frame, you'd add vel_x to object_x, and vel_y to object_y.
>Starting the object's coordinates at 0, what would the values look like? 
0,
>128, 256, 384, 512, etc.  When you actually draw it, you use the high byte.
>What would they look like?  0, 0, 1, 1, 2, etc.  Make sense?  This is the
>same idea behind Bresenham's line algorithm.
>
>> 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