I tried making a programme that shows a screen with two buttons but all it shows is a blank screen. This is my code:
int rect1X, rect1Y; //Position Button 1 (Option 1)
int rect2X, rect2Y; //Position Button 2 (Option 2)
int rect1SizeW = displayWidth/3; //Width Button 1 (Option 1)
int rect1SizeH = displayHeight/5*2; //Height Button 1 (Option 1)
int rect2SizeW = displayWidth/3; //Width Button 2 (Option 2)
int rect2SizeH = displayHeight/5*2; //Height Button 2 (Option 2)
color rect1Color, rect2Color, baseColor;
color rect1Highlight, rect2Highlight;
boolean rect1Over = false;
boolean rect2Over = false;
void setup(){
fullScreen();
background(51, 51, 51);
rect1Color = color(65, 51, 122);
rect1Highlight = color(131, 119, 209);
rect2Color = color(65, 51, 122);
rect2Highlight = color(131, 119, 209);
rect1X = displayWidth/9;
rect1Y = displayHeight/5*3;
rect2X = displayWidth/9*5;
rect2Y = displayHeight/5*3;
}
void draw(){
update(mouseX, mouseY);
if (rect1Over){
fill (rect1Highlight);
} else {
fill (rect1Color);
}
stroke(102, 106, 134);
rect(rect1X, rect1Y, rect1SizeW, rect1SizeH);
if (rect2Over){
fill (rect2Highlight);
} else {
fill (rect2Color);
}
stroke(102, 106, 134);
rect(rect2X, rect2Y, rect2SizeW, rect2SizeH);
}
void update(int x, int y) {
if ( overRect2(rect2X, rect2Y, rect2SizeH, rect2SizeW) ) {
rect2Over = true;
rect1Over = false;
} else if ( overRect1(rect1X, rect1Y, rect1SizeH, rect1SizeW) ) {
rect1Over = true;
rect2Over = false;
} else {
rect2Over = rect1Over = false;
}
}
void mousePressed() {
if (rect1Over) {
}
if (rect2Over) {
}
}
boolean overRect1(int x, int y, int width, int height) {
if (mouseX >= x && mouseX <= x+width &&
mouseY >= y && mouseY <= y+height) {
return true;
} else {
return false;
}
}
boolean overRect2(int x, int y, int width, int height) {
if (mouseX >= x && mouseX <= x+width &&
mouseY >= y && mouseY <= y+height) {
return true;
} else {
return false;
}
}
I would really appreciate it if anyone found out what I did wrong
Thank you