Advertisement
ahorsewithnoname

Voluntario2

Apr 20th, 2021
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. int radio = 60;
  2. int cont = 0;
  3. boolean justonce = false;
  4.  
  5. void setup(){
  6.   size(200, 200);
  7.   stroke(0);
  8. }
  9.  
  10. boolean overRect = false;
  11.  
  12. void draw(){
  13.   background(255);//Fondo de color blanco
  14.   translate(width/2,height/2);
  15.   if(mouseX > (width/2)-radio && mouseX < (width/2)+radio && mouseY > (height/2)-radio && mouseY < (height/2)+radio){
  16.     overRect=true;    
  17.   }
  18.   else{
  19.     overRect=false;
  20.   }
  21.   if(cont != 5){
  22.     fill(200);
  23.   }
  24.   else{
  25.     fill(100,251,102);
  26.   }
  27.   rectMode(RADIUS);
  28.   rect(0,0,radio,radio);
  29. }
  30.  
  31. void mousePressed(){
  32.   println(justonce + " " + overRect);
  33.   if (overRect==true && justonce == false){
  34.     cont++;
  35.     justonce = true;
  36.     println(cont);
  37.   }
  38. }
  39.  
  40. void mouseReleased(){
  41.   justonce = false;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement