Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Jose Morales-Mendizabal19,175 Points
Why not call Tick() every 1000ms instead of doing the Math?
I'm not quite sure why Guil is calling the Tick function every 100ms and then doing the extra computation of dividing the value by 1000, instead of just configuring the the setInterval() to run every 1 second (1000ms)
Because it is not always accurate.. https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Reasons_for_delays_longer_than_specified
This is why Guil is tracking current time and previous time to make sure that timing is accurate