Skip to main content
added 135 characters in body
Source Link

Euclidean distante = sqrt (dx * dx + dy * dy), for your distance you need to define dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy.

Usualy the direction vector is Pt - Pm (Position vector target - Position vector missile). In your case you can define Direction vector x component as

if (x2-x1)>=0
  DirX=if min(abs(x2-x1) ,< abs((x2-x1)-width))
    DirX = x2-x1;   
  else
  DirX= max DirX = (x2-x1)-width;
else
 , if (abs(x2-x1) < abs(width + (x2-x1))
    DirX=x2-x1;
  else
    DirX= width + (x2-x1);

enter image description here

In the same way (using HEIGTH) you can get DirY.

Euclidean distante = sqrt (dx * dx + dy * dy), for your distance you need to define dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy.

Usualy the direction vector is Pt - Pm (Position vector target - Position vector missile). In your case you can define Direction vector x component as

if (x2-x1)>=0
  DirX= min(x2-x1 , (x2-x1)-width)
else
  DirX= max(x2-x1 , width + (x2-x1))

enter image description here

In the same way (using HEIGTH) you can get DirY.

Euclidean distante = sqrt (dx * dx + dy * dy), for your distance you need to define dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy.

Usualy the direction vector is Pt - Pm (Position vector target - Position vector missile). In your case you can define Direction vector x component as

if (x2-x1)>=0
  if (abs(x2-x1) < abs((x2-x1)-width))
    DirX = x2-x1;   
  else
    DirX = (x2-x1)-width;
else
  if (abs(x2-x1) < abs(width + (x2-x1))
    DirX=x2-x1;
  else
    DirX= width + (x2-x1);

enter image description here

In the same way (using HEIGTH) you can get DirY.

deleted 1 character in body
Source Link

Euclidean distante = sqrt (dx * dx + dy * dy), for your distance you need to define dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy.

Usualy the direction vector is Pt - Pm (Position vector target - Position vector missile). In your case you can define Direction vector x component as

if (x2-x1)>=0
  DirX= min(x2-x1 , width -(x2-x1)-width)
else
  DirX= max(x2-x1 , width + (x2-x1))

enter image description here

In the same way (using HEIGTH) you can get DirY.

Euclidean distante = sqrt (dx * dx + dy * dy), for your distance you need to define dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy.

Usualy the direction vector is Pt - Pm (Position vector target - Position vector missile). In your case you can define Direction vector x component as

if (x2-x1)>=0
  DirX= min(x2-x1 , width -(x2-x1))
else
  DirX= max(x2-x1 , width + (x2-x1))

enter image description here

In the same way (using HEIGTH) you can DirY.

Euclidean distante = sqrt (dx * dx + dy * dy), for your distance you need to define dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy.

Usualy the direction vector is Pt - Pm (Position vector target - Position vector missile). In your case you can define Direction vector x component as

if (x2-x1)>=0
  DirX= min(x2-x1 , (x2-x1)-width)
else
  DirX= max(x2-x1 , width + (x2-x1))

enter image description here

In the same way (using HEIGTH) you can get DirY.

added 426 characters in body
Source Link

Euclidean distante = sqrt (dx * dx + dy * dy), for your distance you need to define dx dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy.

Usualy the direction vector is Pt - Pm (Position vector target - Position vector missile). In your case you can define Direction vector x component as

if (x2-x1)>=0
  DirX= min(x2-x1 , width -(x2-x1))
else
  DirX= max(x2-x1 , width + (x2-x1))

enter image description here

In the same way (using HEIGTH) you can DirY.

Euclidean distante = sqrt (dx * dx + dy * dy), you need to define dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy.

Euclidean distante = sqrt (dx * dx + dy * dy), for your distance you need to define dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy.

Usualy the direction vector is Pt - Pm (Position vector target - Position vector missile). In your case you can define Direction vector x component as

if (x2-x1)>=0
  DirX= min(x2-x1 , width -(x2-x1))
else
  DirX= max(x2-x1 , width + (x2-x1))

enter image description here

In the same way (using HEIGTH) you can DirY.

Source Link
Loading