Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do i make a FPS counter?!?!?!
- danboy12342
-
Scratcher
24 posts
How do i make a FPS counter?!?!?!
HI,
i need some help.
i need a fps counter but cant quite make one?
i need some help.
i need a fps counter but cant quite make one?
- gor-dee
-
Scratcher
1000+ posts
How do i make a FPS counter?!?!?!
put this in your main game loop
set [FPS v] to (round ((1) / (timer)))
reset timer
- codeman1044
-
Scratcher
1000+ posts
How do i make a FPS counter?!?!?!
There's another way to do this that I prefer, as it doesn't mess with the timer. It does take a couple more blocks, but it works fine.
There's going to be a couple of variables: fps (don't show this one) and FPS (the one that you will show)
There's going to be a couple of variables: fps (don't show this one) and FPS (the one that you will show)
when gf clickedExplanation: FPS stands for frames per second. It takes one frame for a forever loop to run once. Therefore, in one second, you can run a forever loop X amount of times based on your FPS. If you keep changing a value by one each frame, that value will reach your fps each second.
forever
change [fps v] by (1)
end
when gf clicked
forever
wait (1) secs
set [FPS v] to (fps)
set [fps v] to (0)
Last edited by codeman1044 (May 20, 2019 12:26:42)
- deck26
-
Scratcher
1000+ posts
How do i make a FPS counter?!?!?!
There's another way to do this that I prefer, as it doesn't mess with the timer. It does take a couple more blocks, but it works fine.Presumably less reliable as the project slows down. The wait block is less accurate than the timer.
There's going to be a couple of variables: fps (don't show this one) and FPS (the one that you will show)when gf clicked
forever
change [fps v] by (1)
end
when gf clicked
forever
wait (1) secs
set [FPS v] to (fps)
set [fps v] to (0)
- codeman1044
-
Scratcher
1000+ posts
How do i make a FPS counter?!?!?!
I guess… it's just that I prefer it. The fps might be off by one or two frames if it slows down, but I've tested this and it works fine at 20+ fps (never have seen it go lower).
I use a lot of projects that rely on the timer. Just put that code up in case anyone else had the same case.
I use a lot of projects that rely on the timer. Just put that code up in case anyone else had the same case.
- gor-dee
-
Scratcher
1000+ posts
How do i make a FPS counter?!?!?!
I guess you could do
set [ FPS v] to (round ((1) / ((timer) - (oldTime))))if the timer was used elsewhere (unless it's being reset all the time)
set [oldTime v] to (timer)
- LifeTecLoverYT
-
Scratcher
33 posts
How do i make a FPS counter?!?!?!
does turbo mode mess up the fps counter?
- LifeTecLoverYT
-
Scratcher
33 posts
How do i make a FPS counter?!?!?!
another fps counter example
when green flag clicked
forever
change [counter v] by (1)
wait (0) secs
if <(timer) > [1]> then
reset timer
set [FPS v] to (counter)
set [counter v] to [0]
end
end
Last edited by LifeTecLoverYT (April 24, 2020 10:11:09)
- potatomanABC
-
Scratcher
14 posts
How do i make a FPS counter?!?!?!
another fps counter examplebruh that was from FUNUT/Professor Blue…when green flag clicked
forever
change [counter v] by (1)
wait (0) secs
if <(timer) > [1]> then
reset timer
set [FPS v] to (counter)
set [counter v] to [0]
end
end
- Lightthefox
-
Scratcher
13 posts
How do i make a FPS counter?!?!?!
You can do:
when green flag clickedi hope its correct
forever
change [cnt v] by (1)
wait (0) secs
if <((ownTime v)) > [1]> then
set [ownTime v] to (0)
set [FPS v] to (cnt)
set [cnt v] to [0]
end
end
when green flag clicked
forever
change [ownTime v] by (0.1)
wait (0.09) secs
end
Last edited by Lightthefox (April 13, 2021 09:58:41)
- Ankit_Anmol
-
Scratcher
500+ posts
How do i make a FPS counter?!?!?!
put this in your main game loopThis is GENIUS! thanks for showing me this!!!!set [FPS v] to (round ((1) / (timer)))
reset timer
- Proforce101
-
Scratcher
100+ posts
How do i make a FPS counter?!?!?!
I LIKE DOGEput this in your main game loopThis is GENIUS! thanks for showing me this!!!!set [FPS v] to (round ((1) / (timer)))
reset timer
- ThinkAlt_DJ
-
Scratcher
1 post
How do i make a FPS counter?!?!?!
Thanks for using the fps

put this in your main game loopif I press to stop, it will change the text that says “infinite” the block is soset [FPS v] to (round ((1) / (timer)))
reset timer

- helloworldbyeworld
-
Scratcher
1000+ posts
How do i make a FPS counter?!?!?!
Thanks for using the fpsThis is the simplest FPS counter that doesn’t have this bug that I can think of:put this in your main game loopif I press to stop, it will change the text that says “infinite” the block is soset [FPS v] to (round ((1) / (timer)))
reset timer
when green flag clicked
forever
reset timer
set [FPS v] to ((1) / (timer))
wait ((1) / (30)) secs // max 30 FPS
end
when [timer v] > (0.3)
set [FPS v] to [-]
If you have a thumbnail, show the thumbnail here::grey
- PopzearX
-
Scratcher
26 posts
How do i make a FPS counter?!?!?!
Make variables:
Create a Variable named “Frame” and create another one named “FPS” and then hide Frame!
a real fps counter script:
i hope that helped a lot!
also here is the fps counter project: FPS COUNTER
Create a Variable named “Frame” and create another one named “FPS” and then hide Frame!
a real fps counter script:
when green flag clicked
forever
change [Frame v] by (1)
end
when green flag clicked
forever
wait (1) secs
if <(Frame) > [31]> then
set [FPS v] to [31]
else
set [FPS v] to (Frame)
end
end
i hope that helped a lot!

also here is the fps counter project: FPS COUNTER
Last edited by PopzearX (July 18, 2024 06:01:37)
- Discussion Forums
- » Help with Scripts
-
» How do i make a FPS counter?!?!?!