   [.net] calculating projectile path in 2D game in C#
  Hi, im working on a 2D vertical scroller shooting game in C#. the game is near its completion but i'm stuck on one problem. in my code now the enemy's bullet could only be fired in 4 directions - up, down, left, or right. however i'd like the enemies to fire at the player sprite. i know how to get the coordinates of both enemy and player sprites, could someone pls enlighten me on how to calculate the projectile path? For example, the enemy sprite is at 200,300(X,Y coordinate) and the player sprite is at 500,500, and the enemy fires a bullet at the player. now, how do i get the path of the enemy's bullet that will travel toward 500,500.currently in my code the bullet moves according to its Matrix system like this:bullet.bulletMatrix = Matrix.Multiply(bullet.bulletMatrix, Matrix.Translation(0, Bullet.bulletSpeed, 0));as u can see the bullet moves only on Y coordinate, since X coordinate is set to 0.is there a way to calculate 2 numbers that i could put into X,Y coordinate to make the bullet travel toward the player's position?that way i can do:bullet.bulletMatrix = Matrix.Multiply(bullet.bulletMatrix, Matrix.Translation(X, Y, 0));Your input is greatly appreciated.   
  You need to find the direction to the player, and then multiply that vector by the speed of the bullet<br>//This will calculate the initial direction of travel for the bullet, and set it to move along the direction at a speed defined by "bulletSpeed"<br><br>float bulletX=0.0f;<br>float bulletY=0.0f;<br>float distance=0.0f;<br><br>//step 1: find the vector of the player from the enemy:<br><br>bulletX = player.position.x - enemy.position.x;<br>bulletY = player.position.y - enemy.position.y;<br><br>//step 2: normalize the vector to give a direction of length 1 (so that we can make it move at the correct speed)<br><br>distance = sqrt(bulletdirection.x*bulletdirection.x + bulletdirection.z*bulletdirection.z);<br><br>bulletX /= distance;<br>bulletY /= distance;<br><br>//step 3: multiply by the speed you want the bullet to move at:<br>bulletX *= bulletSpeed;<br>bulletY *= bulletSpeed;<br><br>//step 4: Now do your snizzle<br>bullet.bulletMatrix = Matrix.Multiply(bullet.bulletMatrix, Matrix.Translation(bulletX , bulletY, 0));<br><br></code>;  If you do "playercoords - enemycoords" then the result will be a vector that points at the player position with respect to the enemys position. If you then normalize this vector (make it have a length of 1) then you will have a direction to the player. Multiply this by the bullets speed and you have the direction that you need to move in at the right speed in order to fire at the player.I hope this helps.EDIT: Argh, beaten to it.   ;  thanks for your code.