Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make an FPS counter
- zekrom1407
-
28 posts
How to make an FPS counter
The title pretty much says it all. I'm not sure how to make an FPS counter, so can someone help me figure it out maybe? 

- Flipped_
-
500+ posts
How to make an FPS counter
Hmm, I've never done it myself, but I would begin with
That variable would be the length of time it took for the time to go from 0 to over 0.3, you could take it from there since I'm not sure how I would convert that variable into a framerate.
when green flag clicked
forever
reset timer
repeat until <(timer) > [0.3]>
change [var v] by (1)
end
end
That variable would be the length of time it took for the time to go from 0 to over 0.3, you could take it from there since I'm not sure how I would convert that variable into a framerate.
Last edited by Flipped_ (March 3, 2019 19:58:24)
- Kraken_Games
-
100+ posts
How to make an FPS counter
Aha
(Frames Per Second)
(Counter)
when green flag clicked
forever
set [Frames Per Second v] to [(Counter)]
set [Counter v] to [0]
end
when green flag clicked
forever
change [Counter v] by (1)
end
- sippingcider
-
500+ posts
How to make an FPS counter
FPS stands for Frames Per Second. In other words, how many frames are rendered in one second.
Edit: I had a bunch of other stuff written here that wasn't needed, since the forever loop yields this will work fine.
When green flag clicked
reset timer
set [lastFPSUpdate v] to [0]
forever // so the fps continues to get updated
change [frames v] by (1) // 1 frame has been updated
if <(timer) > ((lastFPSUpdate) + (1))> then //checks if it has been 1 second since the last fps update
set [FPS v] to (frames) //number of frame updates that happened during that 1 second
set [frames v] to [0] //reset frames for the next 1 second calculation
set [lastFPSUpdate v] to (timer) //reset our lastFPSUpdate variable for the next 1 second calculation
end
end
Edit: I had a bunch of other stuff written here that wasn't needed, since the forever loop yields this will work fine.
Last edited by sippingcider (March 4, 2019 00:02:12)
- gor-dee
-
1000+ posts
How to make an FPS counter
foreverput the two blocks at the end of an existing forever loop
set [FPS v] to ((1) / (timer))
reset timer
end
Last edited by gor-dee (March 4, 2019 00:51:03)
- sippingcider
-
500+ posts
How to make an FPS counter
foreverput the two blocks at the end of an existing forever loop
set [FPS v] to ((1) / (timer))
reset timer
end
Oh wow, that is a really elegant way of doing it. You should try doing a scratch-golf competition!
- -Snipet-
-
500+ posts
How to make an FPS counter
Wow, that’s efficientforeverput the two blocks at the end of an existing forever loop
set [FPS v] to ((1) / (timer))
reset timer
end
- zekrom1407
-
28 posts
How to make an FPS counter
Wow, that’s efficientforeverput the two blocks at the end of an existing forever loop
set [FPS v] to ((1) / (timer))
reset timer
end
yeah that is pretty nice
- colinmacc
-
1000+ posts
How to make an FPS counter
I usually put one in all my games, just to check how well it's running. Basically this is the main repeat loop..
reset timer
repeat until <(playing) = [FALSE]>
change [tick v] by (1)
set [FPS v] to (round ((tick) / (round (timer))))
Do everything else...
end
Last edited by colinmacc (March 4, 2019 15:33:05)
- MrSquirrelDeDuck
-
100+ posts
How to make an FPS counter
I agree that
Is very efficient but it gives you a large decimal, I used
forever
set [FPS v] to ((1) / (timer))
reset timer
end
Is very efficient but it gives you a large decimal, I used
forever
set [FPS v] to (round ((1) / (timer)))
reset timer
end
- ZXMBXES
-
4 posts
How to make an FPS counter
FPS stands for Frames Per Second. In other words, how many frames are rendered in one second.When green flag clicked
reset timer
set [lastFPSUpdate v] to [0]
forever // so the fps continues to get updated
change [frames v] by (1) // 1 frame has been updated
if <(timer) > ((lastFPSUpdate) + (1))> then //checks if it has been 1 second since the last fps update
set [FPS v] to (frames) //number of frame updates that happened during that 1 second
set [frames v] to [0] //reset frames for the next 1 second calculation
set [lastFPSUpdate v] to (timer) //reset our lastFPSUpdate variable for the next 1 second calculation
end
end
- -InsanityPlays-
-
1000+ posts
How to make an FPS counter
Here's a simple one. Go to the backdrop sprite and make two backdrops then make this:
when green flag clicked
forever
switch backdrop to [backdrop1 v]
switch backdrop to [backdrop2 v]
end
when backdrop switches to [backdrop1 v]
reset timer
when backdrop switches to [backdrop2 v]
set [fps v] to ((1)/(timer))
Last edited by -InsanityPlays- (June 11, 2020 10:08:28)
- Lightthefox
-
13 posts
How to make an FPS counter
i have found a method that works in scratch 2 and 3

when green flag clicked
foreveri can not put the flag on the other stuff sorry but here is a picture for scratch 3 it is exactly the same
change [count v] by (1)
wait (0) secs
if <(timer) > [1]> then
reset timer
set [fps v] to [count]
set [count v] to [0]
end
end

Last edited by Lightthefox (July 29, 2020 06:35:09)
- maDU59_
-
59 posts
How to make an FPS counter
Very usualyforeverput the two blocks at the end of an existing forever loop
set [FPS v] to ((1) / (timer))
reset timer
end
- Vanilla2011
-
500+ posts
How to make an FPS counter
Who are you, so wise in the ways of Scratch coding?foreverput the two blocks at the end of an existing forever loop
set [FPS v] to ((1) / (timer))
reset timer
- THECODEWARRIORS
-
100+ posts
How to make an FPS counter
I have made a fps and turbo mode detector engine here you go - https://scratch.mit.edu/projects/422364988/
- dominic305
-
500+ posts
How to make an FPS counter
Here's a way that doesn't require the timer to be reset:
when gf clicked
set [oldTimer v] to [0]
forever
set [FPS v] to (round([1]/((timer)-(oldTimer)))
set [oldTimer v] to (timer)
end
- WolfMike6
-
100+ posts
How to make an FPS counter
I dont know how to make on either. i want to know!
https://scratch.mit.edu/studios/27775551/projects/
the best game series ever!
https://scratch.mit.edu/studios/27775551/projects/
the best game series ever!
- Discussion Forums
- » Help with Scripts
-
» How to make an FPS counter