Particle Class/Object(s)
Star a [] = new Star[10];
void setup(){
size(500,500);
background(0);
for(int i = 0; i < a.length; i ++){
a [i] = new Star();
}
}
void draw(){
background(0);
for (int i =0 ; i < a.length; i++){
a[i].update();
a[i].display();
//saveFrame("output/gol_####.png");
}
}
class Star {
int d = 30;
float x, y, z;
Star () {
x = width/2;
y = height/2;
}
void update() {
noStroke();
// fill(255,100);
//rect(0,0,width, height);
x += random(-3,3);
y += random(-3,3);
if (x > width) { ///// dont let them out of frame start
x = width;
}
if (x < 0) {
x = 0;
}
if (y > height) {
y = width;
}
if (y < 0) {
y = 0;
}//////dont let them out of frame function end
}
void display() {
stroke(133, 20, 130);
strokeWeight(10);
fill(123, 43, 243);
ellipse(x, y, 30, 30);
noCursor();
stroke(255);
strokeWeight(10);
fill(0);
ellipse(mouseX, height/2 + 200, d+10, d+10);////changing buttom
if (mouseX<width/2) {
fill(random(255), random(255), 255, 200);
ellipse(x, y, 60, 60);
} else {
fill(255, random(255), random(255), 200);
ellipse(x, y, 60, 60);
}
}
}
Comments
Post a Comment