import controlP5.*;
import fisica.*;
ControlP5 cp5;
FWorld world;
FPoly poly;
int oldx = 0;
int oldy = 0;
ArrayList circles = new ArrayList();
FBody hovered;
void setup() {
size(1280, 960);
//frameRate(30);
Fisica.init(this);
world = new FWorld();
world.setGravity(0, 400);
world.setEdges(55);
}
void draw() {
background(55);
if(circles.size() > 100){
int ind = int(random(circles.size()-1));
FBody hovered = circles.get(ind);
world.remove(hovered);
circles.remove(ind);
}
world.draw();
world.step();
//world.remove(poly);
}
void mouseClicked() {
float sz = random(20, 150);
FCircle b = new FCircle(sz);
b.setPosition(mouseX, mouseY);
b.setVelocity(random(-100,100)*2, random(-300)-100);
b.setRestitution(0.7);
b.setDamping(0.01);
b.setDensity(1);
b.setNoStroke();
b.setFill(random(255),random(255),random(255));
circles.add(b);
world.add(b);
}
void contactEnded(FContact c) {
if (!c.getBody1().isStatic()) {
FCircle b = (FCircle)c.getBody1();
if (b.getSize()>50) {
//b.setSize(b.getSize()*0.95);
}
}
if (!c.getBody2().isStatic()) {
FCircle b = (FCircle)c.getBody2();
if (b.getSize()>50) {
//b.setSize(b.getSize()*0.95);
}
}
}