# How to rotate Pacman's animation face

**URL:** <https://discourse.processing.org/t/how-to-rotate-pacmans-animation-face/44129>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [March 21, 2024, 7:58am UTC](https://discourse.processing.org/t/how-to-rotate-pacmans-animation-face/44129 "2024-03-21T07:58:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Challenger](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@Challenger](https://discourse.processing.org/u/Challenger)\
**Post date:** [March 21, 2024, 7:58am UTC](https://discourse.processing.org/t/how-to-rotate-pacmans-animation-face/44129/1 "2024-03-21T07:58:04Z")

</div>

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:

```auto
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);
  }
}

```

---

<div class="post-metadata">

**Author:** ![Challenger](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@Challenger](https://discourse.processing.org/u/Challenger)\
**Post date:** [March 21, 2024, 8:30am UTC](https://discourse.processing.org/t/how-to-rotate-pacmans-animation-face/44129/2 "2024-03-21T08:30:32Z")

</div>

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!
