int numRows = 10; // number of rows in the grid int numCols = 10; // number of columns in the grid int gutter = 5; // space in between the items int margin = 10; // margin around the grid int boxWidth; // declare an int for width of the items int boxHeight; // declare an int for the height of the items int rolledOver = -1; // this int will keep track of which item the mouse is currently over. -1 means none of them void setup(){ frameRate(60); // set the framerate size(480,360); // set the size of the window boxWidth = (width-margin*2-gutter*(numCols-1))/numCols; // assign the boxWidth variable (this changes based on the size of the window) boxHeight = (height-margin*2-gutter*(numRows-1))/numCols; // assign the boxHeight variable (this changes based on the size of the window) } void draw(){ checkRollOvers(); // call the function that checks to see if any of the elements are rolled over drawGrid(); // call the function that draws the grid of elements } // the function that draws the grid void drawGrid(){ int myCounter = 0; // local counter variable to see what number you are currently drawing for(int y=0;ymyX && mouseX<(myX+boxWidth) && mouseY>myY && mouseY<(myY+boxWidth)){ // if the mouse is over this particular element rolledOver = myCounter; // assign rolledOver the ID number (myCounter) of this element } myCounter++; // increment the ID number (myCounter) } } }