Timer in Game Lab

One of my students is trying to use a timer in game lab. He used the example code that we found on the forum, but its still not working. This is what we used…

Can anyone help us figure out the problem? The word score appears, but there is no number value next to it.
Than YOU!

Hi @ekitzel,

The code is very close!!! When you create a variable inside the draw loop it is like creating the variable 32 times a second. I think of it as resetting the variable 32 times per second but not sure that is programmatically accurate:) To resolve the issue, try creating the variable “time” above the draw loop and then inside the draw loop, set its value (so the var only exists outside the draw loop).

~Michelle

We are still having trouble getting it to work. What is the value for variable above the draw loop? We set it to 0. The one inside the draw loop, was also set to zero. I am still not sure what we are doing wrong.

Yes - you can set the “time” variable above the draw loop to zero with the var. The “time” variable inside the draw loop does not have a var and it would be set as you did in the shared project:
time = 10-World.seconds; (without the var).

~Michelle

1 Like