Rotate on Command

I have attempted to integrate what you have suggested, but it may not be the way you thought of it.

boolean rotate=false;
float angle=0;
void setup(){
  size(1000,1000,P3D);
  background(0);
  smooth();
  noFill();
  stroke(255);
}
void draw(){
  background(0);
  translate(width/2,height/2);
  box(500);
  if(rotate){
    rotateY(angle);
    angle+=0.0001;
  }
}
void keyPressed(){
  if(key==CODED){
    if(keyCode==UP){
      rotate=true;
    }
  }
}

I thought that by making the rotateY depend on the angle variable. I made it so that when rotate is true, the angle variable starts to increase in value, and the rotateY would rotate at the angle variable. However, it did not work. I think that it has something to do with the rotateY and the angle value.

1 Like