help: beginner here!!
in
Programming Questions
•
1 year ago
hey guys! so I'm new in programming and processing so bare with me please!
I need to make an ellipse that touches every corner of the screen and change its color randomly. But I can't figure out how to make the color change just one time when it touches the corner. I'm using fill random but it changes like crazy!! haha PLEASE excuse me for my crappy English. Thanks everyone! Here's my code:
I need to make an ellipse that touches every corner of the screen and change its color randomly. But I can't figure out how to make the color change just one time when it touches the corner. I'm using fill random but it changes like crazy!! haha PLEASE excuse me for my crappy English. Thanks everyone! Here's my code:
int fl;
int x;
int y;
void setup(){
size(500,500);
x=30;
y=30;
fl=0;
}
void draw() {
background(#ffffff);
ellipse(x,y,50,50);
//up
if (fl==0){
x=x+1;
}
if (x > 470){
fill(random(0,255),random(0,255),random(0,255));
fl=1;
}
//right
if( fl==1){
y=y+1;
}
if(y > 470){
fill(random(0,255),random(0,255),random(0,255));
fl=2;
}
//down
if(fl==2){
fill(random(0,255),random(0,255),random(0,255));
x=x-1;
}
if(x < 30){
fill(random(0,255),random(0,255),random(0,255));
fl=3;
}
//left
if(fl==3){
y=y-1;
}
if(y < 30){
fill(random(0,255),random(0,255),random(0,255));
fl=0;
}
}
1