# Do you know why there is an error? I found a new problem

**URL:** https://discourse.processing.org/t/do-you-know-why-there-is-an-error-i-found-a-new-problem/37315
**Category:** Coding Questions
**Created:** [June 4, 2022, 8:15am UTC](https://discourse.processing.org/t/do-you-know-why-there-is-an-error-i-found-a-new-problem/37315 "2022-06-04T08:15:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ell](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@ell](https://discourse.processing.org/u/ell)
#### Post date: [June 4, 2022, 8:15am UTC](https://discourse.processing.org/t/do-you-know-why-there-is-an-error-i-found-a-new-problem/37315/1 "2022-06-04T08:15:12Z")

</div>

Hello genius!  
I posted a question yesterday and it was solved, but I am facing a new problem again, so I am asking you again.

There’s a problem with the first line of code.  
It is said that the active mode and static mode were mixed, how can I solve this problem?

int s\_num = 40;

PShape s;  
PShape b;

Virus Virus1 = new Virus[s\_num];  
Cell Cells = new Cell[40];

void setup()  
{  
size(800,600,P3D);

```
s = loadShape("virus.obj");
b = loadShape("cell.obj");

```

for(int i =0; i\< s\_num; i++){  
Virus1[i] = new Virus();  
}

for(int i=0; i\< 1; i++){  
Cells[i] = new Cell ();  
}

}

void draw()  
{  
background(0);  
for(int i =0; i \< s\_num; i++){  
Virus1[i].display();  
Virus1[i].move();  
}  
for(int i =0; i \< 1; i++){  
Cells[i].display();  
Cells[i].move();  
}

}  
class Virus{

float xpos,ypos,zpos,speed;

Virus()  
{  
xpos = random(width);  
ypos = random(height);  
zpos = random(-200,-400);  
speed = random(3,5);  
}

void display()  
{  
noStroke();  
fill(#ffcc33);  
pushMatrix();  
translate(xpos,ypos,zpos);  
shape(s,w,w);  
popMatrix();  
}

void move(){  
zpos += speed;  
if(zpos \> 500 ){  
zpos = -200;  
}

}

}

class Cell{  
float xpos,ypos,zpos,speed,w;

Cell()  
{  
xpos = mouseX;  
ypos = mouseY;  
zpos = mouseX;  
speed = 5;  
w = 0;  
}

void display()  
{  
noStroke();  
fill(255,5,188);  
pushMatrix();  
translate(xpos,ypos,zpos);  
shape(b,w,w);  
popMatrix();  
}

void move()  
{  
xpos = mouseX;  
ypos = mouseY;

}

void draw()  
{  
int nearestCell;  
float minCellDistance =0;

int nearestCell;  
float minCellDistance = Float. MAX\_VALUE;  
for (int i =0; i \< s\_num; i++){  
dist(Cell[0].xpos, Cell[0].ypos, Cell[0].zpos, Virus1[i].xpos,Virus1[i].ypos,Virus1[i].zpos);

}  
}

}

}

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [June 4, 2022, 9:03am UTC](https://discourse.processing.org/t/do-you-know-why-there-is-an-error-i-found-a-new-problem/37315/2 "2022-06-04T09:03:57Z")

</div>

[please use the \</\> button to format your code …](https://discourse.processing.org/faq#format-your-code)

---

<div class="post-metadata">

### Author: ![RichardDL](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@RichardDL](https://discourse.processing.org/u/RichardDL)
#### Post date: [June 4, 2022, 9:48am UTC](https://discourse.processing.org/t/do-you-know-why-there-is-an-error-i-found-a-new-problem/37315/3 "2022-06-04T09:48:05Z")

</div>

As well as formatting it, please make sure the code can be copied (icon top right of formatted code block) and run without errors (other than the one you are asking about).

---

<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: [June 4, 2022, 10:04am UTC](https://discourse.processing.org/t/do-you-know-why-there-is-an-error-i-found-a-new-problem/37315/4 "2022-06-04T10:04:52Z")

</div>

here is a running version:

```auto

int s_num = 40;

PShape s;
PShape b;

Virus[] Virus1 = new Virus[s_num];
Cell[] Cells = new Cell[40];

void setup()
{
  size(800, 600, P3D);

  s = loadShape("virus.obj");
  b = loadShape("cell.obj");

  for (int i =0; i< s_num; i++) {
    Virus1[i] = new Virus();
  }

  for (int i=0; i< 1; i++) {
    Cells[i] = new Cell ();
  }
}

void draw()
{
  background(0);
  for (int i =0; i < s_num; i++) {
    Virus1[i].display();
    Virus1[i].move();
  }
  for (int i =0; i < 1; i++) {
    Cells[i].display();
    Cells[i].move();
  }
}

// =====================================================================

class Virus {

  float xpos, ypos, zpos, speed;

  Virus()
  {
    xpos = random(width);
    ypos = random(height);
    zpos = random(-200, -400);
    speed = random(3, 5);
  }

  void display()
  {
    noStroke();
    fill(#ffcc33);
    pushMatrix();
    translate(xpos, ypos, zpos);
    //shape(s, w, w);
    text("V", 0, 0); 
    popMatrix();
  }

  void move() 
  {
    zpos += speed;
    if (zpos > 500 ) {
      zpos = -200;
    }
  }
  //
}//class

// =====================================================================

class Cell {
  float xpos, ypos, zpos, speed, w;

  Cell()
  {
    xpos = mouseX;
    ypos = mouseY;
    zpos = mouseX;
    speed = 5;
    w = 0;
  }

  void display()
  {
    noStroke();
    fill(255, 5, 188);
    pushMatrix();
    translate(xpos, ypos, zpos);
    //shape(b, w, w);
    text("C", 0, 0); 
    popMatrix();
  }

  void move()
  {
    xpos = mouseX;
    ypos = mouseY;
  }

  void draw()
  {
    int nearestCell;
    float minCellDistance =0;

    // int nearestCell;
    minCellDistance = Float.MAX_VALUE;
    for (int i =0; i < s_num; i++) {
      float d1=dist(Cells[0].xpos, Cells[0].ypos, Cells[0].zpos, 
        Virus1[i].xpos, Virus1[i].ypos, Virus1[i].zpos);
    }
  }
  //
}//class 
//

```

---

<div class="post-metadata">

### Author: ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)
#### Post date: [June 4, 2022, 1:51pm UTC](https://discourse.processing.org/t/do-you-know-why-there-is-an-error-i-found-a-new-problem/37315/5 "2022-06-04T13:51:24Z")

</div>

To add to the recommendations above: you will also get better replies if you use a more descriptive title for your forum post.

If someone reads “Do you know why there is an error? I found a new problem” they do not know whether they will be able to help you or not.

If someone reads “'It looks like you’re mixing active and static modes” they might think “oh I know the answer to that” and jump in to help you out.

You might also find that your question has already been solved by searching online for the error message you get from Processing, like [this stakoverflow issue](https://stackoverflow.com/questions/6658827/processing-it-looks-like-youre-mixing-active-and-static-modes) I found by googling the error message your mentioned 😉

---

<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: [June 4, 2022, 5:54pm UTC](https://discourse.processing.org/t/do-you-know-why-there-is-an-error-i-found-a-new-problem/37315/6 "2022-06-04T17:54:20Z")

</div>

> [@ell](#):
>
> It is said that the active mode and static mode were mixed, how can I solve this problem?

This is mostly caused by misplaced brackets }

One bracket too much or a bracket in a way that code is outside any Function, which isn’t allowed when you work with functions.
