Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static javax.swing.JOptionPane.*;
- boolean overButton = false;
- boolean overit = false;
- int x, y;
- void setup() {
- size(500,500);
- rectMode(RADIUS);
- textSize(20);
- stroke(0);
- textAlign(CENTER, CENTER);
- x = 3*width/4;
- y = 3*height/4;
- }
- void draw(){
- 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("Lucía,\n¿Quieres ser mi novia?",width/2,120);
- textSize(20);
- }
- void mousePressed(){
- if(overButton == true) showMessageDialog(null, "Oficialmente somos novios ahora B)", "pa k lo sepas", INFORMATION_MESSAGE);
- }
- void isitover(int x, int y){
- //rect(x,y,90,20);
- 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)){
- overit = true;
- }
- else overit = false;
- //println(overit);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement