I have created a maze of grids using a 2D array and I'm trying to change the colour of a grid by right clicking or left clicking on a grid in order to indicate the start/end position for the maze by making that grid blue.
Right now my coding allows me to change the colour of a grid when I pressed down the moue button, however it turned back to its original colour (black/white) when i released it. How do I make it stays blue?? Thanks.
Here's my coding:
Maze[][] m; //2D array
int col = 25; //numbers of rows
int row = 25; //numbers of columns
char status;
void setup() {
size (500, 500);
m = new Maze[col][row];
for (int i=0; i<col; i++) { //Initiating each object in the maze
for (int j=0; j<row; j++) {
m[i][j] = new Maze(i*20, j*20, random(1.0), 20, 20, "status");
}
}
}
void draw() {
for (int i=0; i<col; i++) { //i= # of columns
for (int j=0; j<row; j++) { //j = # of rows
if (m[i][j].r>0.3) //70% of assigning white rectangle to grids
m[i][j].drawWhite(); else //30% chance of assigning black rectangle to grids