# While loop is not working in processing

**URL:** <https://discourse.processing.org/t/while-loop-is-not-working-in-processing/29954>\
**Category:** Beginners\
**Created:** [May 8, 2021, 3:01am UTC](https://discourse.processing.org/t/while-loop-is-not-working-in-processing/29954 "2021-05-08T03:01:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nothingelse](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nothingelse](https://discourse.processing.org/u/nothingelse)\
**Post date:** [May 8, 2021, 3:01am UTC](https://discourse.processing.org/t/while-loop-is-not-working-in-processing/29954/1 "2021-05-08T03:01:07Z")

</div>

I am beginner in processing, just started few days ago. I am learning while loop now but when i run the program, while loop does not seem to be working. I tried so much but still don’t know what problem is occuring

```auto
float circleX = 320;
float circleY = 50;
float speed = 1;
void setup()
{
  size(640,360);
}

void draw(){
  background(50);
  while(circleY < height)
  {
    circle(circleX, circleY, 10);
    circleY += speed;
    speed += 0.3;
  }
}

```

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [May 8, 2021, 3:12am UTC](https://discourse.processing.org/t/while-loop-is-not-working-in-processing/29954/2 "2021-05-08T03:12:59Z")

</div>

@nothingelse  
Please post your code so we can see where the issue is…

---

<div class="post-metadata">

**Author:** ![nothingelse](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nothingelse](https://discourse.processing.org/u/nothingelse)\
**Post date:** [May 8, 2021, 3:24am UTC](https://discourse.processing.org/t/while-loop-is-not-working-in-processing/29954/3 "2021-05-08T03:24:02Z")

</div>

I posted my code now, please tell me the solution

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [May 8, 2021, 3:33am UTC](https://discourse.processing.org/t/while-loop-is-not-working-in-processing/29954/4 "2021-05-08T03:33:35Z")

</div>

It looks like you’re trying to move a circle until it hits the bottom of the window. While the circle isn’t at the bottom yet, you want to move it down, and it speeds up.

The problem is that you don’t need a while loop to do this! Confusing, right? You already have a loop, and that loop is `draw()` being called over and over. Consider these changes:

```auto
float circleX = 320;
float circleY = 50;
float speed = 1;
void setup() {
  size(640,360);
}

void draw(){
  background(50);

  if (circleY < height) {
    circleY += speed;
    speed += 0.3;
  }

  ellipse(circleX, circleY, 10, 10);
}

```

Also note that the function to draw a circle is actually `ellipse()`.

---

<div class="post-metadata">

**Author:** ![nothingelse](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nothingelse](https://discourse.processing.org/u/nothingelse)\
**Post date:** [May 8, 2021, 3:36am UTC](https://discourse.processing.org/t/while-loop-is-not-working-in-processing/29954/6 "2021-05-08T03:36:38Z")

</div>

so what does circle function is mode for mainly?

---

<div class="post-metadata">

**Author:** ![nothingelse](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nothingelse](https://discourse.processing.org/u/nothingelse)\
**Post date:** [May 8, 2021, 3:37am UTC](https://discourse.processing.org/t/while-loop-is-not-working-in-processing/29954/7 "2021-05-08T03:37:38Z")

</div>

Thanks but if i want to use while loop later in future so what will i do at that time?

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [May 8, 2021, 3:49pm UTC](https://discourse.processing.org/t/while-loop-is-not-working-in-processing/29954/8 "2021-05-08T15:49:51Z")

</div>

For introductory guidance, this type of question can be answered by reading the Processing reference, linked below:

> **[Reference](https://processing.org/reference/)**
>
> Find further documentation of the Processing language

And there are several tutorials on YouTube. You could start here:

[![](https://img.youtube.com/vi/RtAPBvz6k0Y/hqdefault.jpg "6.1: While Loop - Processing Tutorial") ](https://www.youtube.com/watch?v=RtAPBvz6k0Y)

And here:

[![]( " - YouTube") ](https://www.youtube.com/watch?v=k-32ZfMcNbQ)

Good luck! 🙂

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [May 8, 2021, 3:59pm UTC](https://discourse.processing.org/t/while-loop-is-not-working-in-processing/29954/9 "2021-05-08T15:59:08Z")

</div>

For a quicker clarification, refer to the reference for this type of question. About the circle() can be found here:

[https://processing.org/reference/circle\_.html](https://processing.org/reference/circle_.html)

---

<div class="post-metadata">

**Author:** ![nothingelse](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nothingelse](https://discourse.processing.org/u/nothingelse)\
**Post date:** [May 8, 2021, 6:09pm UTC](https://discourse.processing.org/t/while-loop-is-not-working-in-processing/29954/10 "2021-05-08T18:09:32Z")

</div>

I am learning processing from coding train channel which mention in the first video.
