switch() doesn't work in draw() ?
in
Programming Questions
•
1 year ago
So I am trying to make a abstract clock and basically what I'm doing is in the code below. At each specific time i want the number of circles to corespond to the time and to update each time draw runs but it doesn't update and I cant seem to figure it out. The Second function goes on for a while up to case 59 as does the minute function and the hour function goes to 23. I had assumed that everytime draw() would run it would call the Second, Minute and Hour functions and update the dots but it doesnt seem to work. Any help on how to get it to update in real time would be greatly appreciated.
int s = second();
int m = minute();
int h = hour();
void setup() {
size(460,100);
}
void draw() {
background(0);
//Each white circle is 1 second
Second();
//Each green circle is 1 minute
Minute();
//Each red circle is 1 hour
Hour();
}
void Second() {
fill(255);
switch(s) {
case 0:
break;
case 1:
ellipse(10,20,10,10);
break;
case 2:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
break;
case 3:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
ellipse(40,20,10,10);
break;
case 4:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
ellipse(40,20,10,10);
ellipse(55,20,10,10);
break;
case 5:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
ellipse(40,20,10,10);
ellipse(55,20,10,10);
ellipse(70,20,10,10);
break;
}
}
int s = second();
int m = minute();
int h = hour();
void setup() {
size(460,100);
}
void draw() {
background(0);
//Each white circle is 1 second
Second();
//Each green circle is 1 minute
Minute();
//Each red circle is 1 hour
Hour();
}
void Second() {
fill(255);
switch(s) {
case 0:
break;
case 1:
ellipse(10,20,10,10);
break;
case 2:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
break;
case 3:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
ellipse(40,20,10,10);
break;
case 4:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
ellipse(40,20,10,10);
ellipse(55,20,10,10);
break;
case 5:
ellipse(10,20,10,10);
ellipse(25,20,10,10);
ellipse(40,20,10,10);
ellipse(55,20,10,10);
ellipse(70,20,10,10);
break;
}
}
1