xxxxxxxxxx
int NoB = 10;
float rad = -40;
int num_parts = NoB;
Blob[] b = new Blob[num_parts];
void setup(){
size(500, 800);
background(#fdc520);
for(int a = 0; a < num_parts; a++){
b[a] = new Blob();
}
}
void draw(){
background(#a80d45);
fill(#a62051);
quad(170, 200, 110, 610, 400, 610 ,350 , 200 );
for(int a = 0; a < num_parts; a++){
b[a].update();
b[a].Display1();
}
for(int a = 0; a < num_parts; a++){
b[a].Display2();
}
fill(#762056, 80);
noStroke();
quad (280, 200, 300, 610, 400, 610, 350, 200);
stroke(#491c5a);
noFill();
strokeWeight(7);
quad(170, 200, 110, 610, 400, 610 ,350 , 200 );
fill(#692c82);
quad(200,40, 170, 200, 350, 200, 320, 40);
quad(110, 610, 160, 700, 350, 700, 400, 610 );
quad(160, 700, 130, 780, 370, 780, 350, 700 );
fill(#47205c);
noStroke();
quad(280, 40, 280, 200, 350, 200, 320, 40);
quad(300,610,290,700, 350, 700, 400, 610);
fill(#411d54);
quad (290,700, 290, 780, 370, 780, 350,700);
}
class Blob{
float x1;
float y1;
float rad1;
float thet;
float velo = 0.1;
Blob(){
x1 = width/2;
y1 = height/2;
rad1 = rad + random(90, 160);
thet = random(0, PI);
}
void update(){
thet = thet + random(-.02, .03);
//gives the balls movement
x1 = x1 + (velo * cos(thet));
y1 = y1 + (velo * sin(thet));
if(x1 < (0 + rad1*10) ){
thet = thet + (PI / 2);
}
if(x1 > (width - (rad1*10)) ){
thet = thet + (PI / 2);
}
if(y1 < (0 + (rad1*10)) ){
thet = thet + (PI / 2);
}
if(y1 > (height - (rad1*10)) ){
thet = thet + (PI / 2);
}
//Hit detection, but it is in a straight line.
//if you wanted to make it more specific and slant, you can hit detect at different points by && (y1 < or > whatever point on the screen
if( (x1 < 205) || (x1 > width-200) ) {
velo = velo*-1;
}
if( (y1 < 150) || (y1 > height-100) ) {
velo = velo*-1;
}
}
void Display1(){
fill(239,38,68,200);
noStroke();
ellipse(x1, y1, rad1, rad1);
}
void Display2(){
fill(255,100,0, 150);
noStroke();
ellipse(x1, y1, rad1, rad1);
}
}