Generate a square grid
in
Programming Questions
•
4 months ago
hi im tying to to generate a square grid of 30 rows and 30 columns. the colour of each cell is randomly set.
A new grid is displayed whenever any key is pressed.
got this code so far
int row = 30;
int col = 30;
color[] [] grid = new color [row] [col];
int cell_size = 20;
void setup()
{
background(255);
smooth();
size(600,600);
init_grid()
}
// ceate a gride of 30 rows and 30 colimns ad set the grid colour with random colours
void init_grid()
{
for(???)
{
for(?)
{
//set ramdom colours for the grid cells
grid [?] [?] = color(ramdom(0,255),ramdom(0,255),ramdom(0,255));
}
}
}
// display the grid wit filled in random colours
void draw_grid()
{
//2 for loops for rows and cols
// rect statemant , use of cell size
}
void keyPressed()
{
init_grid();
}
void draw()
{
draw_grid();
}
help plz
1