This commit is contained in:
GordonDaFreeman 2017-09-20 21:12:02 +02:00
parent 75ea591a9c
commit 189afc5a66
1 changed files with 9 additions and 0 deletions

View File

@ -16,4 +16,13 @@ public class Position {
b = Math.abs(y-p.y);
return Math.sqrt(a*a+b*b);
}
public void moveTo(Position t,double d){
double cosT = (x - t.x)/getDistance(t);
double cosA = (y - t.y)/getDistance(t);
double ax = cosT*d;
double ay = cosA*d;
x += ax;
y += ay;
}
}