so i'm playing around with p5js and made a ball bounce while at the same time lose momentum after each bounce. I want to be able to make the ball reset after 30 seconds or a minute has passed. So i'm basically resetting the sketch after a minute, does anyone how to go about that? i know i have to use minute() or millis() but can't quite figure it out. Here's my code:
var py = 100 // postion y
var spd = 5 // speed
var gravity = 0.1
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
fill('red');
stroke('blue');
ellipse(width/2, py, 25, 25);
py = py + spd;
spd = spd + gravity;
if (py > 400 || py < 0) {
spd = -0.95 * spd;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.0.0/p5.min.js"></script>