How do I determine the points in a line, in order, from P1 to P2?
<p>Hey guys. I'm trying to make a simple game for Android in which the player drags a space ship with one thumb and fires at enemy ships by tapping empty space with the other thumb. Thing is, to animate the bullets traveling across space, I need the list of points between the user's spaceship, and the end of the screen, the line passing through the place the user tapped. </p>

<p>I know I have to parametrize the line, and have read some about the subject, but I can't quite grasp it, especially on how to convert it to code. The way I see it, I need to convert the line segment between the user's ship (P1) and the place the user taps (P2) the smallest possible piece, the rate of change between x and y, the slope, I guess. Once I have that I can just multiply the rate of change by the distance from P1 to get the desired point. </p>

<p>But it ain't quite working. Any help would be appreciated. Thanks.</p>

<p>EDIT:
This is what I was doing. This is all to calculate the rate of change, which I use on the Beam's update method to update it's position by multiplying it by speed...</p>

<pre><code>Beam(Renderer r, float OX, float OY, float TX, float TY)
{
    super(r);

    p.x = (int) OX;
    p.y = (int) OY;

    paint = new Paint();
    paint.setColor(Color.BLUE);


    float X = TX - OX;
    float Y = TY - OY;

    boolean xPositive = X &gt;= 0;
    boolean yPositive = Y &gt;= 0;

    if(X &lt; Y)
    {
        RateOfChangeX = Math.abs(X) / Math.abs(Y);
        RateOfChangeY = 1;
    }
    else
    {
        RateOfChangeX = 1;
        RateOfChangeY = Math.abs(Y) / Math.abs(X);
    }
    if(RateOfChangeX &lt; 0 &amp; xPositive)
    {
        RateOfChangeX = RateOfChangeX * -1;
    }
    if(RateOfChangeY &lt; 0 &amp; yPositive)
    {
        RateOfChangeY = RateOfChangeY * -1;
    }
}
</code></pre>
