xxxxxxxxxx
46
/********** The Broken Stopwatch **********
The code for this stopwatch is missing some parts.
Can you get it to work?
1. Debug and fix the code errors.
2. Start and stop the timer.
3. Count the time in seconds.
4. Display the timer in 00:00 (minutes and seconds)
Extra stuff:
1. Can you add a reset button?
2. Can you count by 1/10th of a second?
******************************************/
var startButton, stopButton;
var time = 0;
function setup() {
createCanvas(500, 300);
// Create a start button on the right side of the screen
startButton = createButton('Start');
startButton.position(width - 160, height - 60);
startButton.mousePressed(startTimer);
}
function draw() {
// Draw the timer background
background(230);
rect(50, 90, width-100, 100);
// Draw the timer
textSize(92);
textAlign(RIGHT);
text(time, 50, 100, width-100, 100);
if (timerIsRunning) {
// Do something?
}
}