Advertisement
ahorsewithnoname

pastelux

May 9th, 2021
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.81 KB | None | 0 0
  1. import static javax.swing.JOptionPane.*;
  2.  
  3. boolean overButton = false;
  4. boolean overit = false;
  5. int x, y;
  6. void setup() {
  7.   size(500,500);
  8.   rectMode(RADIUS);
  9.   textSize(20);
  10.   stroke(0);
  11.   textAlign(CENTER, CENTER);
  12.   x = 3*width/4;
  13.   y = 3*height/4;
  14. }
  15.  
  16. void draw(){
  17.   background(255);
  18.   //println(mouseY);
  19.   //isitover(mouseX,mouseY);
  20.   if(mouseX > x-90 && mouseX < x+90 && mouseY > y-20 && mouseY < y+20){
  21.     do{
  22.         x = int(random(110,width-110));
  23.         y = int(random(210,height-20));
  24.         isitover(x,y);
  25.     }while(overit == true /*&& mouseX > x-90 && mouseX < x+90 && mouseY > y-20 && mouseY < y+20*/);
  26.     ////println("x: " + x + " y: " + y);
  27.   }
  28.   boton(x,y,"No");
  29.   boton(width/4,3*height/4,"Si");
  30. }
  31.  
  32. void boton(int posx, int posy, String texto){
  33.   fill(255);
  34.   if(mouseX > posx-90 && mouseX < posx+90 && mouseY > posy-20 && mouseY < posy+20){
  35.     stroke(0,0,255);
  36.     overButton = true;
  37.   }
  38.   else{
  39.     overButton = false;
  40.     stroke(0);
  41.   }
  42.   rect(posx,posy,90,20);
  43.   fill(0);
  44.   text(texto,posx,posy);
  45.   textSize(40);
  46.   text("Lucía,\n¿Quieres ser mi novia?",width/2,120);
  47.   textSize(20);
  48. }
  49.  
  50.  
  51. void mousePressed(){
  52.   if(overButton == true) showMessageDialog(null, "Oficialmente somos novios ahora B)", "pa k lo sepas", INFORMATION_MESSAGE);
  53. }
  54.  
  55. void isitover(int x, int y){
  56.   //rect(x,y,90,20);
  57.   if((x-90 > (width/4)-90 && x-90 < (width/4)+90 && y-20 > (3*height/4)-20 && y-20 < (3*height/4)+20)||(x+90 > (width/4)-90 && x+90 < (width/4)+90 && y-20 > (3*height/4)-20 && y-20 < (3*height/4)+20)||(x+90 > (width/4)-90 && x+90 < (width/4)+90 && y+20 > (3*height/4)-20 && y+20 < (3*height/4)+20)||(x-90 > (width/4)-90 && x-90 < (width/4)+90 && y+20 > (3*height/4)-20 && y+20 < (3*height/4)+20)){
  58.     overit = true;
  59.    
  60.   }
  61.   else overit = false;
  62.   //println(overit);
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement