Listing 10. Source code for the act2Action method.

Penguins02's Code

Created by: Dick Baldwin

world

Methods

  public void act2Action ( ) {
    
       // Mama penguin and baby penguin walk to edge of hole
  // and look in
  doTogether {
       doInOrder {
       mama.walking ( ( ( ( mama .distanceTo( hole ) ) - ( ( ( subject = hole .getWidth() ) / 2 ) ) ) ) );
  mama.head .turn( FORWARD , 0.1 revolutions );
  }
  // Could use some anti-collision logic to make sure
  // mama and baby don't collide at edge of hole
  doInOrder {
       baby.walking ( ( ( ( baby .distanceTo( hole ) ) - ( ( ( subject = hole .getWidth() ) / 2 ) ) ) ) );
  baby.head .turn( FORWARD , 0.1 revolutions );
  }
  }
  }