Hello! I’ve been trying to put this code into separate tabs with classes so I can play around with changing the mouseX and mouseY to Kinect. I was wondering what’s going wrong here? Would really appreciate some help on this It is just showing up blank whenever I run it, but I don’t understand why.
TAB1
//ArrayList <Particle> particles;
//int num = 300;
ParticleSystem p;
void setup() {
size(800, 600);
smooth();
p = new ParticleSystem();
//particles = new ArrayList<Particle>();
//for (int i = 0; i < num; i++) {
// particles.add( new Particle() );
//}
}
void draw() {
background(255);
//for (int i = 0; i < num; i++) {
// particles.get(i).move();
// particles.get(i).draw();
//}
p.addParticle(width/2,height/2);
//for (Particle p : particles) {
// p.move();
// p.sketch();
// p.checkMouse();
//}
}
TAB2
class Particle {
float px, py;
float dx, dy;
float damp;
color sc;
Particle(float x, float y) {
px = width / 2;
py = height/2;
dx = random(width);
dy = random(height);
damp = random(0.01, 0.04);
sc = color(random(100, 255), 0, random(15, 25));
}
void move() {
dx += random(-5, +5);
dy += random(-5, +5);
px += (dx - px) * damp;
py += (dy - py) * damp;
}
void sketch() {
fill(sc, 30);
noStroke();
ellipse(px, py, 20, 20);
fill(100);
noStroke();
ellipse(px, py, 5, 5);
}
void mouse() {
dx = mouseX;
dy = mouseY;
}
void checkMouse() {
float mouseRadius = 50;
float d = dist(mouseX, mouseY, px, py);
if (d<mouseRadius && d > 1) {
dx += (px-mouseX) / d*mouseRadius;
dy += (py-mouseY) / d*mouseRadius;
}
}
}
TAB3
class ParticleSystem {
ArrayList <Particle> particles;
//int num = 300;
ParticleSystem(){
particles = new ArrayList<Particle>();
}
int num = 300;
void addParticle(float x, float y) {
for (int i = 0; i < num; i++) {
particles.add(new Particle(x,y));
}
}
}