Test classes

This commit is contained in:
ngb
2021-12-30 18:07:00 +01:00
parent 1a3be1b485
commit 8505c2baf4
11 changed files with 843 additions and 82 deletions

View File

@@ -0,0 +1,29 @@
import schule.ngb.zm.*;
public class Attractor extends Mover {
private static final int G = 10;
private int mass = 0;
public Attractor( int x, int pY, int pMass ) {
this(x, pY, pMass, new Vector());
}
public Attractor( int x, int pY, int pMass, Vector pVelocity ) {
super(x, pY, pVelocity);
mass = pMass;
setFillColor(YELLOW);
}
public void attract( Mover pMover ) {
if( pMover != this ) {
Vector force = new Vector(this.x, this.y);
force.sub(pMover.getX(), pMover.getY()).scale(mass*G).limit(0, 50*G);
pMover.applyForce(force);
}
}
}