How to make a Entity move towards a x and y?
<p>I am looking for a way to make my Entity(A bullet) move towards a x and y,which is where the player was when the bullet was fired. so In my entity class i have - </p>

<pre><code>   float xSpeed = 1.0F;
   float ySpeed = 0.0F;
</code></pre>

<p>if I wanted to move the entity in a diaganal line I would make xSpeed and ySpeed = 1.0F
How would I make it move in the dir of another x and y?</p>

<p>Thanks for the help
EDIT --
Solved,thanks for the help
To anyone else who finds this question needing help,here is my code-</p>

<pre><code>    float xSpeed = 0;
    float ySpeed = 0;
</code></pre>

<p>then I have some maths to make it so they move at the same speed</p>

<pre><code>   ySpeed =  ySpeed * (float) (2.5 / Math.sqrt(xSpeed * xSpeed + ySpeed * ySpeed));
   xSpeed = xSpeed * (float) (2.5 / Math.sqrt(xSpeed * xSpeed + ySpeed * ySpeed));
</code></pre>

<p>and this code to set the xSpeed and ySpeed,based on a x and y you want to move towards</p>

<pre><code>    xSpeed = (Game.PlayerX - x) / 3;
    ySpeed = (Game.Playery - y) / 3;
</code></pre>

<p>and then,finaly,add xSpeed and ySpeed to the x and y of your entity</p>

<pre><code>    this.x += xSpeed;
    this.y += ySpeed;
</code></pre>
