How to rotate Pacman's animation face

hi guys, I am having trouble reversing the pacmans face when moving pacman backwards, any ideas?
heres the code i’ve been working on for my homework:

boolean pacopen = true;
float pacwidth = 0;
float mouthclose = TWO_PI/180;
int x;
int y;
int direction;
int keys;
void setup() {
  size(800, 200);
  background(0);
  y = height/2;
  x = width/2;
  direction = 6;
}
void keyPressed () {
  if (key== ' ') {
    keys++;
  }
}
void draw() {
  if (keys == 0|| keys %2 == 0) {
    background(0);
    fill(255, 204, 0);

    if (pacopen == true) {
      pacwidth += mouthclose;
    } 
    else {
      pacwidth -= mouthclose;
    }
    if (pacwidth >= TWO_PI/8 || pacwidth <=0) {
      pacopen = !pacopen;
    }
    arc(x, y, 40, 40, 0+pacwidth, TWO_PI-pacwidth);
    fill(0);
    fill(0, 0, 255);
    rect(0, 50, 800, 10);
    rect(0, 140, 800, 10);
    x = (x + direction) % width;
  } 
  else {
    if (x <=0) {
      x = width;
    }
    background(0);
    fill(255, 204, 0);
    if (pacopen == true) {
      pacwidth += mouthclose;
    } else {
      pacwidth -= mouthclose;
    }
    if (pacwidth >= TWO_PI/8 || pacwidth <=0) {
      pacopen = !pacopen;
    }
    arc(x, y, 40, 40, 0+pacwidth, TWO_PI-pacwidth);
    fill(0);
    fill(0, 0, 255);
    rect(0, 50, 800, 10);
    rect(0, 140, 800, 10);
    x = (x-direction);
  }
}
1 Like

haha actually dont worry guys, i figured it out by adding radians(180) to the pacwidth and two pi pacwidth.I was so dumb thanks tho!

1 Like