Rotation when mouseClicked
in
Programming Questions
•
6 months ago
Hello
I'm having problems getting my "wheel" to rotate when you click on your mouse. my first thought was to get the wheel to rotate and to stop at a random position but right i would be happy just til get the wheel to rotate 360 degrees and stay in that position.
//PImage Knap
PImage img;
float x = 100;
float y = 100;
float xspeed = 2;
float yspeed = 4;
void setup () {
size(400, 400);
img=loadImage("knap.png");
}
void draw()
{
background(0);
image(img, 0, 0);
}
void mouseClicked(){
x = x + xspeed;
y = y + yspeed;
translate(width/2, height/2);
rotate(PI/radians(x));
translate(-img.width/2, -img.height/2);
xspeed = xspeed * -1 ;
yspeed = yspeed * -1 ;
image(img, 0, 0);
}
and yeah im pretty new at this so I hope it's hopeless what I made. I really hope someone can help
1