Variable Problem
in
Programming Questions
•
5 months ago
Hi there,
I was wondering why the 'a' variable doesn't change in my sketch. The 'a' variable is the value for the
fill() of an
ellipse() and when the 2 ellipses intercept and the time reaches 2000 milliseconds then the value of 'a' should change from 255 to 0 but it doesn't.
Any ideas or help on this problem would be greatly appreciated.
Thanks
// Here is the code
int begintime = 2;
int window = 0;
int start;
float f,g,h,j;
int a = 255;
void setup() {
size(400, 400);
f = 50;
g = 50;
h = 40;
j = 30;
}
void draw() {
background(255);
fill(a);
ellipse(f,g,h,h);
ellipse(mouseX,mouseY,30,30);
if (dist(f,g,mouseX,mouseY) < (h/2)+(j/2)) {
a = 0;
int ms = millis()-start;
println(ms);
// int sec = frameCount/60;
int sec = ms/1000;
int timer = begintime - sec;
if (timer <= 0) {
a = 0;
println("HELLO");
// rect(300,300,100,100);
}
}
else {
start = millis(); }
a = 255;
}
1