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);
}
}
}
}