timing animations within draw()?
in
Programming Questions
•
1 year ago
Hi,
Im having difficulty creating a loading bar. Before we start this is for a uni assignment so i dont think i can paste my code on here. Basically we have to get a random number between 2000 and 8000. This represents how long the loading bar will take to reach 100%.
So far i have managed to do the following;
I have the endingTime calculated which is the randomly generated when the program begins.
I have a function set up which returns the percentage completed based on millis and endingTime.
The bar length is fixed at 120 pixels.
i am using a line of 1 pixel width. Therefore 120 lines would fill the bar.
So logic would dictate that we should draw 1 line every endingTime / 120 milliseconds or every 100/120 percent right? Is that right? If so could someone show me how i could accomplish this inside draw()? Since draw() is a loop, therefore using for / while inside just displays the whole loop once it reaches the end of draw.
How do i go about timing the bar so that is matches the percentage completed?
I have read over delay and frameRate but have been told using millis() is more precise.
Even if your not willing to show code could you please explain in detail what i should be trying to do since ive spent close to 30 hours trying to figure this out....
ive attempted to draw a line every endingTime/120 . But it would mean that a line would need to be drawn when less that 100ms. In console when i output millis(), it starts at around 500. Can someone explain to me why millis() does not start at 0. Is it because the console doesnt refresh that often?
1