Party in the sky

I organized my last code into three main functions — consumingClouds, confettiTrail, and shootingStar — and added the bouncing ball effect and borrowed Shiffman’s code for a star shape. Can I add some ’80s disco music later on?

//What's happening conceptually?
//void draw(){
//consumingClouds();
//twinklingStars();
//shootingStar();
//}

//DECLARING VARIABLE
float cloudX;
float cloudY;
int x = 0;
int y = 0;
int xspeed = 30;
int yspeed = 10;

//INITIALIZE VARIABLE
void setup(){
size(800,800);
background(255);
}

//USE VARIABLE
void draw(){
consumingClouds();
confettiTrail();
shootingStar();
}

void consumingClouds(){
cloudX = random(width);
cloudY = random(height);
stroke(135,206,235,20);
fill(135,206,235,70);
ellipse(cloudX,cloudY,200,100);
}

void confettiTrail(){
if (mousePressed) {
float r = random(0,255);
float g = random(0,255);
float b = random(0,255);
float a = random(0,255);
fill(r,g,b,a); //fill(random(255),random(255),random(255),random(255));
ellipse(mouseX,mouseY,30,30);
}
}

void shootingStar(){
x = x + xspeed;
y = y + yspeed;

if (x > width || x < 0){
xspeed = xspeed * -1;
}

if (y > height || y < 0){
yspeed = yspeed * -1;
}

if(mousePressed){
stroke(255,215,10,100);
fill(255,215,10,100);
beginShape();
vertex(x, y-50);
vertex(x+14,y-20);
vertex(x+47,y-15);
vertex(x+23,y+7);
vertex(x+29,y+40);
vertex(x, y+25);
vertex(x-29,y+40);
vertex(x-23,y+7);
vertex(x-47,y-15);
vertex(x-14,y-20);
endShape(CLOSE);
}
}

Leave a Reply