Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Needs some work but I'm happy it works
- public void gravity(AnimatedSprite T)
- {
- //
- //distance getter
- double dist = this.DisToOther(T);
- //double distX = Math.abs(this.center().X() - T.center().X());
- //double distY = Math.abs(this.center().Y() - T.center().Y());
- //double dist = Math.sqrt( Math.pow(distX, 2) + Math.pow(distY, 2) );
- double force = (1.81 * (T.mass * 10)) / Math.pow(dist,2);//Math.pow() * massA
- double dirX = (T.center().X() - this.center().X()) / dist;
- double dirY = (T.center().Y() - this.center().Y()) / dist;
- if(this.DisToOther(T) >= this.frameWidth())
- {
- //I'll be fixing this up with Velocity increment functions in a few
- T.setXVelocity( (T.velocity().X() - (force * dirX)) );//T.velocity().X()
- T.setYVelocity( (T.velocity().Y() - (force * dirY)) );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement