falling shapes after mouse click function
in
Programming Questions
•
3 years ago
i've written this program that draws iterated rectangles with various sizes depending on on how fast you drag the mouse. What i'm having trouble doing is making the squares fall and disappear from the screen after a second or so after the squares are drawn. I've experimented with if (millis() > 3000) {x++;} to try and move the y coordinate of the rectangles three seconds after they are drawn. obviously i've tried it several different ways within the structure and it doesn't seem to work. i could be possibly using the wrong approach to this or i may be overlooking something really obvious. here is my code without any code to try and drop the rectangles, let me no what you think.
//program that draws random squares of color when mouse is moved. squares change size with how fast mouse moves.squares float to bottom three seconds after they are drawn.
void setup(){
size(400,400);
background(255);
}
void draw(){
for(int g=0;g<400;g++)
Squares(g*400, 400,2);
}//parameters 1 and 2 and 3
void Squares(float rx, float ry, float rz)
{
frameRate(60);
if(mousePressed){
float w=random(rx);
float x=random(ry);
float z=random(rz);
float s1 = dist(mouseX,mouseY, pmouseX,pmouseY) + 1;
float s2 = dist(mouseX,mouseY, pmouseX,pmouseY) + 1;
float t=random(255);
float u=random(255);
float v=random(255);
noStroke();
fill(t,u,v,t);
strokeWeight(z);
stroke(t,u,v);
for(int a=0;a<30;a++){
rect(w+a,x-a, s1, s2);}
}}
1