Discuss Scratch

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?
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
danboy12342
Scratcher
24 posts

How do i make a FPS counter?!?!?!

thanks
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)
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)
Explanation: 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.

Last edited by codeman1044 (May 20, 2019 12:26:42)

deck26
Scratcher
1000+ posts

How do i make a FPS counter?!?!?!

codeman1044 wrote:

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)
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)
Presumably less reliable as the project slows down. The wait block is less accurate than the timer.
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.
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))))
set [oldTime v] to (timer)
if the timer was used elsewhere (unless it's being reset all the time)
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?!?!?!

LifeTecLoverYT wrote:

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
bruh that was from FUNUT/Professor Blue…
Lightthefox
Scratcher
13 posts

How do i make a FPS counter?!?!?!

You can do:
when green flag clicked
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
i hope its correct

Last edited by Lightthefox (April 13, 2021 09:58:41)

Ankit_Anmol
Scratcher
500+ posts

How do i make a FPS counter?!?!?!

gor-dee wrote:

put this in your main game loop
set [FPS v] to (round ((1) / (timer)))
reset timer
This is GENIUS! thanks for showing me this!!!!
Proforce101
Scratcher
100+ posts

How do i make a FPS counter?!?!?!

Ankit_Anmol wrote:

gor-dee wrote:

put this in your main game loop
set [FPS v] to (round ((1) / (timer)))
reset timer
This is GENIUS! thanks for showing me this!!!!
I LIKE DOGE
ThinkAlt_DJ
Scratcher
1 post

How do i make a FPS counter?!?!?!

Thanks for using the fps

gor-dee wrote:

put this in your main game loop
set [FPS v] to (round ((1) / (timer)))
reset timer
if I press to stop, it will change the text that says “infinite” the block is so
helloworldbyeworld
Scratcher
1000+ posts

How do i make a FPS counter?!?!?!

ThinkAlt_DJ wrote:

Thanks for using the fps

gor-dee wrote:

put this in your main game loop
set [FPS v] to (round ((1) / (timer)))
reset timer
if I press to stop, it will change the text that says “infinite” the block is so
This is the simplest FPS counter that doesn’t have this bug that I can think of:

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:
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)

Powered by DjangoBB