# Create very few particles on a particle system

**URL:** <https://discourse.processing.org/t/create-very-few-particles-on-a-particle-system/31478>\
**Category:** Coding Questions\
**Created:** [July 28, 2021, 11:35pm UTC](https://discourse.processing.org/t/create-very-few-particles-on-a-particle-system/31478 "2021-07-28T23:35:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![avivtech](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/avivtech/32/13981_2.png) [@avivtech](https://discourse.processing.org/u/avivtech)\
**Post date:** [July 28, 2021, 11:35pm UTC](https://discourse.processing.org/t/create-very-few-particles-on-a-particle-system/31478/1 "2021-07-28T23:35:43Z")

</div>

Hi,

I am trying to create bubbles simulation. I want a bubble to appear every 1-2 sec. and to burst at the bottom of the canvas.  
I have this so far: [https://codepen.io/Avivtech/pen/yLbKooV](https://codepen.io/Avivtech/pen/yLbKooV)

I can not get to create only few bubbles…  
When I move the `for` loop to the `draw` function it creates A LOT of bubbles ☹

Help 😃

---

<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:** [July 29, 2021, 7:09am UTC](https://discourse.processing.org/t/create-very-few-particles-on-a-particle-system/31478/2 "2021-07-29T07:09:07Z")

</div>

You can also check whether a balloon has left the screen and then give it a new y position

OR you remove balls when they left and when the number is smaller 30 use push

---

<div class="post-metadata">

**Author:** ![avivtech](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/avivtech/32/13981_2.png) [@avivtech](https://discourse.processing.org/u/avivtech)\
**Post date:** [July 29, 2021, 7:42am UTC](https://discourse.processing.org/t/create-very-few-particles-on-a-particle-system/31478/3 "2021-07-29T07:42:28Z")

</div>

Hey @Chrisir

Thank you for the reply!  
My problem is with creation of bubbles - how to constantly create bubbles on a very slow pace

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [July 29, 2021, 9:39am UTC](https://discourse.processing.org/t/create-very-few-particles-on-a-particle-system/31478/4 "2021-07-29T09:39:22Z")

</div>

Hello,

Give this a try in draw():

`if( frameCount%60 == 0 ) particles.push(new Particle()); //This will add one every 60 frames which is around 1 sec.`

Look up the modulo (%) operator to understand how this works.  
This is a useful function and worthy of exploration!

There are other ways to time events.

References:

> **[reference | p5.js](https://p5js.org/reference/#/p5/setup)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

> **[reference | p5.js](https://p5js.org/reference/#/p5/draw)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

> **[reference | p5.js](https://p5js.org/reference/#/p5/frameCount)**
>
> p5.js a JS client-side library for creating graphic and interactive experiences, based on the core principles of Processing.

[![](https://img.youtube.com/vi/r5Iy3v1co0A/maxresdefault.jpg "Guest Tutorial #6: The Modulo Operator with Golan Levin") ](https://www.youtube.com/watch?v=r5Iy3v1co0A)

`:)`
