Trying to make a 2d array of a maze
in
Programming Questions
•
1 year ago
I'm in the beginning part of this project. Having trouble with getting nested for loops to do what I want. Initially, what I am trying to do is create 3 cells that has 3 columns and 27 rows. They are drawing on top of each other and can not figure out how to get it to work. If I can get this cornerstone, than I'll be able to make the other components.
This is my initial code.
//think low level
// the parts of this function
// maze component
// particle movement component
//first make maze called drawBlocks
//global variables - what variables are needed for maze component
// drawing cells
int rows = 360;
int cols = 460;
//int cells; error message said duplicate
int w = width/cols;
int h = height/rows;
int [] [] cells = new int [w] [h];
void setup () {
size(460,360);
background(255);
//working 2D array, nested for loop
int cells = 10;
//meant to correlate to rows
for (int i = 0; i < 27; i++) {
//loop meant to correlate to cols
for (int j = 0; j < 3; j++) {
rect(0,0,cells,cells);
// w*=i;
//h*=j;
}
}
}
1