I need to get rotating barbell to follow the mouse around the window.
in
Programming Questions
•
2 years ago
Hi, I am in a beginner programming class, my final exam is Monday, when going over the review, I am having trouble with this one problem.. I need to make a barbell(line with an ellipse at each end) that rotates around its center, follow the mouse around the window. I have put together code for the barbell to rotate in the center of the screen. Any attempt to get the barbell to follow the mouse has been a disaster to the code... Any help or tips would be appreciated thank you...
int lineCenterX = 150;
int lineCenterY = 150;
int lineRadius = 30;
float angle = 0.0;
void setup ()
}
size(300, 300, P3D);
background(150);
fill(150, 170, 200);
{
void draw ()
}
background(150);
if (lineCenterX > 0)
}
translate(lineCenterX, lineCenterY);
rotate(radians(angle));
line(-1*lineRadius, 0, lineRadius, 0);
ellipse(-1*lineRadius, 0, 8, 8);
ellipse(lineRadius, 0, 8, 8);
angle += 0.8;
{
{
1