Advertisement
p14082003

sketch.js

Jan 1st, 2017
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var H = 0;
  2. var h = 0;
  3. var M = 0;
  4. var m = 0;
  5. var S = 0;
  6. var s = 0;
  7. var c = 0;
  8.  
  9.  
  10. function setup() {
  11.   createCanvas(110, 100);
  12.   frameRate(100);
  13.   textSize(22);
  14. }
  15.  
  16. function mousePressed() {
  17.   if (mouseX>15 && mouseX<45&&mouseY>60&&mouseY<90) {
  18.     pause();
  19.   }
  20.  
  21.   if (mouseX>65 && mouseX<95&&mouseY>60&&mouseY<90) {
  22.     background(0);
  23.     reset();
  24.     draw_r();
  25.     display();
  26.     if (c > 0) {
  27.       noLoop();
  28.       c = !c;
  29.     }
  30.   }
  31. }
  32.  
  33. function keyPressed() {
  34.   pause();
  35. }
  36. function draw() {
  37.   background(0);
  38.   draw_r();
  39.  
  40.   if (s != 9) {
  41.     s++;
  42.   } else if (S != 9) {
  43.     S++;
  44.     s = 0;
  45.   } else if (m != 9) {
  46.     m++;
  47.     s = 0;
  48.     S = 0;
  49.   } else if (M != 5) {
  50.     M++;
  51.     s = 0;
  52.     S = 0;
  53.     m = 0;
  54.   } else if (h != 60) {
  55.     h++;
  56.     s = 0;
  57.     S = 0;
  58.     m = 0;
  59.     M = 0;
  60.   } else if (H != 60) {
  61.     H++;
  62.     s = 0;
  63.     S = 0;
  64.     m = 0;
  65.     M = 0;
  66.     h = 0;
  67.   }
  68.  
  69.   display();
  70. }
  71.  
  72. function reset() {
  73.   s=0;
  74.   S=0;
  75.   m=0;
  76.   M=0;
  77.   h=0;
  78.   H=0;
  79.   if (c) {
  80.     noLoop();
  81.     c = !c;
  82.   }
  83. }
  84.  
  85. function pause() {
  86.   if (c > 0) {
  87.     noLoop();
  88.     c = !c;
  89.   } else {
  90.     loop();
  91.     c = !c;
  92.   }
  93. }
  94. function draw_r() {
  95. fill(255);
  96. rect(15, 60, 30, 30);
  97. rect(65, 60, 30, 30);
  98. }
  99.  
  100.  
  101. function display() {
  102. text(H+h+";"+M+m+";"+S+s,10,33);
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement