Advertisement
ahorsewithnoname

Voluntario3

Apr 20th, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. int mode = 0;
  2. int currentValue = 0;
  3. long previousMillis = 0;
  4.  
  5. void setup(){
  6.   size(300,300);
  7.   fill(0);
  8.   background(255);
  9.   textAlign(CENTER);
  10.   textSize(27);
  11.   stroke(0);
  12.   strokeWeight(3);
  13.   fill(200);
  14. }
  15.  
  16. void draw(){
  17.   long currentMillis = millis();
  18.  
  19.   if(mode == 1){
  20.     if(currentMillis - previousMillis > 3000){
  21.       previousMillis = currentMillis;
  22.     }
  23.     if(currentMillis - previousMillis < 3000 && currentMillis - previousMillis > 2000){
  24.       fill(255,0,0);
  25.     }
  26.     else if(currentMillis - previousMillis > 1000 && currentMillis - previousMillis < 2000){
  27.       fill(255,255,0);
  28.     }
  29.     else if(currentMillis - previousMillis < 1000){
  30.       fill(0,255,0);
  31.     }
  32.   }
  33.   if(mode == 2){
  34.     if(currentMillis - previousMillis > 5000){
  35.       previousMillis = currentMillis;
  36.     }
  37.     if(currentMillis - previousMillis < 5000 && currentMillis - previousMillis > 3000){
  38.       fill(255,0,0);
  39.     }
  40.     else if(currentMillis - previousMillis > 2000 && currentMillis - previousMillis < 3000){
  41.       fill(255,255,0);
  42.     }
  43.     else if(currentMillis - previousMillis < 2000){
  44.       fill(0,255,0);
  45.     }
  46.   }
  47.    
  48.     ellipse(width/2,height/2,70,70);
  49. }
  50. void keyPressed(){
  51.   background(255);
  52.   fill(0);
  53.   previousMillis = millis();
  54.   if(key == '1'){
  55.     text("Modo 1",width/2,85);
  56.     mode = 1;
  57.   }
  58.   if(key == '2'){
  59.     text("Modo 2",width/2,85);
  60.     mode = 2;
  61.   }
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement