BlueJ-Projekt aus Test in "examples" verschoben

This commit is contained in:
ngb
2022-01-02 22:16:19 +01:00
parent 29a240909c
commit cb85bc5e53
4 changed files with 13 additions and 147 deletions

View File

@@ -1,29 +0,0 @@
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);
}
}
}

View File

@@ -1,40 +0,0 @@
import java.util.LinkedList;
import schule.ngb.zm.*;
public class Gravity extends Zeichenmaschine {
private LinkedList<Mover> movers = new LinkedList<>();
private LinkedList<Attractor> attractors = new LinkedList<>();
public void setup(){
for( int i = 0; i < 10; i++ ) {
Mover m = new Mover(random(10, width-10), random(10, height-10));
movers.add(m);
shapes.add(m);
}
attractors.add(new Attractor(width/2, height/2, 10));
shapes.add(attractors.get(0));
}
public void update( double delta ) {
for( Attractor a: attractors ) {
for( Mover m: movers ) {
a.attract(m);
}
}
for( Mover m: movers ) {
m.update(delta);
}
shapes.clear();
}
public void draw() {
shapes.clear();
}
}

View File

@@ -1,38 +0,0 @@
import schule.ngb.zm.*;
import schule.ngb.zm.formen.*;
public class Mover extends Circle implements Updatable {
private Vector velocity;
private Vector acceleration = new Vector();
public Mover( int x, int pY ) {
this(x, pY, new Vector());
}
public Mover( int x, int pY, Vector pVelocity ) {
super(x, pY, 10);
this.velocity = pVelocity.copy();
}
public void applyForce( Vector force ) {
acceleration.add(force);
}
public boolean isActive() {
return true;
}
public void update( double delta ) {
acceleration.scale(delta);
velocity.add(acceleration);
acceleration.scale(0.0);
this.x += velocity.x;
this.y += velocity.y;
}
}

View File

@@ -2,16 +2,10 @@
dependency1.from=BluejTest
dependency1.to=ClasspathInspector
dependency1.type=UsesDependency
dependency2.from=Gravity
dependency2.to=Mover
dependency2.type=UsesDependency
dependency3.from=Gravity
dependency3.to=Attractor
dependency3.type=UsesDependency
editor.fx.0.height=728
editor.fx.0.width=1037
editor.fx.0.x=95
editor.fx.0.y=53
editor.fx.0.height=0
editor.fx.0.width=0
editor.fx.0.x=0
editor.fx.0.y=0
objectbench.height=94
objectbench.width=776
package.divider.horizontal=0.6
@@ -22,8 +16,8 @@ package.editor.x=374
package.editor.y=158
package.frame.height=660
package.frame.width=800
package.numDependencies=3
package.numTargets=5
package.numDependencies=1
package.numTargets=2
package.showExtends=true
package.showUses=true
project.charset=UTF-8
@@ -33,37 +27,16 @@ readme.width=48
readme.x=10
readme.y=10
target1.height=70
target1.name=Mover
target1.name=BluejTest
target1.showInterface=false
target1.type=ClassTarget
target1.width=120
target1.x=320
target1.y=200
target1.x=70
target1.y=10
target2.height=70
target2.name=BluejTest
target2.name=ClasspathInspector
target2.showInterface=false
target2.type=ClassTarget
target2.width=120
target2.x=70
target2.y=10
target3.height=70
target3.name=Attractor
target3.showInterface=false
target3.type=ClassTarget
target3.width=120
target3.x=390
target3.y=350
target4.height=70
target4.name=ClasspathInspector
target4.showInterface=false
target4.type=ClassTarget
target4.width=130
target4.x=380
target4.y=30
target5.height=70
target5.name=Gravity
target5.showInterface=false
target5.type=ClassTarget
target5.width=120
target5.x=100
target5.y=300
target2.width=130
target2.x=380
target2.y=30