Trying to make a "clock", and have to use a class with 2 methods. I have it all the way to where I am trying to get the objects to move with the clock. I cannot seem to get it figured out. can someone help me. Keep in mind this is for a into programing class.
ClockHand msh, sh, mh, hh;
float s;
float m;
float h;
float St;
float Mi;
float ml;
float m;
float h;
float St;
float Mi;
float ml;
void setup() {
size(500, 500);
background(0);
noStroke();
ml = millis();
Mi = map (ml, 0, (1000 * 60), 0, TWO_PI) + St;
//s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI; //subtract HALF_PI to make them start at the top. radians start to the right TWO_PI-Half_pi
m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) - HALF_PI;
h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI;
size(500, 500);
background(0);
noStroke();
ml = millis();
Mi = map (ml, 0, (1000 * 60), 0, TWO_PI) + St;
//s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI; //subtract HALF_PI to make them start at the top. radians start to the right TWO_PI-Half_pi
m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) - HALF_PI;
h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI;
s = second(); //subtract HALF_PI to make them start at the top. radians start to the right TWO_PI-Half_pi
m = minute();
h = hour();
m = minute();
h = hour();
msh = new ClockHand (250, 250, 5, 50, 0, ml);
sh = new ClockHand (250, 250, 15, 75, 0, Mi);
mh = new ClockHand (250, 250, 35, 100, 0, m);
hh = new ClockHand(250, 250, 50, 150, 0, h);
}
void draw() {
background(0);
msh.display();
msh.time();
sh.display();
sh.time();
mh.display();
mh.time();
hh.display();
hh.time();
}
background(0);
msh.display();
msh.time();
sh.display();
sh.time();
mh.display();
mh.time();
hh.display();
hh.time();
}
class ClockHand {
float x, y;
float diameter;
float transX;
float transY;
float time;
float x, y;
float diameter;
float transX;
float transY;
float time;
ClockHand (float xi, float yi, float di, float tx, float ty, float ti) {
x = xi;
y = yi;
diameter = di;
transX = tx;
transY = ty;
time = ti;
}
x = xi;
y = yi;
diameter = di;
transX = tx;
transY = ty;
time = ti;
}
void display() {
ellipse(x, y, diameter, diameter);
translate(transX, transY);
}
void time() {
}
}
ellipse(x, y, diameter, diameter);
translate(transX, transY);
}
void time() {
}
}
1