ArrayList Problems / get() & remove()

Hi @josephh,

Thank you for your message. Sorry for asking but why do i need to change the name? I really want to make sure that i understand well the logic behind.

Also, i just changed the variable name but the screen is grey and this is still not working.
I changed the “size” position cause i had a message error when it was packed in setup()

Best,

Rémy

ArrayList<Bullet> bullets;

void settings(){
   size(400,400);
}

void setup(){

  smooth();
  
  bullets = new ArrayList<Bullet>();
  
  bullets.add(new Bullet(mouseX,mouseY));
  
}


void display(){
  background(255);
  
  for (int i = bullets.size()-1; i >= 0; i--) { 
  Bullet b = bullets.get(i);
  b.move();
  b.display();
  
  if (b.finished()){
    bullets.remove(i);
  }
 }
}

void mousePressed(){
  bullets.add(new Bullet(mouseX,mouseY));
}

class Bullet{
  
  float bulletX1, bulletY1;
  float bulletX2, bulletY2;
  int r;
  int bulletSpeed;
  
  Bullet(float _x, float _y){
    
    bulletX1 = _x - 10;
    bulletY1 = _y;
    bulletX2 = _x +10;
    bulletY2 = _y;
    r = 6;
    bulletSpeed = 1;
  
  }
  
  void move(){
    bulletY1 -= bulletSpeed;
    bulletY2 -= bulletSpeed;
  }
  
    boolean finished() {
    if ((bulletY1<0) || (bulletY2<0)) {
      return true;
    } else {
      return false;
    }
  }
  
  
  void display(){
    fill(255,0,0);
    noStroke();
    ellipse (bulletX1,bulletY1,r,r);
    ellipse (bulletX2,bulletY2,r,r);  
  }
  

}