# Apply wind force on this code

**URL:** https://discourse.processing.org/t/apply-wind-force-on-this-code/29322
**Category:** Coding Questions
**Created:** [April 13, 2021, 11:30am UTC](https://discourse.processing.org/t/apply-wind-force-on-this-code/29322 "2021-04-13T11:30:15Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Lolita](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@Lolita](https://discourse.processing.org/u/Lolita)
#### Post date: [April 13, 2021, 11:30am UTC](https://discourse.processing.org/t/apply-wind-force-on-this-code/29322/1 "2021-04-13T11:30:15Z")

</div>

Here is the code and Id apply wind force instead of friction,

```auto
int NrDisks = 120;
float Gravity = 0.03;
float Fri = -0.9;
Disk[] disks = new Disk[NrDisks];

void setup() {
  size(700, 700);
  for (int i = 0; i < NrDisks; i++) {
    disks [i] = new Disk(-random(height ), -random(width)/2, random(20, 20), i, disks );
  }
  noStroke();
  fill(255, 204);
}

void draw() {
  background(0);
  for (Disk disk : disks ) {
    disk.move();
    disk.display();
  }
}

class Disk {
  float r = random(255);
  float g = random(255);
  float b = random(255);

  float posx, posy;
  float diameter;
  float velx = -2;
  float vely = 2;
  int id;
  Disk[] others;

  Disk(float xin, float yin, float d, int idin, Disk[] oin) {
    posx = xin;
    posy = yin;
    diameter = d;
    id = idin;
    others = oin;
  } 

  void move() {
    vely += Gravity;
    posx -= velx;
    posy += vely;

    if (diameter/2 > width) {
      posx = width - diameter/2;
      velx *= Fri;
    } else if (posy - diameter > height) {
      posy = height - diameter;
      vely *= Fri;
    }
  }

  void display() {
    fill(r, g, b);
    ellipse(posx, posy, diameter, diameter);
  }
}

```

---

<div class="post-metadata">

### Author: ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)
#### Post date: [April 13, 2021, 11:35am UTC](https://discourse.processing.org/t/apply-wind-force-on-this-code/29322/2 "2021-04-13T11:35:34Z")

</div>

Same for all the posts you made, but you have to format the code with `</>` button in the editor 🙂

---

<div class="post-metadata">

### Author: ![Lolita](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@Lolita](https://discourse.processing.org/u/Lolita)
#### Post date: [April 13, 2021, 11:39am UTC](https://discourse.processing.org/t/apply-wind-force-on-this-code/29322/3 "2021-04-13T11:39:24Z")

</div>

thanks, I just made the edit, is is it working now ? 😀

---

<div class="post-metadata">

### Author: ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)
#### Post date: [April 13, 2021, 11:53am UTC](https://discourse.processing.org/t/apply-wind-force-on-this-code/29322/4 "2021-04-13T11:53:21Z")

</div>

yes but the indentation is gone ☹ you can ctrl+t (or command+t) in the the Processing IDE (not forum) to format the code and then paste it here again.

Regarding the question, do you have “equations” of how a wind force is calculated?

---

<div class="post-metadata">

### Author: ![Lolita](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@Lolita](https://discourse.processing.org/u/Lolita)
#### Post date: [April 13, 2021, 12:15pm UTC](https://discourse.processing.org/t/apply-wind-force-on-this-code/29322/5 "2021-04-13T12:15:50Z")

</div>

I just edited as requested, hope it works 🤕

---

<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: [April 13, 2021, 12:23pm UTC](https://discourse.processing.org/t/apply-wind-force-on-this-code/29322/6 "2021-04-13T12:23:19Z")

</div>

Hello,

Google search this:

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b6f38560f7a4e076736daeb46b72a9d77fdb4fbc.png)

`:)`
