# Question on how to define a boolean

**URL:** <https://discourse.processing.org/t/question-on-how-to-define-a-boolean/36546>\
**Category:** Coding Questions\
**Created:** [April 23, 2022, 1:46pm UTC](https://discourse.processing.org/t/question-on-how-to-define-a-boolean/36546 "2022-04-23T13:46:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hannymymy](https://avatars.discourse-cdn.com/v4/letter/h/dbc845/32.png) [@hannymymy](https://discourse.processing.org/u/hannymymy)\
**Post date:** [April 23, 2022, 1:46pm UTC](https://discourse.processing.org/t/question-on-how-to-define-a-boolean/36546/1 "2022-04-23T13:46:33Z")

</div>

Hi, I am very new to coding and have a question regarding the code below. I’d like it to grow the circle with the count\_up, but when one of the circles reaches the max width to go back again (in a way to loop the action) I was trying to make this happen witjh if…else but I don’t know how I should define the if so that it’s working.  
Thank you so much in advance!!

```auto
int count_up = 0;
int count_down = 500;

void setup() 
{
  size(500, 500);
}

void draw() { 

  if ( count_up < width/2) {
  
fill(170, 172, 204, 150);
  circle(width/2, height/2, count_up);
  count_up += 1;
  
  fill(250, 191, 171, 100);
  circle(width/2, height/2, count_down);
  count_down -= 2;
  }
 else {
    fill(170, 172, 204, 150);
  circle(width/2, height/2, count_up);
  count_up -= 1;
  
  fill(250, 191, 171, 100);
  circle(width/2, height/2, count_down);
  count_down += 2;
  }
}

```

This is what the code is supposed to do but without growing indefinetly:

```auto
int count_up = 0;
int count_down = 500;

void setup() 
{
  size(500, 500);
}

void draw() { 
  background (233);
fill(170, 172, 204, 150);
  circle(width/2, height/2, count_up);
  count_up += 1;
 
  fill(250, 191, 171, 100);
  circle(width/2, height/2, count_down);
  count_down -= 2;
 
 }

```

---

<div class="post-metadata">

**Author:** ![Divitiacus](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@Divitiacus](https://discourse.processing.org/u/Divitiacus)\
**Post date:** [April 23, 2022, 1:54pm UTC](https://discourse.processing.org/t/question-on-how-to-define-a-boolean/36546/2 "2022-04-23T13:54:08Z")

</div>

You have two states: the count going up and the count going down. You need a variable to define these states, then you have to check for it to either count up or down.  
Finally when your count reaches the minimum and the maximum of your counting, you have to switch.

You can use a boolean, which is just true or false, to record the two states.
