import static javax.swing.JOptionPane.*; boolean overButton = false; boolean overit = false; int x, y; void setup() { size(400,400); rectMode(RADIUS); textSize(20); stroke(0); textAlign(CENTER, CENTER); x = 3*width/4; y = 3*height/4; } void draw(){ modo4(); } void modo4(){ background(255); println(mouseY); //isitover(mouseX,mouseY); if(mouseX > x-90 && mouseX < x+90 && mouseY > y-20 && mouseY < y+20){ do{ x = int(random(110,width-110)); y = int(random(210,height-20)); isitover(x,y); }while(overit == true /*&& mouseX > x-90 && mouseX < x+90 && mouseY > y-20 && mouseY < y+20*/); //println("x: " + x + " y: " + y); } boton(x,y,"No"); boton(width/4,3*height/4,"Si"); } void boton(int posx, int posy, String texto){ fill(255); if(mouseX > posx-90 && mouseX < posx+90 && mouseY > posy-20 && mouseY < posy+20){ stroke(0,0,255); overButton = true; } else{ overButton = false; stroke(0); } rect(posx,posy,90,20); fill(0); text(texto,posx,posy); textSize(40); text("¿Pondrías un 10\na este trabajo?",width/2,120); textSize(20); } void mousePressed(){ if(overButton == true) showMessageDialog(null, "Sabía que dirías que sí :D", "Info", INFORMATION_MESSAGE); } void isitover(int x, int y){ //rect(x,y,90,20); if((x-89 > (width/4)-90 && x-89 < (width/4)+90 && y-19 > (3*height/4)-20 && y-19 < (3*height/4)+20)||(x+89 > (width/4)-90 && x+89 < (width/4)+90 && y-19 > (3*height/4)-20 && y-19 < (3*height/4)+20)||(x+89 > (width/4)-90 && x+89 < (width/4)+90 && y+19 > (3*height/4)-20 && y+19 < (3*height/4)+20)||(x-89 > (width/4)-90 && x-89 < (width/4)+90 && y+19 > (3*height/4)-20 && y+19 < (3*height/4)+20)){ overit = true; } else overit = false; println(overit); }