Problems with Arrays

Hello there,
I previously asked how I can make objects of the same class to execute the same function at the same time. I think the solution to this problem is an array. Unfortuneately it does not work as intended. When I hit the start button of the game, the sketch gets a lot of bugs and does not work properly. The cause of these bugs is the array I use. I can not find the mistake I must have made, can you help me to find it? The array is in the Part1 tab and the class which is used in the array is in the tree tab. I decided to put all my code in this, so you can copy and paste it and try the game by yourself.
Here’s the main tab:

Startscreen startscreen;
Helpmenu helpmenu;
Controlmenu controlmenu;
Part1 part1;
float part=0;
void setup()
{
  size(1300,700,P3D);
  startscreen=new Startscreen(#000000,#000000,#000000);
  helpmenu=new Helpmenu(#000000,#000000,#000000);
  controlmenu=new Controlmenu(#B84EC6);
  part1=new Part1();
}
void draw()
{
  if(starter==0)
  {
  startscreen.createStartscreen();
  startscreen.change();
  startscreen.decoration();
  }
  if(help==5)
  {
    helpmenu.createHelpmenu();
    helpmenu.change();
  }
  if(help==10)
  {
    controlmenu.createControlmenu();
    controlmenu.change();
  }
  if(part==0&starter==5&help==0)
  {
    part1.createPart1();
  }
}
void keyPressed()
{
  helpmenu.callhelp();
  if(part==0&starter==5&help==0)
  {
    part1.Part1keyPressed();
  }
}
void keyReleased()
{
  if(part==0&starter==5&help==0)
  {
    part1.Part1keyReleased();
  }
}
void mousePressed()
{
  if(starter==0)
  {
    startscreen.Play();
    startscreen.Delete();
    startscreen.Exit();
  }
  if(help==5)
  {
    helpmenu.backgame();
    helpmenu.backmain();
    helpmenu.Controls();
  }
  if(help==10)
  {
    controlmenu.backgame();
  }
  if(part==0&starter==5&help==0)
  {
    part1.Part1mousePressed();
  }
}
void mouseReleased()
{
  if(part==0&starter==5&help==0)
  {
    part1.Part1mouseReleased();
  }
}
void mouseMoved()
{
  if(part==0&starter==5&help==0)
  {
    part1.Part1mouseMoved();
  }
}

Here’s the startscreen:

float starter=0;
class Startscreen
{
  color paint1;
  color paint2;
  color paint3;
  PFont scarytitle;
  Startscreen(color p1,color p2,color p3)
  {
    paint1=p1;
    paint2=p2;
    paint3=p3;
    scarytitle=loadFont("FrenchScriptMT-50.vlw");
  }
  void createStartscreen()
  {
    camera();
    lights();
    background(#A098A2);
    textFont(scarytitle);
    rectMode(CENTER);
    strokeWeight(10);
    stroke(paint1);
    fill(#B22CD1);
    rect(650,150,200,100);
    fill(#000000);
    text("Play",630,175,1);
    stroke(paint2);
    fill(#B22CD1);
    rect(650,300,200,100);
    fill(#000000);
    text("Delete",610,325,1);
    stroke(paint3);
    fill(#B22CD1);
    rect(650,450,200,100);
    fill(#000000);
    text("Exit",630,475,1);
    strokeWeight(1);
    paint1=#000000;
    paint2=#000000;
    paint3=#000000;
    pushMatrix();
    translate(mouseX,mouseY,1);
    fill(#5F5F5F);
    beginShape();
    vertex(0,0,0);
    vertex(0,10,0);
    vertex(5,5,0);
    endShape();
    popMatrix();
  }
  void change()
  {
    if((mouseX<750&mouseX>550)&(mouseY<200&mouseY>50))
    {paint1=#FFFFFF;}
    if((mouseX<750&mouseX>550)&(mouseY<350&mouseY>250))
    {paint2=#FFFFFF;}
    if((mouseX<750&mouseX>550)&(mouseY<500&mouseY>400))
    {paint3=#FFFFFF;}
  }
  void Play()
  {
    if(paint1==#FFFFFF)
    {
      if(mouseButton==LEFT)
      {starter=5;}
    }
  }
  void Delete()
  {
    if(paint2==#FFFFFF)
    {
      if(mouseButton==LEFT)
      {
      }
    }
  }
  void Exit()
  {
    if(paint3==#FFFFFF)
    {exit();}
  }
  void decoration()
  {
    strokeWeight(1);
    stroke(#000000);
    fill(#000000);
    beginShape();
    vertex(100,700,0);
    vertex(125,675,0);
    vertex(125,200,0);
    vertex(150,200,0);
    vertex(150,675,0);
    vertex(175,700,0);
    endShape();
    beginShape();
    vertex(125,200,0);
    vertex(275,100,0);
    vertex(150,200,0);
    endShape();
    beginShape();
    vertex(150,200,0);
    vertex(0,75,0);
    vertex(125,200,0);
    endShape();
    beginShape();
    vertex(125,200,0);
    vertex(120,50,0);
    vertex(150,200,0);
    endShape();
    beginShape();
    vertex(150,450,0);
    vertex(300,400,0);
    vertex(150,475,0);
    endShape();
    beginShape();
    vertex(125,500,0);
    vertex(25,250,0);
    vertex(125,475,0);
    endShape();
    beginShape();
    vertex(150,300,0);
    vertex(350,275,0);
    vertex(150,290,0);
    endShape();
  }
}

Here’s the helpmenu tab:

float help=0;
class Helpmenu
{
  color paint1;
  color paint2;
  color paint3;
  PFont scaryhelp;
  
  Helpmenu(color p1,color p2,color p3)
  {
    paint1=p1;
    paint2=p2;
    paint3=p3;
    scaryhelp=loadFont("FrenchScriptMT-50.vlw");
  }
  void createHelpmenu()
  {
    camera();
    lights();
    background(#000000);
    rectMode(CENTER);
    fill(#B22CD1);
    strokeWeight(10);
    stroke(paint1);
    rect(650,200,350,100);
    stroke(paint2);
    rect(650,400,350,100);
    stroke(paint3);
    rect(650,600,350,100);
    strokeWeight(1);
    fill(#000000);
    textFont(scaryhelp);
    text("Back to Game",500,225,0);
    text("Back to MainMenu",500,425,0);
    text("Controls",610,625,0);
    paint1=#000000;
    paint2=#000000;
    paint3=#000000;
    pushMatrix();
    translate(mouseX,mouseY,1);
    fill(#5F5F5F);
    beginShape();
    vertex(0,0,0);
    vertex(0,10,0);
    vertex(5,5,0);
    endShape();
    popMatrix();
  }
  void callhelp()
  {
    if(key=='h')
    {help=5;}
  }
  void change()
  {
    if((mouseX<1000&mouseX>300)&(mouseY<250&mouseY>150))
    {paint1=#FFFFFF;}
    if((mouseX<1000&mouseX>300)&(mouseY<450&mouseY>350))
    {paint2=#FFFFFF;}
    if((mouseX<1000&mouseX>300)&(mouseY<650&mouseY>550))
    {paint3=#FFFFFF;}
  }
  void backgame()
  {
    if(paint1==#FFFFFF)
    {
      if(mouseButton==LEFT)
      {
        help=0;
      }
    }
  }
  void backmain()
  {
    if(paint2==#FFFFFF)
    {
      if(mouseButton==LEFT)
      {
        starter=0;
        help=0;
      }
    }
  }
  void Controls()
  {
    if(paint3==#FFFFFF)
    {
      if(mouseButton==LEFT)
      {
        help=10;
      }
    }
  }
}

Here’s the controlmenu tab:

class Controlmenu
{
  color paint;
  PFont scarycontrol;
  
  Controlmenu(color p)
  {
    paint=p;
    scarycontrol=loadFont("FrenchScriptMT-50.vlw");
  }
  void createControlmenu()
  {
    camera();
    lights();
    background(#000000);
    rectMode(CENTER);
    strokeWeight(1);
    stroke(#000000);
    fill(paint);
    rect(650,650,350,100);
    textFont(scarycontrol);
    fill(#FFFFFF);
    text("",25,100,0);
    fill(#000000);
    text("Back to Game",500,675,0);
    paint=#B84EC6;
    pushMatrix();
    translate(mouseX,mouseY,1);
    fill(#5F5F5F);
    beginShape();
    vertex(0,0,0);
    vertex(0,10,0);
    vertex(5,5,0);
    endShape();
    popMatrix();
  }
  void change()
  {
    if((mouseX<1000&mouseX>300)&(mouseY<700&mouseY>600))
    {paint=#FFFFFF;}
  }
  void backgame()
  {
    if(paint==#FFFFFF)
    {
      if(mouseButton==LEFT)
      {
        help=0;
      }
    }
  }
}

Here’s finally the Part 1 tab

class Part1
{
  Marcy marcy;
  Campfire campfire;
  Tree[] Trees;
  
  Part1()
  {
    marcy=new Marcy(650,440,0,0,0,0,640);
    campfire=new Campfire(650,-100);
    Trees=new Tree[5];
    Trees[0]=new Tree(440,440);
    Trees[1]=new Tree(500,600);
    Trees[2]=new Tree(350,900);
    Trees[3]=new Tree(-100,750);
    Trees[4]=new Tree(700,550);
  }
  void createPart1()
  {
    ambientLight(0,0,0);
    pointLight(brightlight,brightlight,brightlight,xLight,yLight,zLight);
    background(#0D053B);
    pushMatrix();
    translate(650,650,0);
    fill(#114310);
    box(4000,20,4000);
    popMatrix();
    pushMatrix();
    translate(650,650,4000);
    fill(#114310);
    box(4000,20,4000);
    popMatrix();
    pushMatrix();
    translate(650,650,8000);
    fill(#114310);
    box(4000,20,4000);
    popMatrix();
    pushMatrix();
    translate(650,650,12000);
    fill(#114310);
    box(4000,20,4000);
    popMatrix();
    pushMatrix();
    translate(650,650,19000);
    fill(#114310);
    box(4000,20,10000);
    popMatrix();
    fill(#A09E9C);
    beginShape();
    vertex(-1350,640,-2000);
    vertex(2650,640,-2000);
    vertex(2650,100,-2000);
    vertex(-1350,100,-2000);
    endShape();
    beginShape();
    vertex(-1350,640,24000);
    vertex(2650,640,24000);
    vertex(2650,100,24000);
    vertex(-1350,100,24000);
    endShape();
    beginShape();
    vertex(-1350,640,-2000);
    vertex(-1350,640,24000);
    vertex(-1350,100,24000);
    vertex(-1350,100,-2000);
    endShape();
    beginShape();
    vertex(2650,640,-2000);
    vertex(2650,640,24000);
    vertex(2650,100,24000);
    vertex(2650,100,-2000);
    endShape();
    campfire.drawCampfire();
    marcy.drawMarcy();
    marcy.moveMarcy();
    marcy.gravity();
    marcy.cam();
    marcy.jump();
    marcy.flashlight();
    marcy.sprint();
    marcy.moveLegs();
    Trees[5].drawTree();
    if((ax<-1350||ax>2650)||(cz<-2000||cz>24000))
    {
      marcy.bounceBack();
    }
    if(bouncer==true)
    {
      marcy.bounceBack();
    }
  }
  void Part1keyPressed()
  {
    marcy.pressedkeys();
  }
  void Part1keyReleased()
  {
    marcy.releasedkeys();
  }
  void Part1mousePressed()
  {
  }
  void Part1mouseReleased()
  {
  }
  void Part1mouseMoved()
  {
    marcy.mouseturn();
  }
}

Here’s the actor tab (sorry for the many variables and shapes):

float a1=0;
float c1=0;
float cam1=0;
float jump1=0;
float sprinter=0;
float stamina=100;
float jumpfactor=-5;
float mouseturnX=0;
float mouseturnY=0;
float camdist=200;
float brightlight=0;
float lightcount=0;
float xLight=0;
float yLight=0;
float zLight=0;
float ax=0;
float by=0;
float cz=0;
float knee1=12.5;
float m=5;
float knee2=12.5;
float n=5;
float ankle1=200;
float w=-5;
float ankle2=200;
float v=-5;
float legswitch=0;
class Marcy
{
  float xPos;
  float yPos;
  float zPos;
  float xCam;
  float yCam;
  float zCam;
  float floor;
  
  Marcy(float x,float y,float z,float xc,float yc,float zc,float f)
  {
    xPos=x;
    yPos=y;
    zPos=z;
    xCam=xc;
    yCam=yc;
    zCam=zc;
    floor=f;
  }
  void drawMarcy()
  {
    ax=xPos;
    by=yPos;
    cz=zPos;
    pushMatrix();
    translate(xPos,yPos,zPos);
    if(c1!=0||a1!=0)
    {rotateY(mouseturnX);}
    beginShape();
    fill(#FAEABD);//head
    vertex(0,0,0);
    vertex(0,30,0);
    vertex(20,0,-10);
    endShape();
    beginShape();
    vertex(0,0,0);
    vertex(0,30,0);
    vertex(-20,0,-10);
    endShape();
    beginShape();
    vertex(0,0,0);
    vertex(0,-20,0);
    vertex(20,0,-10);
    endShape();
    beginShape();
    vertex(0,0,0);
    vertex(0,-20,0);
    vertex(-20,0,-10);
    endShape();
    beginShape();
    vertex(0,30,0);
    vertex(-20,0,-10);
    vertex(20,0,-10);
    endShape();
    beginShape();//neck
    vertex(0,0,-10);
    vertex(10,50,-10);
    vertex(-10,50,-10);
    endShape();
    beginShape();
    vertex(0,0,-5);
    vertex(10,50,-5);
    vertex(-10,50,-5);
    endShape();
    beginShape();
    vertex(-10,50,-5);
    vertex(0,0,-5);
    vertex(0,0,-10);
    vertex(-10,50,-10);
    endShape();
    beginShape();
    vertex(10,50,-5);
    vertex(0,0,-5);
    vertex(0,0,-10);
    vertex(10,50,-10);
    endShape();
    beginShape();//nose
    vertex(0,0,0);
    vertex(0,15,7.5);
    vertex(0,15,0);
    endShape();
    fill(#EFF05C);//hair
    beginShape();
    vertex(0,-20,0);
    vertex(0,-25,0);
    vertex(30,10,-15);
    endShape();
    beginShape();
    vertex(0,-20,0);
    vertex(0,-25,0);
    vertex(-30,10,-15);
    endShape();
    beginShape();
    vertex(0,-25,0);
    vertex(-20,0,-10);
    vertex(20,0,-10);
    endShape();
    beginShape();
    vertex(20,0,-10);
    vertex(0,15,-15);
    vertex(-20,0,-10);
    endShape();
    beginShape();
    vertex(-5,12.5,-12.5);
    vertex(5,12.5,-12.5);
    vertex(0,60,-15);
    endShape();
    fill(#1D7116);//Pullover
    beginShape();
    vertex(40,40,-7.5);
    vertex(-40,40,-7.5);
    vertex(-40,60,-27.5);
    vertex(40,60,-27.5);
    endShape();
    beginShape();
    vertex(40,40,-7.5);
    vertex(-40,40,-7.5);
    vertex(-40,60,12.5);
    vertex(40,60,12.5);
    endShape();
    beginShape();
    vertex(40,60,12.5);
    vertex(-40,60,12.5);
    vertex(-20,80,2.5);
    vertex(20,80,2.5);
    endShape();
    beginShape();
    vertex(40,60,-27.5);
    vertex(-40,60,-27.5);
    vertex(-20,80,-17.5);
    vertex(20,80,-17.5);
    endShape();
    beginShape();
    vertex(40,40,-7.5);
    vertex(40,60,12.5);
    vertex(40,60,-27.5);
    endShape();
    beginShape();
    vertex(-40,40,-7.5);
    vertex(-40,60,12.5);
    vertex(-40,60,-27.5);
    endShape();
    beginShape();
    vertex(40,60,12.5);
    vertex(40,60,-27.5);
    vertex(20,80,-17.5);
    vertex(20,80,2.5);
    endShape();
    beginShape();
    vertex(-40,60,12.5);
    vertex(-40,60,-27.5);
    vertex(-20,80,-17.5);
    vertex(-20,80,2.5);
    endShape();
    beginShape();
    vertex(-20,80,2.5);
    vertex(20,80,2.5);
    vertex(40,100,12.5);
    vertex(-40,100,12.5);
    endShape();
    beginShape();
    vertex(-20,80,-17.5);
    vertex(20,80,-17.5);
    vertex(40,100,-27.5);
    vertex(-40,100,-27.5);
    endShape();
    beginShape();
    vertex(20,80,-17.5);
    vertex(20,80,2.5);
    vertex(40,100,12.5);
    vertex(40,100,-27.5);
    endShape();
    beginShape();
    vertex(-20,80,-17.5);
    vertex(-20,80,2.5);
    vertex(-40,100,12.5);
    vertex(-40,100,-27.5);
    endShape();
    beginShape();//Arms
    vertex(-40,50,-5);
    vertex(-40,50,-10);
    vertex(-40,100,-7.5);
    endShape();
    beginShape();
    vertex(-45,50,-5);
    vertex(-45,50,-10);
    vertex(-45,100,-7.5);
    endShape();
    beginShape();
    vertex(-45,50,-5);
    vertex(-40,50,-5);
    vertex(-40,50,-10);
    vertex(-45,50,-10);
    endShape();
    beginShape();
    vertex(-45,50,-5);
    vertex(-40,50,-5);
    vertex(-40,100,-7.5);
    vertex(-45,100,-7.5);
    endShape();
    beginShape();
    vertex(-45,50,-10);
    vertex(-40,50,-10);
    vertex(-40,100,-7.5);
    vertex(-45,100,-7.5);
    endShape();
    beginShape();//other arm
    vertex(40,50,-5);
    vertex(40,50,-10);
    vertex(40,100,-7.5);
    endShape();
    beginShape();
    vertex(45,50,-5);
    vertex(45,50,-10);
    vertex(45,100,-7.5);
    endShape();
    beginShape();
    vertex(45,50,-5);
    vertex(40,50,-5);
    vertex(40,50,-10);
    vertex(45,50,-10);
    endShape();
    beginShape();
    vertex(40,50,-5);
    vertex(45,50,-5);
    vertex(45,100,-7.5);
    vertex(40,100,-7.5);
    endShape();
    beginShape();
    vertex(40,50,-10);
    vertex(45,50,-10);
    vertex(45,100,-7.5);
    vertex(40,100,-7.5);
    endShape();
    fill(#6E95B2);//Trousers tigh1
    beginShape();
    vertex(0,100,12.5);
    vertex(0,100,-27.5);
    vertex(0,150,knee1);
    endShape();
    beginShape();
    vertex(-40,100,12.5);
    vertex(-40,100,-27.5);
    vertex(-40,150,knee1);
    endShape();
    beginShape();
    vertex(0,100,12.5);
    vertex(-40,100,12.51);
    vertex(-40,150,knee1);
    vertex(0,150,knee1);
    endShape();
    beginShape();
    vertex(-40,100,-27.5);
    vertex(0,100,-27.5);
    vertex(0,150,knee1);
    vertex(-40,150,knee1);
    endShape();
    beginShape();//tigh2
    vertex(0,100,12.5);
    vertex(0,100,-27.5);
    vertex(0,150,knee2);
    endShape();
    beginShape();
    vertex(40,100,12.5);
    vertex(40,100,-27.5);
    vertex(40,150,knee2);
    endShape();
    beginShape();
    vertex(0,100,12.5);
    vertex(40,100,12.5);
    vertex(40,150,knee2);
    vertex(0,150,knee2);
    endShape();
    beginShape();
    vertex(0,100,-27.5);
    vertex(40,100,-27.5);
    vertex(40,150,knee2);
    vertex(0,150,knee2);
    endShape();
    beginShape();//lowerknee1
    vertex(0,150,knee1);
    vertex(0,ankle1,12.5);
    vertex(0,ankle1,-27.5);
    endShape();
    beginShape();
    vertex(-40,150,knee1);
    vertex(-40,ankle1,12.5);
    vertex(-40,ankle1,-27.5);
    endShape();
    beginShape();
    vertex(0,150,knee1);
    vertex(-40,150,knee1);
    vertex(-40,ankle1,12.5);
    vertex(0,ankle1,12.5);
    endShape();
    beginShape();
    vertex(0,150,knee1);
    vertex(-40,150,knee1);
    vertex(-40,ankle1,-27.5);
    vertex(0,ankle1,-27.5);
    endShape();
    beginShape();//lowerknee2
    vertex(0,150,knee2);
    vertex(0,ankle2,12.5);
    vertex(0,ankle2,-27.5);
    endShape();
    beginShape();
    vertex(40,150,knee2);
    vertex(40,ankle2,12.5);
    vertex(40,ankle2,-27.5);
    endShape();
    beginShape();
    vertex(0,150,knee2);
    vertex(40,150,knee2);
    vertex(40,ankle2,12.5);
    vertex(0,ankle2,12.5);
    endShape();
    beginShape();
    vertex(0,150,knee2);
    vertex(40,150,knee2);
    vertex(40,ankle2,-27.5);
    vertex(0,ankle2,-27.5);
    endShape();
    fill(#BD0CF0);//eyes
    beginShape();
    vertex(-5,5,0);
    vertex(-5,-5,0);
    vertex(-10,0,-2.5);
    endShape();
    beginShape();
    vertex(5,5,0);
    vertex(5,-5,0);
    vertex(10,0,-2.5);
    endShape();
    popMatrix();
  }
  void mouseturn()
  {
    if(mouseX>650)
    {mouseturnX=(mouseX-650)*0.01;}
    if(mouseX<650)
    {mouseturnX=-(-mouseX+650)*0.01;}
    
    if(mouseY>350)
    {mouseturnY=(mouseY-350)*0.5;}
    if(mouseY<350)
    {mouseturnY=-(-mouseY+350)*0.5;}
  }
  void pressedkeys()
  {
    if(key=='w')
    {a1=-5;}
    if(key=='s')
    {a1=5;}
    if(key=='a')
    {c1=5;}
    if(key=='d')
    {c1=-5;}
    if(key=='c')
    {cam1=5;}
    if(key=='x')
    {jump1=5;}
    if(key=='e')
    {lightcount=5;}
    if(key=='q')
    {sprinter=5;}
  }
  void releasedkeys()
  {
    if(key=='w')
    {a1=0;}
    if(key=='s')
    {a1=0;}
    if(key=='a')
    {c1=0;}
    if(key=='d')
    {c1=0;}
    if(key=='c')
    {cam1=0;}
    if(key=='x')
    {jump1=0;}
    if(key=='e')
    {lightcount=0;}
    if(key=='q')
    {sprinter=0;}
  }
  void moveMarcy()
  {
    if(a1<0||a1>0)
    {
      xPos=(cos(mouseturnX)*a1)+xPos;
      zPos=(sin(mouseturnX)*a1)+zPos;
    }
    if(c1<0||c1>0)
    {
      xPos=(sin(mouseturnX)*c1)+xPos;
      zPos=(cos(mouseturnX)*c1)+zPos;
    }
  }
  void jump()
  {
    if(jump1>0)
    {
      yPos=yPos-jumpfactor;
      if(yPos>floor-175||yPos<floor-400)
      {jumpfactor=-jumpfactor;}
    }
  }
  void gravity()
  {
    if(yPos<floor-200)
    {yPos++;}
    if(yPos>floor-200)
    {yPos--;}
  }
  void cam()
  {
    xCam=(cos(mouseturnX)*camdist)+xPos;
    if(cam1==0)
    {yCam=yPos+mouseturnY;}
    zCam=(sin(mouseturnX)*camdist)+zPos;
    camera(xCam,yCam,zCam,xPos,yPos,zPos,0,1,0);
    if(cam1==0)
    {camdist=200;}
    if(cam1>0)
    {
    camdist=10;
    yCam=yPos;
    }
  }
  void flashlight()
  { 
   
    
    xLight=(cos(mouseturnX)*-200)+xPos;
    yLight=yPos;
    zLight=(sin(mouseturnX)*-200)+zPos;
  
    if(lightcount==0)
    {brightlight=0;}
    if(lightcount>0)
    {brightlight=255;}
  }
  void sprint()
  {
    if(sprinter>0&stamina>10)
    {
    a1=-15;
    }
    if(sprinter>0)
    {stamina=stamina-5;}
    if(stamina<100)
    {stamina=stamina+1;}
    pushMatrix();
    hint(DISABLE_DEPTH_TEST);
    camera();
    noLights();
    rectMode(CORNER);
    fill(#00FF00);
    rect(0,350,stamina,10);
    hint(ENABLE_DEPTH_TEST);
    popMatrix();
  }
  void bounceBack()
  {
    zPos=(sin(mouseturnX)*-a1)+zPos;
    xPos=(cos(mouseturnX)*-a1)+xPos;
    zPos=zPos-(zPos*0.01);
    xPos=xPos-(xPos*0.01);
  }
  void moveLegs()
  {
    if(c1==0&a1==0&jump1==0)
    {
      knee1=12.5;
      knee2=12.5;
      ankle1=200;
      ankle2=200;
      legswitch=0;
    }
    if(c1!=0||a1!=0)
    {
      knee1=knee1+m;
      ankle1=ankle1+w;
      if(knee1<12.5||knee1>37.5)
      {m=-m;}
      if(ankle1>200||ankle1<175)
      {w=-w;}
      if(knee1>37)
      {legswitch=1;}
      if(legswitch==1)
      {
        knee2=knee2+n;
        ankle2=ankle2+v;
        if(knee2<12.5||knee2>37.5)
        {n=-n;}
        if(ankle2>200||ankle2<175)
        {v=-v;}
      }
    }
    if(jump1!=0)
    {
      if(yPos>floor-200)
      {
        knee1=knee1+m;
        ankle1=ankle1+w;
        if(knee1<12.5||knee1>37.5)
        {m=-m;}
        if(ankle1>200||ankle1<175)
        {w=-w;}
        knee2=knee2+n;
        ankle2=ankle2+v;
        if(knee2<12.5||knee2>37.5)
        {n=-n;}
        if(ankle2>200||ankle2<175)
        {v=-v;}
      }
    }
  }
}

Here’s the Campfire tab:

class Campfire
{
  float xPos;
  float zPos;
  
  Campfire(float x,float z)
  {
    xPos=x;
    zPos=z;
  }
  void drawCampfire()
  {
    pushMatrix();
    translate(xPos,640,zPos);
    pointLight(250,68,35,0,-10,0);
    pointLight(250,68,35,-40,-10,0);
    pointLight(250,68,35,40,-10,0);
    pointLight(250,68,35,0,-10,40);
    pointLight(250,68,35,0,-10,-40);
    fill(#FA4423);
    beginShape();
    vertex(-30,0,-30);
    vertex(-30,-60,0);
    vertex(-30,0,30);
    endShape();
    beginShape();
    vertex(30,0,-30);
    vertex(30,-60,0);
    vertex(30,0,30);
    endShape();
    beginShape();
    vertex(-30,0,-30);
    vertex(0,-60,-30);
    vertex(30,0,-30);
    endShape();
    beginShape();
    vertex(-30,0,30);
    vertex(0,-60,30);
    vertex(30,0,30);
    endShape();
    popMatrix();
  }
}

Here’s the Tree tab

boolean bouncer=false;
class Tree
{
  float xPos;
  float zPos;
  
  Tree(float x,float z)
  {
    xPos=x;
    zPos=z;
  }
  void drawTree()
  {
    pushMatrix();
    translate(xPos,240,zPos);
    fill(#8E8671);
    box(20,800,20);
    popMatrix();
    pushMatrix();
    translate(xPos,240,zPos);
    box(80,10,10);
    box(10,10,80);
    popMatrix();
    pushMatrix();
    translate(xPos,200,zPos);
    box(100,10,10);
    box(10,10,100);
    popMatrix();
    pushMatrix();
    translate(xPos,160,zPos);
    box(120,10,10);
    box(10,10,120);
    popMatrix();
    pushMatrix();
    translate(xPos,120,zPos);
    box(140,10,10);
    box(10,10,140);
    popMatrix();
    pushMatrix();
    translate(xPos,80,zPos);
    box(120,10,10);
    box(10,10,120);
    popMatrix();
    pushMatrix();
    translate(xPos,40,zPos);
    box(100,10,10);
    box(10,10,100);
    popMatrix();
    pushMatrix();
    translate(xPos,0,zPos);
    box(80,10,10);
    box(10,10,80);
    popMatrix();
    pushMatrix();
    translate(xPos,-40,zPos);
    box(60,10,10);
    box(10,10,60);
    popMatrix();
    pushMatrix();
    translate(xPos,-80,zPos);
    box(40,10,10);
    box(10,10,40);
    popMatrix();
    
    if((ax<xPos-40||ax>xPos+40)||(cz<zPos-40||cz>zPos+40))
    {bouncer=false;}
    bouncer=((ax>xPos-40&ax<xPos+40)&(cz>zPos-40&cz<zPos+40));
    
    
  }  
}

Thank you very much.

I didn’t look through all of it, but there is an issue with the line above. In that line “Trees[5]” refers to one specific “Tree” object in the array, but the array does not have an object at index 5, only 0 through 4.

If you want to loop through the array and do something with each object you could do something like this:

for(Tree tree : Trees) {
  // each time through the loop the "tree" variable 
  // refers to the next Tree object in array Trees
  tree.drawTree();
}

Thank you very much for your help :slight_smile: