# Help! need assistance on including a void in an if statement? is it possible?

**URL:** <https://discourse.processing.org/t/help-need-assistance-on-including-a-void-in-an-if-statement-is-it-possible/27978>\
**Category:** Coding Questions\
**Created:** [February 21, 2021, 4:26pm UTC](https://discourse.processing.org/t/help-need-assistance-on-including-a-void-in-an-if-statement-is-it-possible/27978 "2021-02-21T16:26:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbie1](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@newbie1](https://discourse.processing.org/u/newbie1)\
**Post date:** [February 21, 2021, 4:26pm UTC](https://discourse.processing.org/t/help-need-assistance-on-including-a-void-in-an-if-statement-is-it-possible/27978/1 "2021-02-21T16:26:58Z")

</div>

Hi, this is something that I am working on for a college project, is it possible to put the void eyes() into the snowman head?

void setup() {  
size(1280, 720);  
background(55, 126, 231);  
fill(255);  
rect(0, 610, width, height/6);  
fill(29, 157, 25);  
triangle(0, 610, 170, 120, 610, 610);  
fill(29, 107, 25);  
triangle(0, 610, 250, 150, 610, 610);  
fill(29, 157, 115);  
triangle(0, 610, 70, 220, 610, 610);  
fill(129, 127, 125);  
triangle(50, 610, 370, 150, 610, 610);  
frameRate(25);

//Littleforest using a for loop  
for (int x = 1; x \< 11; x++)  
{  
fill(33, 79, 24);  
triangle(320 + 69 \* x, 610, 330 + 69 \* x, 500, 350 + 69 \* x, 610);  
fill(133, 209, 24);  
triangle(370 + 75 \* x, 610, 380 + 75 \* x, 510, 400 + 75 \* x, 610);  
fill(29, 167, 25);  
triangle(460 + 50 \* x, 610, 470 + 50 \* x, 520, 490 + 50 \* x, 610);  
fill(51, 105, 30);  
triangle(420 + 60 \* x, 610, 430 + 60 \* x, 510, 450 + 60 \* x, 610);  
fill(34, 139, 34);  
triangle(390 + 55 \* x, 610, 400 + 55 \* x, 490, 420 + 55 \* x, 610);  
}  
}

void draw() {//sets up the event listener for all the events below  
eye(150, 360);  
eye(170, 350);

if (mousePressed) {  
if (mouseButton ==LEFT) {  
stroke(1);  
fill(255, 255, 250);  
ellipse(150, 580, 180, 180); //body  
} else if (mouseButton==CENTER)  
{  
stroke(1);  
fill(255, 255, 250);  
ellipse(150, 480, 140, 140); //Middle  
} else if (mouseButton==RIGHT) {// head

```
  stroke(1);
  fill(255, 255, 250);
  ellipse(150, 380, 110, 110); 
  fill(0);

  //ellipse(130, 360, 10, 10);//left eye
  // ellipse(170, 360, 10, 10); //right eye
  fill(255, 50, 0);
  triangle(160, 370, 160, 400, 140, 370);//nose
  ellipse(120, 400, 10, 10);//smileleft
  ellipse(130, 410, 10, 10);//smileleft
  ellipse(140, 415, 10, 10);//smileright
  ellipse(180, 400, 10, 10);//smileleft
  ellipse(150, 415, 10, 10);//smileright
  ellipse(160, 415, 10, 10);//smileright
  ellipse(170, 410, 10, 10);//smileright
}

```

}  
}  
void eye(int x,int y){  
fill(255);  
ellipse(x,y,12,12);  
fill(0);  
ellipse(x+2,y,6,6);  
fill(255);  
ellipse(x+3,y-1,1,1);  
}

void mouseMoved()  
{  
fill(25, 25, 25);  
textSize(50);  
text(“Do you want to build a Snowman?”, width/3, height/4);  
}  
void mousePressed() {

fill(12, 45, 255);  
textSize(30);  
text(“Did you just Sing that??”, width/9, height/9);  
}

void mouseDragged() {  
noStroke();  
fill(255);  
ellipse(random(mouseX), random(mouseY), 5, 5);  
textSize(100);  
fill(60, 225, 225);  
text(“Let it Snow”, width/2, height/2);  
}

void mouseClicked () {  
}

---

<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:** [February 21, 2021, 4:58pm UTC](https://discourse.processing.org/t/help-need-assistance-on-including-a-void-in-an-if-statement-is-it-possible/27978/2 "2021-02-21T16:58:59Z")

</div>

Yes you can call eye from snowman function

---

<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:** [February 21, 2021, 5:24pm UTC](https://discourse.processing.org/t/help-need-assistance-on-including-a-void-in-an-if-statement-is-it-possible/27978/3 "2021-02-21T17:24:23Z")

</div>

Looks very nice! Great Sketch!

Here is the Sketch with eyes in the if-clause. The function eye() gets called from inside the if-clause.

Hey, and welcome to the forum!

Great to have you here!

Chrisir

```auto

void setup() {
  size(1280, 720);

  background(55, 126, 231);
  fill(255);
  rect(0, 610, width, height/6);
  fill(29, 157, 25);
  triangle(0, 610, 170, 120, 610, 610);
  fill(29, 107, 25);
  triangle(0, 610, 250, 150, 610, 610);
  fill(29, 157, 115);
  triangle(0, 610, 70, 220, 610, 610);
  fill(129, 127, 125);
  triangle(50, 610, 370, 150, 610, 610);
  frameRate(25);

  //Little forest using a for loop
  for (int x = 1; x < 11; x++)
  {
    fill(33, 79, 24);
    triangle(320 + 69 * x, 610, 330 + 69 * x, 500, 350 + 69 * x, 610);
    fill(133, 209, 24);
    triangle(370 + 75 * x, 610, 380 + 75 * x, 510, 400 + 75 * x, 610);
    fill(29, 167, 25);
    triangle(460 + 50 * x, 610, 470 + 50 * x, 520, 490 + 50 * x, 610);
    fill(51, 105, 30);
    triangle(420 + 60 * x, 610, 430 + 60 * x, 510, 450 + 60 * x, 610);
    fill(34, 139, 34);
    triangle(390 + 55 * x, 610, 400 + 55 * x, 490, 420 + 55 * x, 610);
  }
}

void draw() {

  //sets up the event listener for all the events below

  if (mousePressed) {
    if (mouseButton == LEFT) {
      //body
      stroke(1);
      fill(255, 255, 250);
      ellipse(150, 580, 180, 180);
    } else if (mouseButton == CENTER) {
      // middle
      stroke(1);
      fill(255, 255, 250);
      ellipse(150, 480, 140, 140);
    } else if (mouseButton == RIGHT) {
      // head
      stroke(1);
      fill(255, 255, 250);
      ellipse(150, 380, 110, 110); 
      fill(0);

      //ellipse(130, 360, 10, 10);//left eye
      // ellipse(170, 360, 10, 10); //right eye
      fill(255, 50, 0);
      triangle(160, 370, 160, 400, 140, 370);//nose
      ellipse(120, 400, 10, 10);//smileleft
      ellipse(130, 410, 10, 10);//smileleft
      ellipse(140, 415, 10, 10);//smileright
      ellipse(180, 400, 10, 10);//smileleft
      ellipse(150, 415, 10, 10);//smileright
      ellipse(160, 415, 10, 10);//smileright
      ellipse(170, 410, 10, 10);//smileright

      eye(150, 360);
      eye(170, 350);
    }
  }
}

void eye(int x, int y) {
  fill(255);
  ellipse(x, y, 12, 12);
  fill(0);
  ellipse(x+2, y, 6, 6);
  fill(255);
  ellipse(x+3, y-1, 1, 1);
}

void mouseMoved() {
  fill(25, 25, 25);
  textSize(50);
  text("Do you want to build a Snowman?", width/3, height/4);
}

void mousePressed() {
  fill(12, 45, 255);
  textSize(30);
  text("Did you just Sing that??", width/9, height/9);
}

void mouseDragged() {
  noStroke();
  fill(255);
  ellipse(random(mouseX), random(mouseY), 5, 5);
  textSize(100);
  fill(60, 225, 225);
  text("Let it Snow", width/2, height/2);
}

void mouseClicked () {
}
//

```

---

<div class="post-metadata">

**Author:** ![newbie1](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@newbie1](https://discourse.processing.org/u/newbie1)\
**Post date:** [February 21, 2021, 5:38pm UTC](https://discourse.processing.org/t/help-need-assistance-on-including-a-void-in-an-if-statement-is-it-possible/27978/4 "2021-02-21T17:38:52Z")

</div>

Thank you was pulling out my hair on that 😄

---

<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:** [February 21, 2021, 6:19pm UTC](https://discourse.processing.org/t/help-need-assistance-on-including-a-void-in-an-if-statement-is-it-possible/27978/5 "2021-02-21T18:19:37Z")

</div>

Of course you could display the sun and when you click on the sun, eyes appear… 😉
