# How move the penguin without the arms flying off?

**URL:** <https://discourse.processing.org/t/how-move-the-penguin-without-the-arms-flying-off/48065>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [March 10, 2026, 6:08am UTC](https://discourse.processing.org/t/how-move-the-penguin-without-the-arms-flying-off/48065 "2026-03-10T06:08:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![False](https://avatars.discourse-cdn.com/v4/letter/f/ac8455/32.png) [@False](https://discourse.processing.org/u/False)\
**Post date:** [March 10, 2026, 6:08am UTC](https://discourse.processing.org/t/how-move-the-penguin-without-the-arms-flying-off/48065/1 "2026-03-10T06:08:27Z")

</div>

‘’‘processing’‘’  
//position  
float xorigin, yorigin;  
//origin position  
float xPos, yPos;  
//penguin position  
//wing animation  
float wingangle;  
float wingspeed;  
float upperwinglimit;  
float lowerwinglimit;  
boolean winglimitBO;  
void setup() {  
//varibles

//position  
xPos = 0;  
yPos = 0;  
xorigin = 400;  
yorigin = 400;

//Wings  
wingangle = PI/16;  
upperwinglimit=PI/12;  
lowerwinglimit=PI/20;  
wingspeed = PI/4096;  
size(800,800);  
void draw() {

//setup  
translate(xorigin,yorigin);  
.  
pushMatrix();  
rotate(wingangle);  
ellipse(xPos-90,yPos+120,40,180); // wing left  
popMatrix();

pushMatrix();  
rotate(-wingangle);  
ellipse(xPos+90,yPos+120,40,180); // wing right  
popMatrix();  
.  
if (wingangle\>upperwinglimit) {  
winglimitBO = false;  
}

if (winglimitBO) {  
wingangle = wingangle + wingspeed;  
}  
if (winglimitBO == false) {  
wingangle = wingangle - wingspeed;  
}

if (wingangle\<lowerwinglimit) {  
winglimitBO = true;  
}

This isn’t the full code but it is all the code relating to the position/angle of the wings the wings flap up and down like they are meant to when stationary but if you change the X position of the penguin through something such as xPos += 1; then the wings will start moving up and down without any change to the Y axis being made and I cant figure out why. I was wondering if there is an error or a way to fix this?

---

<div class="post-metadata">

**Author:** ![EricRogerGarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ericrogergarcia/32/21029_2.png) [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Post date:** [March 15, 2026, 11:11am UTC](https://discourse.processing.org/t/how-move-the-penguin-without-the-arms-flying-off/48065/2 "2026-03-15T11:11:45Z")

</div>

Maybe the position of the wings should not be calculated based on (xPos, yPos) which must be I think the position of the total image. Thus, it would be enough to change the position of the whole by a translate(xPos,yPos) before drawing everything including the wings.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 24, 2026, 8:02am UTC](https://discourse.processing.org/t/how-move-the-penguin-without-the-arms-flying-off/48065/6 "2026-03-24T08:02:52Z")

</div>

**in your version:**

since you use `translate(xorigin,yorigin);` the Pinguin is at pos xorigin,yorigin.

xpos and ypos can stay 0, it’s not in use because you use translate.

To move the pinguin, change xorigin,yorigin.

**here is my version**

```auto

// position Pinguin
float xPinguin, yPinguin;

// position / NOT IN USE / always == 0
float xPos, yPos;

//wing animation
float wingangle;
float wingspeed;
float upperwinglimit;
float lowerwinglimit;

boolean winglimitBO;

// -------------------------------------------------------------------------------

void setup() {
  size(800, 800);

  //position
  xPos = 0;
  yPos = 0;
  xPinguin = 2;
  yPinguin = 400-322;

  //Wings
  wingangle = PI/16;
  upperwinglimit=PI/12*2;
  lowerwinglimit=PI/20;
  wingspeed = PI/4096*3;

  background (111);
}

void draw() {
  background (111);

  // -----------------------------
  // move entire Pinguin
  xPinguin++;

  // -----------------------------
  // display Pinguin
  translate(xPinguin, yPinguin);

  pushMatrix();
  rotate(wingangle);
  ellipse(xPos-90, yPos+120, 40, 180); // wing left
  popMatrix();

  pushMatrix();
  rotate(-wingangle);
  ellipse(xPos+90, yPos+120, 40, 180); // wing right
  popMatrix();

  // -----------------------------
  // move Wings

  if (wingangle>upperwinglimit) {
    winglimitBO = false;
  }

  if (winglimitBO) {
    wingangle = wingangle + wingspeed;
  } else if (! winglimitBO) { // FALSE
    wingangle = wingangle - wingspeed;
  }

  if (wingangle<lowerwinglimit) {
    winglimitBO = true;
  }
}
//

```
