boolean over(float x, float y, float w, float h) {
if (mouseY > y && mouseY < y + h && mouseX > x && mouse**Y** < x + w) {
return true;
}
return false;
}
is wrong
also start structuring your code better
and learn using variables:
try this code to get the idea:
int state = 0;
int x1=100, y1=100, w1=250, h1=250; //Button oben links
int x2=1570, y2=100, w2=250, h2=250; //Button oben rechts
int x3=100, y3=730, w3=250, h3=250; //Button unten links
int x4=1570, y4=730, w4=250, h4=250; //Button unten rechts
int x5=80, y5=870, w5=250, h5=100; // Button zurück
void draw_4_button() { //_______ stat 0 only
if ( over(x1, y1, w1, h1) ) stroke(200,0,0); else stroke(0);
rect(x1, y1, w1, h1);
if ( over(x2, y2, w2, h2) ) stroke(200,0,0); else stroke(0);
rect(x2, y2, w2, h2);
if ( over(x3, y3, w3, h3) ) stroke(200,0,0); else stroke(0);
rect(x3, y3, w3, h3);
if ( over(x4, y4, w4, h4) ) stroke(200,0,0); else stroke(0);
rect(x4, y4, w4, h4);
}
void draw_zurueck_button() { //_ state 1,2,3
if ( over(x5, y5, w5, h5) ) stroke(200,0,0); else stroke(0);
rect(x5, y5, w5, h5);
}
void setup() {
size(1920, 1080);
fill(0,0,200);
strokeWeight(10);
}
void draw() {
background(200,100,200);
if ( state == 0 ) draw_4_buttons();
if ( state > 0 ) draw_back_button_and_some_text(state);
}
void draw_4_buttons() {
draw_4_button();
}
void draw_back_button_and_some_text(int page ) {
text("some text page "+page,20,20);
draw_zurueck_button();
}
boolean over(int x, int y, int w, int h) {
return ( mouseX > x & mouseX < x + w &&
mouseY > y & mouseY < y + h ) ;
}