Question about expand array
              in 
             Programming Questions 
              •  
              1 year ago    
            
 
           
             I am creating an array of cells, what i want is once mousepressed, one cell becomes two, then each of the two cells becomes two , so the quantity of the cells doubles everytime you press the mouse. I want to use expand function to double the size of the array, 
            
             
            
            
             
              
             
             
              
             
             
              
             
             
                
             
             
              
             
             
                
             
             
              
             
             
              
             
             
              
             
             
            
             
            
            
             
             
           
 
            
           
             Here is my code(I have a cell class created already): 
            
            
              cell[] cells;
             
             
              void setup(){
             
             
              size(600,600);
             
             
              smooth();
             
             
              cells = new cell[1];
             
             
              cells[0] = new cell(300,300,50);
             
             
              }
             
             
              void draw(){
             
             
              background (255,235,205);
             
             
              for (int i = 0; i < cells.length; i++) {
             
             
                  cells[i].grow();
             
             
                  cells[i].move();
             
             
                  cells[i].display();
             
             
                }
             
             
              }
             
             
              void mousePressed(){
             
             
              cells = (cell[])expand(cells);
             
             
              // not quite sure what I should put in here? 
             
             
                }
             
             
              }
             
            
             Thank you for your help! 
            
             
              
              1  
            
 
            