Created
November 22, 2016 20:23
-
-
Save slambert/3a67218b1d7ead0007334827a4f0f28b to your computer and use it in GitHub Desktop.
This is a demo of how millis works
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Steve is the best | |
// It seems he can do anything. | |
// November 22, 2016 | |
int startTime = 0; | |
int currentTime = 0; | |
int endTime = 15000; | |
void setup() { | |
size(512, 512); | |
} | |
void draw() { | |
println("startTime: "+startTime); | |
println("currentTime: "+currentTime); | |
println("endTime: "+endTime); | |
currentTime = millis(); | |
// background(125); | |
// println("millis: "+millis()); // show me the time! | |
// if (millis() >= 5000) { // 5000 = 5 seconds | |
// background(255, 0, 0); | |
// } | |
if (currentTime >= endTime){ // if we get to the endTime.... | |
startTime = currentTime; // it resets itself!! | |
endTime = currentTime + 5000; // another 5 seconds | |
background(random(255)); | |
} | |
} | |
void keyPressed() { | |
if(key == 'r'){ | |
// println("millis: "+millis()); // show me the time! | |
startTime = currentTime; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment