xxxxxxxxxx
27
class Metro {
constructor(_ms) {
this.ms = _ms;
this.timestamp = millis();
}
bang(_ms) {
if ((this.timestamp + this.ms) < millis()) {
this.timestamp = millis();
return true;
}
return false;
}
}
var metro;
function setup() {
createCanvas(400, 400);
metro = new Metro(1000);
}
function draw() {
background(220);
if (metro.bang()) {
print("500ms");
}
}