Rotate on Command

That’s probaly because when you rotate 90 degrees and then 180 degree, they look exactly the same. Try instead of float anglechgU=HALF_PI/90; better float anglechgU=HALF_PI/76; so it’s not 90, then 180… which would look exactly the same…

my idea

here is my idea

boolean rotateU=false;
boolean rotateD=false;
boolean rotateL=false;
boolean rotateR=false;

float angleX=0;
float angleY=10;

float anglechgU=HALF_PI/90;
float anglechgD=HALF_PI/90;
float anglechgL=HALF_PI/90;
float anglechgR=HALF_PI/90;


float max1Add =HALF_PI/2.9; 
float max1=max1Add; 

void setup() {
  size(1000, 1000, P3D);
  noFill();
  stroke(255);
  println("press w to rotate ");
}

void draw() {
  background(0);

  fill(255);
  text("Use w to move on", 19, 19);

  lights(); 

  translate(width/2, height/2);
  rotateX(angleX);

  if (rotateU) {
    angleX+=anglechgU;

    if (angleX>=max1) {
      anglechgU=0;
      rotateU=false;
      max1+=max1Add;
    } else {
      //
    }
  }

  fill(255, 0, 0); 
  box(500);
}

void keyPressed() {
  if (key=='w') {
    rotateU=true;
    anglechgU=HALF_PI/90;
  }
}
3 Likes