New to Processing, I need HELP!

Hi, I’m new to Processing, I’m making a 3x3 grid game that makes users mousehover over to a target square that is one of the 9 squares. I’m trying to create a function called getNextSquare that picks a random number between 1 and 9 to be the target that that loops again if it picks the number(square) previously clicked by the user to pick a number (square) that wasn’t picked before.
Any help would be vastly appreciated. Here’s my code.

int nextSquare = 0;
void setup() {
nextSquare = 0;

void getNextSquare()  {
for (int nextSquare = 0; nextSquare < 10; nextSquare++) {
  float r = random(1, 9);
1 Like

Since your squares are numbered 0-8 then try

int r = (int) random(0, 9);
println( r );

You definitvly need a draw function that displays the grid

And you need an array to store which cells have been clicked

getNextSquare should check against this array to choose only unclicked cells

1 Like