Could someone help me make a good FPS counter?

Guys, I need help. I'm trying to create a "simple" flashlight in my game, but there's one big issue: using the flashlight causes a significant frame drop. I wanted to implement an FPS counter so I can adjust the player's velocity dynamically, ensuring it stays consistent at both 30 FPS and 60 FPS. Now, I have never used Snap before, I used scratch and in scratch, making an FPS counter is preatty easy, but I quickly found out that things are different here. So I looked through some older posts about FPS counters and found one that I thought would work. Unfortunately, it only updates once per second, but I need it to check the FPS every single frame. I tried tweaking it, but i broke it :confused:

Can anyone help me out?

Btw if u guys need to see what I tried doing, heres my project:
Snap! Build Your Own Blocks (u can find the FPS code in the stage)
And heres the project I "borrowed" :wink: the code from:
Snap! Build Your Own Blocks


Every loop of the forever changes the variable "Frame" by 1. This is compared to the time elapsed to determine how many loops occur per second. Note that for a brief moment the FPS will be infinity, because the timer will be zero and will cause a division by zero.

If you need the timer for something else, here is a method that doesn't reset the timer on flag click:

PS: If you are wondering why the move 0 steps block, it is because of a new Snap feature which crams tons of loops into one frame if the loop doesn't do anything visually (e.g. move). This can be worked around with the move 0 steps block.

oh ma gah, ty :pray:

hmm. Unfortunately, the frame rate updates too slowly. I expected it to work like Scratch, where if the FPS drops from 60 to 30, it would instantly display 30 instead of gradually decreasing. Is there some way to make it immidiently change?

I just found this:

Importable script pic:


Good luck with your project!

it works, tank u :3

This is not a smart script pic. I remade the script, though, and it's cool watching my fps drop a bit gradually every ~5 seconds with this block

Maybe instead of always just saying "that's not a smart script pic" when you can't drag and drop it, take a step back and try to click the image to make it bigger, then download the image, then drag and drop it into snap.

I'm only saying this, because you've said this exact thing many times when I've been able to get the script from the image myself (just saying, I was able to import this specific script).

I did. If I could send a video of myself dragging and dropping the image from my files app into the Snap! editor, I would.
This may just be an issue with ChromeOS now.

Yeah, maybe import it into snap with the file > import option.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.