New to processing!

edited January 2016 in Questions about Code

New to processing! I constructed this code that imprints a square that moves every second and fills the screen as time goes on. I need the squares/screen to refresh every hour. Help!

void setup(){

size(590, 590); background (20); }

void draw(){

int x = 10;

float s = map(second(),0,59,0,(width-x)); float m = map(minute(),0,59,0,(height-x));

noStroke(); rect(s, m, 10, 10); }

Answers

  • edited January 2016

    Look, so you did that to be dependant on current time. If you want that to be timer (count time since you start a program), you need to use millis().

    If this is actually a clock, but not a timer and you want to refresh screen at the beginning of each hour, you can use:

    if (m == 0 && s == 0){
    background(20);
    }
    
Sign In or Register to comment.