I'm attempting to build an app in Processing.js that rotates an array of objects every 15 min (seconds for now). My idea was to just increment the index every time the second hand strikes 0/15/30/45, but since it's inside a draw loop it executes +1 times every frame in that second, setting my index to like, 30. How can I ensure only one increment gets through?
var i = 0;
var draw = function() {
background(148, 221, 255);
var s = second();
var m = minute();
var h = hour();
text(h + " : " + m + " : " + s, 5, 395);
var Rotation = function() {
if (s === 0 || s === 15 || s === 30 || s === 45) {
i+= 1;
Array[i];
}
};
Rotation();
text(i,50,50);
};
Thanks