I’m involved in a team project in college. the objective is to make a game for kids and the foundation is there. but when the mouse hover code works i have the other 8 squares in my 3x3 grid set to white. i want it to be where one other square turns red to be a target square for my hover code to get to. please help and respond asap.
thanks very much.
PFont f;
int time1 = 500;
int time2 = 3500;
float x = 0;
Cell [] grid;
int unit = 350; // size of one tile
int wideCount ;
int highCount ;
String[] list = {"4-5", "6-7", "8-9", "10-11", "", "12-13", "14-15", "16-17", "18+"};
// ---------------------------------------------------------
void setup() {
size(1200, 1080);
f = createFont("Times New Roman",16,true); // STEP 2 Create Font
noStroke();
background(255);
int count;
wideCount = width / unit;
highCount = height / unit;
count = wideCount * highCount;
grid = new Cell[count];
int index = 0;
int k=0;
for (int x=0; x< wideCount; x++) {
for (int y=0; y< highCount; y++) {
//start creating objects
grid[index] = new Cell (x*unit, y*unit, unit, list[k]);
index++;
k++;
}
}
}
//
void draw() {
//
background(255);
int index = 0;
//
for (int x=0; x< wideCount; x++) {
for (int y=0; y< highCount; y++) {
grid[index++].display();
}
textFont(f,16);
fill(0);
textAlign(CENTER);
text("Stand on your AGE group to Play!",width/2,35);
}
}
// ========================================================================
// and the class
class Cell {
float x, y;
float side;
String text="";
// int col;
Cell (float tempX, float tempY,
float tempSide,
String tempText) {
x = tempX;
y = tempY;
side = tempSide;
text = tempText;
//
float fate = random(2);
}
void display() {
int currentTime = millis();
fill(255, 255, 255);
stroke(122);
fill(255, 255, 255);
rect (x+width/9, y+height/9, side/2, side/2);
fill(0,0,0);
text(text, x+width/7.5+25, y+height/9+40);
if (mouseX>x&&mouseX<x+side&&mouseY>y&&mouseY<y+side) {
fill(255, 0, 0);
stroke(122);
rect (x+width/9, y+height/9, side/2, side/2);
fill(0,0,0);
text(text, x+width/7.5+25, y+height/9+40);
fill(0, 255, 0);
}
if (currentTime > time2 & mouseX>x&&mouseX<x+side&&mouseY>y&&mouseY<y+side) {
fill(0, 255, 0);
stroke(122);
rect (x+width/9, y+height/9, side/2, side/2);
fill(0,0,0);
text(text, x+width/7.5+25, y+height/9+40);
}
}
}