Advertisement
StormWingDelta

GravityFailMoment

Jun 21st, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. private void gravity(AnimatedSprite T, double massA, double massB)
  2.     {
  3.         //
  4.         //distance getter
  5.         double dist = this.DisToOther(T);
  6.         double force = 9.8 * Math.pow( ( (massA * massB) / dist ),2 );
  7.        
  8.         if( Math.abs(this.center().X())  > Math.abs(T.center().X()) )
  9.         {
  10.             T.setXVelocity( (T.velocity().X()-force) );//T.velocity().X()
  11.         }
  12.         if( Math.abs(this.center().Y()) > Math.abs(T.center().Y()) )
  13.         {
  14.             T.setYVelocity( (T.velocity().Y()-force) );//T.velocity().Y()
  15.         }
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement