> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.dwajqVDWnFC/rev.6
 * 
 * authors: 
 *   GoToLoop

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



/**
 * Paused Countdown (v2.0)
 * by GoToLoop (2014/Jun)
 *
 * forum.processing.org/two/discussion/5650/timing-component-for-game
 *
 * studio.processingtogether.com/sp/pad/export/ro.9Djm2xo4wna7I/latest
 */

static final color FG = #D0A000, BG = 0;
static final int TEXT_SIZE = 0100, QUALITY = 4;
static final int FPS = 60, TIMING = 1*FPS*60 + 60;

int timeup = TIMING;
boolean isPaused, isGameOver;

// ...

void setup() {
  size(800, 600, JAVA2D);
  smooth(QUALITY);
  frameRate(FPS);

  textSize(TEXT_SIZE);
  textAlign(CENTER, CENTER);

  fill(FG);

  // ...
}

void draw() {
  if (isPaused | isGameOver) {
    text(isGameOver? "Game Over" : "Game Paused"
      , width>>1, height>>2);
    noLoop();
    return;
  }

  background(BG);

  final int countdown = (timeup-frameCount)/60 | 0;
  if (countdown == 0)  isGameOver = true;
  text("Countdown: " + countdown, width>>1, height>>1);

  // ...
}

void keyPressed() {
  final int k = keyCode;

  if (!(isPaused ^= k == 'P'))  loop();

  // ...
}