Skip to content

Instantly share code, notes, and snippets.

@tomluyten
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomluyten/24048a9c35a5c300fa72 to your computer and use it in GitHub Desktop.
Save tomluyten/24048a9c35a5c300fa72 to your computer and use it in GitHub Desktop.
//Object oriented timer by Daniel Shiffman (learningprocessing.org)
class Timer {
int savedTime; // When Timer started
int totalTime; // How long Timer should last
int passedTime;
Timer(int tempTotalTime) {
totalTime = tempTotalTime;
}
// Starting the timer
void start() {
// When the timer starts it stores the current time in milliseconds.
savedTime = millis();
}
// The function isFinished() returns true if 5,000 ms have passed.
// The work of the timer is farmed out to this method.
boolean isFinished() {
// Check how much time has passed
passedTime = millis()- savedTime;
if (passedTime > totalTime) {
return true;
} else {
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment