Last active
August 29, 2015 14:27
-
-
Save tomluyten/24048a9c35a5c300fa72 to your computer and use it in GitHub Desktop.
This file contains 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
//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