# c# xna move Image using two Vectors?

initially image placed (0,0)th position and where ever i touch that is end position.

Now i got Start Position(0,0) and End Position(200,200).

i want to move start to end vector using angle.

If anyone now the ans please tell me.

• -1 It is not clear at all what you're asking. Do you want to draw a line or determine the angle of the vector or something else? Apr 17 '12 at 5:19
• i want to move image using two vector points/rectangle points. Apr 17 '12 at 5:22
• So what do the two points have to do with it? Are you resizing the image, are you moving it to point B, or what? Apr 17 '12 at 5:23
• i want to move image A position to B position with angle Apr 17 '12 at 5:29
• Possible duplicate: gamedev.stackexchange.com/questions/22952/… Apr 17 '12 at 5:52

You need to find the delta between your two vectors and just move the sprite along that new vector.

Vector2 startPos = new Vector2(0,0);
Vector2 endPos = new Vector2(100,200);

Vector2 delta = endPos - startPos;

//see if he is at the target. Very rarely will it be Vector2.Zero, so subtract 3 to get you close. If you don't do this your sprite can bounce.
if ((delta.X > -3 && delta.X < 3)
&& (delta.Y > -3 && delta.Y < 3))
{
sprite.Moving= false;
}

if(sprite.Moving)
{
delta.Normalize() //you want to normalize the vector. Otherwise he will move faster diagnoally

sprite.Position += delta *5f;  //5f is a random speed I chose. The higher this number, the faster he will move
}