Discuss Scratch

Kami-ko
Scratcher
100+ posts

Deltatime is 0

Without much scripts running (just a game loop), Scratch reports a fps of over 30, usually 1000 or infinity. In cases like this I've just added a
wait () secs

after the tick block to “lower” the framerate a bit. My question is: is this the best way of going about it? Thanks!

Check out Super Battle Machine Boxing here!!!

Kami-ko is short for kami no ko (神の子)
Zerofile
Scratcher
100+ posts

Deltatime is 0

you could use broadcast recursion

Last edited by Zerofile (Sept. 8, 2020 22:54:52)


thanks for the website ST
Kami-ko
Scratcher
100+ posts

Deltatime is 0

Zerofile wrote:

you could use broadcast recursion
what's that?

Check out Super Battle Machine Boxing here!!!

Kami-ko is short for kami no ko (神の子)
Flowermanvista
Scratcher
1000+ posts

Deltatime is 0

Kami-ko wrote:

Zerofile wrote:

you could use broadcast recursion
what's that?
I presume they mean something like this:
when I receive [foo v]
...
broadcast [foo v]
which works because broadcasts force a 1 frame delay. I personally don't recommend this as infinite recursion will (very slowly) eat up all of the user's memory.

If you need to force a 1 frame delay, the solution you have is probably the best one - although anything that touches the screen will also cause a delay so that the updated screen can be shown (except on Turbo Mode). This means, for example, that moving a sprite, creating clones, using the pen, etc. will all make it wait 1 frame so that the updated screen is seen by the user. Even a block that seemingly does nothing (such as moving 0 steps) will cause a delay, so forcing one shouldn't be necessary once you add code to show the player, sprites, etc.

Add a SPOOKY SKELETON to your project!

The Scratch 3 Project Save Troubleshooter - find out why your project won't save

ST, Please Add A Warning When A Size Limit Is Exceeded

My Dumb Creations - THE BEST ANIMATION | The Windows 98 Experience (made on Windows 98) | nobody cares about Me… | the2000 Reveals His New Profile Picture | Not Dumb Creations - Ten Years
Ctrl+Shift+Down for more…
Do evil kumquats keep eating your signature? Assert your dominance and eat the evil kumquats. Did you know that kumquats are only about the size of an olive?
Kami-ko
Scratcher
100+ posts

Deltatime is 0

Flowermanvista wrote:

Kami-ko wrote:

Zerofile wrote:

you could use broadcast recursion
what's that?
I presume they mean something like this:
when I receive [foo v]
...
broadcast [foo v]
which works because broadcasts force a 1 frame delay. I personally don't recommend this as infinite recursion will (very slowly) eat up all of the user's memory.

If you need to force a 1 frame delay, the solution you have is probably the best one - although anything that touches the screen will also cause a delay so that the updated screen can be shown (except on Turbo Mode). This means, for example, that moving a sprite, creating clones, using the pen, etc. will all make it wait 1 frame so that the updated screen is seen by the user. Even a block that seemingly does nothing (such as moving 0 steps) will cause a delay, so forcing one shouldn't be necessary once you add code to show the player, sprites, etc.

I'm just trying to check If my current strategy to make delta greater than 0; not wait a frame.

Check out Super Battle Machine Boxing here!!!

Kami-ko is short for kami no ko (神の子)
Zerofile
Scratcher
100+ posts

Deltatime is 0

Flowermanvista wrote:

Kami-ko wrote:

Zerofile wrote:

you could use broadcast recursion
what's that?
I presume they mean something like this:
when I receive [foo v]
...
broadcast [foo v]
which works because broadcasts force a 1 frame delay. I personally don't recommend this as infinite recursion will (very slowly) eat up all of the user's memory.

~snip~
.

What will eat memory is putting two broadcasts, or a broadcast and wait.

With only one broadcast it will briefly run the two scripts at once and terminate the predecessor. So the script won't eat up memory

Last edited by Zerofile (Sept. 9, 2020 00:49:45)


thanks for the website ST
Flowermanvista
Scratcher
1000+ posts

Deltatime is 0

Zerofile wrote:

Flowermanvista wrote:

Kami-ko wrote:

Zerofile wrote:

you could use broadcast recursion
what's that?
I presume they mean something like this:
when I receive [foo v]
...
broadcast [foo v]
which works because broadcasts force a 1 frame delay. I personally don't recommend this as infinite recursion will (very slowly) eat up all of the user's memory.

~snip~
.

What will eat memory is putting two broadcasts, or a broadcast and wait.

With only one broadcast it will briefly run the two scripts at once and terminate the predecessor. So the script won't eat up memory
Huh, neat. TIL.

Add a SPOOKY SKELETON to your project!

The Scratch 3 Project Save Troubleshooter - find out why your project won't save

ST, Please Add A Warning When A Size Limit Is Exceeded

My Dumb Creations - THE BEST ANIMATION | The Windows 98 Experience (made on Windows 98) | nobody cares about Me… | the2000 Reveals His New Profile Picture | Not Dumb Creations - Ten Years
Ctrl+Shift+Down for more…
Do evil kumquats keep eating your signature? Assert your dominance and eat the evil kumquats. Did you know that kumquats are only about the size of an olive?

Powered by DjangoBB