public void applyGravity(Player p)
{
//Gravity Calculations between players and the planet(object producing the gravity).
float G = MatchConfig.gravityConstant;
double distanceG = Math.Sqrt((Math.Pow(p.x - this.x, 2) + Math.Pow(p.y - this.y, 2)));
double speedVector = (float)((G * this.mass) / Math.Pow(distanceG, 2));
double deltaY = (p.y - this.y);
double deltaX = (p.x - this.x);
double angleDegree = Math.Atan(deltaY / deltaX);// * 180 / Math.PI;
//float rad = (float)(Math.PI / 180) * o.angle;
if (p.x != this.x)
{
//speedX += (float)(Math.Cos(angleDegree) * speedVector);
if (p.x > this.x)
p.speedX -= (float)Math.Abs((Math.Cos(angleDegree) * speedVector));
else
p.speedX += (float)Math.Abs((Math.Cos(angleDegree) * speedVector));
}
if (p.y != this.y)
{
//speedY += (float)(Math.Sin(angleDegree) * speedVector);
if (p.y < this.y)
p.speedY += (float)Math.Abs((Math.Sin(angleDegree) * speedVector));
else
p.speedY -= (float)Math.Abs((Math.Sin(angleDegree) * speedVector));
}
}