-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better implementation of setInterval #23
Comments
Hey :). Perhaps this explanatory comment would be more clear if it said:
|
Hi @theophani, your explanation is better, thank you. The main idea is to have x number of frames drawn per second. Once x is chosen the time per frame is then calculated. :) |
So should we improve the material? |
@xMartin I think we should improve the comments to be more concise and easy to understand for a beginner programmer. I propose this:
The simple arithmetic better explains how the |
Should still be improved, I guess. |
I was thinking of expressing whats going on in source code with good named variables.
|
Personally, I like your version a lot. I've experienced learners that found it much easier to understand code with lots of names, that were overwhelmed with magic numbers. On the other hand, some people do think in a more mathematical way and like the condensed way, playing with the numbers in place. I wonder if we can provide multiple versions of code. But that's probably going too far. With that said, I still think your version would be an improvement for most learners ;) Maybe we can add to the comments that this is equal to "draw a frame every 50 milliseconds". |
Yeah but "mathematical thinkers" will be able to handle the variable names too. |
@tobmaster Could you prepare a Pull Request? Would be highly appreciated. |
@xMartin sure |
The introduction to the function setInterval says:
setInterval(func, n)
is a way to run a function every n milliseconds yet during implementation n has to be computed like so:This is confusing. For consistency we could have the function take in millisecond units or have an explanation for the conversion.
The text was updated successfully, but these errors were encountered: