From the course: Coding for Visual Learners: Learning JavaScript from Scratch

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Frame, frameRate, frameCount

Frame, frameRate, frameCount

- [Narrator] In the previous chapter, we saw some of the variables p5.js makes available for us. One important thing to note is that these variables can only be used from inside the p5.js functions, set up and draw. If you're going to try to use them outside these functions you will get an error saying that they're not declared. Let's see another useful variable that p5.js makes available for us, which is frameCount. Remember how we defines account variable in the previous chapter, to be able to count a number of times that the draw function is getting called. You can actually use the variable called frameCounts that p5.js provides for us for the same purpose. FrameCounts is a variable that keeps count of the number of times that the draw function is called throughout the lifetime of the program. By default, the draw function is called a maximum of 60 times per second, a setting called frameRates inside p5.js determines…

Contents