private void aimShot() {
float distanceX = this.fX - this.paX;
float distanceY = this.fY - this.paY;
boolean xIsNegative = false;
boolean yIsNegative = false;
if (distanceX < 0) {
xIsNegative = true;
distanceX = -distanceX;
}
if (distanceY < 0) {
yIsNegative = true;
distanceY = -distanceY;
}
if (distanceX == 0) {
distanceX = 1;
}
if (distanceY == 0) {
distanceY = 1;
}
float ratio = distanceX / distanceY;
this.speedY = 10 / (ratio + 1);
this.speedX = ratio * this.speedY;
if (xIsNegative) {
this.speedX = -this.speedX;
}
if (yIsNegative) {
this.speedY = -this.speedY;
}
}
Thorion
Member Since 31 Jan 2012Offline Last Active Feb 14 2012 08:44 PM

Find content
Not Telling