Yes! There is a function called “modulo” that allows you to make things happen on a specified interval. It basically does a division problem and looks at the remainder of the problem, so every time through the draw loop, it divides the WorldSeconds by 30 and looks at only the remainder. If the remainder is 0 (or any other number really), you can have a variable update…
In this case, the student needs to create the variable (such as
var score = 0;) at the top of the code. Then, I would suggest moving the score blocks right below the black background code in the main draw loop. Then, instead of hard coding the score as 1, 2, 3, 4, etc, use the name of the score variable.
Finally, I’ll help you with the modulo as it is a little out of scope for CSD, but it’s pretty simple code… You can see that the timer function will now only do one thing … look for when the modulus is 0 and change the score variable. Then, the main program displays the score when it updates the background.
Hope this helps!