Discuss Scratch

shopperkeeps
Scratcher
22 posts

How fast is Scratch moving 10 steps?

Self-explanatory. How much time is moving 10 steps?

Last edited by shopperkeeps (July 29, 2021 11:12:47)

dertermenter
Scratcher
1000+ posts

How fast is Scratch moving 10 steps?

I think it’s just 1 frame. Scratch runs at 30 frames for 1 second.

Any distance with the move block is 1 frame
Vadik1
Scratcher
500+ posts

How fast is Scratch moving 10 steps?

The answer is quite complicated.
The block itself has no defined time, it runs almost instantly and time is based entirely on how fast your computer is. There is another thing though that slows it down. And to understand it, you will need to know about “screen updates” and “script passes”(this doesn't really have a name, but I will call it this way).

One script pass is when scratch passes through all scripts in the project that need to run and runs them by 1 step. All loops run one iteration per script pass. So if you have 2 forever loops activated simultaneously, with no delays in them, scratch will run one iteration in first loop, then one iteration in second loop, which will be counted as one script pass, after which it does it again, and again, and so on. By default scratch tries to run at as many script passes as you computer is able to. That is the reason why if you try running
set [my variable v] to (0)
repeat (10000)
change [my variable v] by (1)
end
on it's own, while the rest of the project isn't running, it will complete very quickly.

However, if during script pass execution, there were any blocks that change anything related to what is shown on stage, like moving visible sprites, changing their costumes, size, effects, showing or hiding them, drawing with pen, and so on, it will mark that script pass as the one causing a screen update, also reffered as frame. If it is marked as such, it means that after that script pass finishes it will have to make a screen update before starting next script pass. Screen update is basically scratch clearing the stage and redrawing everything on it(background, sprites, etc.), which happens so fast that you can't see it. (There is actually other reason, but I wouldn't mention it to not overcomplicate things)
The thing is, screen updates are limited to happening not more frequently than once every 0.0333 seconds or in other words 30 times per second. And since scratch waits for screen update to complete before starting next screen pass, in most projects scratch ends up running all scripts in active loops only 30 times per second.
That is why:
when flag clicked
forever
move (10) steps
end
will only run at speed of 30 times per second, and that is also why:
when flag clicked
forever
move (1) steps
move (1) steps
move (1) steps
move (1) steps
move (1) steps
move (1) steps
move (1) steps
move (1) steps
move (1) steps
move (1) steps
end
will also run 30 times per second despite being 10 times more blocks.
Another thing you can test is making a project that doesn't cause any screen updates. That means script passes will not be limited by 30 screen updates per second, so the project will run at as many script passes per second as your computer can handle.
For example:
when flag clicked
show
repeat (10000)
move (0.1) steps
end
will take a lot of time to complete, while
when flag clicked
hide
repeat (10000)
move (0.1) steps
end
will finish running very quickly.

As a side note: turbo mode disables dependency of script passes on screen updates, which allows project to run at high amount of script passes per second, while still causing only 30 screen updates per second.
wvj
Scratcher
1000+ posts

How fast is Scratch moving 10 steps?

approximately 0.03 seconds
D-ScratchNinja
Scratcher
1000+ posts

How fast is Scratch moving 10 steps?

Here's basically the explanation from post #3 in a nutshell. If one of your scripts runs and ends up refreshing the screen, then in this case, the script below will move the sprite 3 steps once per 1/30th of a second (a Scratch frame) 10 times. That's because Scratch basically animates motion and screen refreshes because at the end of a loop before it is restarted (unless you turn on Turbo Mode), it waits for the next frame so you can see your sprite moving one bit at a time.
repeat (10)
move (3) steps
end

That also means if you stack those blocks, the pause doesn't occur until the end of the loop, so this will still make your sprite move 3 steps per frame.
repeat (10)
move (1) steps
move (1) steps
move (1) steps
end

And the other part where the pausing only happens when the screen is refreshing means that this script below can run as fast as possible if there isn't any action, but will be limited to 30 loops per second if there is action.
repeat (10)
change [my variable v] by (1)
end
Chiroyce
Scratcher
1000+ posts

How fast is Scratch moving 10 steps?

If it's running when you click on a stack of blocks, it runs instantly. If it's running after you click the flag, approximately 0.03 seconds on a 30Hz or higher refresh rate display.

Powered by DjangoBB