spawn on mouse press
This commit is contained in:
parent
37fca7ef10
commit
7f47af5e13
|
@ -1,5 +1,5 @@
|
|||
final int maxDistanz = 200;
|
||||
final int punkteMenge = 40;
|
||||
final int punkteMenge = 100;
|
||||
final int punktDurchmesser = 10;
|
||||
final int verbindungsDicke = 4;
|
||||
final float punktGeschwindigkeit = 3;
|
||||
|
@ -23,9 +23,9 @@ void draw() {
|
|||
verbindePunkte(m, p.position);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < punkteMenge; i++) {
|
||||
for (int i = 0; i < punkte.size(); i++) {
|
||||
punkte.get(i).update();
|
||||
for (int j = 0; j < punkteMenge; j++) {
|
||||
for (int j = 0; j < punkte.size(); j++) {
|
||||
if (j != i) {
|
||||
verbindePunkte(
|
||||
punkte.get(i).position,
|
||||
|
@ -39,6 +39,10 @@ void draw() {
|
|||
}
|
||||
}
|
||||
|
||||
void mousePressed() {
|
||||
punkte.add(new Punkt(new PVector(mouseX, mouseY)));
|
||||
}
|
||||
|
||||
void verbindePunkte(PVector a, PVector b) {
|
||||
float c = dist(a.x,a.y,b.x,b.y);
|
||||
float d = 255;
|
||||
|
@ -60,6 +64,12 @@ class Punkt {
|
|||
position = new PVector(random(width), random(height));
|
||||
}
|
||||
|
||||
Punkt(PVector pos) {
|
||||
velocity = PVector.random2D();
|
||||
velocity.mult(punktGeschwindigkeit);
|
||||
position = pos.copy();
|
||||
}
|
||||
|
||||
void update() {
|
||||
position.add(velocity);
|
||||
if (position.x < 0) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user