How to append objects to an array

I don't know which type grid has to be, it's confusing.

Cell cell;
int cols, rows;
int size = 40;
Cell[] grid;

void setup(){
  size(800, 600);
  background(255);
  cols = floor(width/size);
  rows = floor(height/size);

  for(int i = 0; i < rows; i++){
    for(int j = 0; i < cols; j++){
      cell = new Cell(i, j);
      grid.append(cell);
    }
  }
}

void draw(){
  background(255);
}

class Cell{
  int i, j;

  Cell(int _i, int _j){
    i = _i;
    j = _j;
  }
}
Tagged:

Answers

Sign In or Register to comment.