Guest User

Untitled

a guest
Sep 25th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. /*
  2. * Variables
  3. */
  4. int time_now;
  5. int time_old;
  6. int time_delta;
  7.  
  8. int countdown_start;
  9. int countdown;
  10. int time_counter_started;
  11. boolean start;
  12.  
  13. /*
  14. * Funcion incializacion
  15. */
  16. void setup() {
  17. size(800, 400);
  18. // size(800, 400, P2D);
  19. // size(800, 400, P3D);
  20.  
  21. background(0, 0, 0);
  22. stroke(255, 255, 255);
  23.  
  24. frameRate(10);
  25.  
  26. time_old = 0;
  27.  
  28. countdown_start = 10;
  29. countdown = countdown_start;
  30. time_counter_started = 0;
  31. start = false;
  32. }
  33.  
  34. /*
  35. * Funcion de repintado
  36. */
  37. void draw() {
  38. time_now = millis();
  39. time_delta = time_now - time_old;
  40. time_old = time_now;
  41.  
  42. background(0, 0, 0);
  43.  
  44. textSize(30);
  45. text(time_delta, 50, 35);
  46. text("ms entre frames", 130, 35);
  47. text("Cuenta atrás: " + countdown, 50, 70);
  48.  
  49. if (start && countdown > 0) {
  50. countdown = countdown_start - (time_now - time_counter_started) / 1000;
  51. }
  52. }
  53.  
  54. /*
  55. * Captura click raton
  56. */
  57. void mousePressed() {
  58. start = true;
  59. time_counter_started = millis();
  60. }
Add Comment
Please, Sign In to add comment