We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So i have this code that's is kinda working. My problem is when I release the key is that the square rotates a little backwards, is it a processing glitch or something about the resolution?
float theta = 0.01;
float rotated;
float ini = 0;
void setup() {
size(500,500);
}
void draw() {
background(255);
fill(0);
rectMode(CENTER);
translate(width/2, height/2);
if(keyPressed) {
if(keyCode == RIGHT) {
rotate(ini + theta);
theta = theta + 0.05;
rotated = theta;
}
}
if(theta >= 2*PI) theta = 0;
rotate(rotated);
rect(0, 0, 50, 50);
println(theta);
}
void keyReleased() {
ini = theta;
theta = 0;
}
Comments
here
Thanks!