How to integrate an if sentence with a function?
in
Programming Questions
•
6 months ago
In the below code, how do I make the circle change color when the mouseX is < 50? How do I use an if sentence inside a function?
void setup() {
size(300, 300);
noStroke();
smooth();
}
void draw() {
background(0);
circle(mouseX, mouseY, 30, 255);
}
void circle(int x, int y, int size, int b) {
fill(0, 0, b);
ellipse(x, y, size, size);
// How do I make the circle change color when the mouseX is < 50?
if(mouseX < 50) {
b = 50;
} else {
b = 255;
}
}
1