Control blocks in Scratch look like as shown above in the image. It has different blocks which can be categorised into three sections 👍
- Wait, repeat and Forever
- If , if else, wait until and repeat until
- Clone blocks
Let’s understand wait, repeat and Forever blocks with examples
Here in the code shown below, the sprite (cat) says hello after a gap of 3 seconds after the flag is clicked.
Output of the code :
2. Repeat block in Scratch
The code blocks kept inside the repeat block are executed by the computer the number of times specified in the repeat block.
For Ex:-
When the flag is clicked, the sprite (cat) will turn by 15 degrees only 10 times as the turn 15 degrees is inside the repeat block which will run for 10 times.
Code: Output:
’
3.Forever block in Scratch
The code blocks kept inside the Forever block are executed by the computer forever unless the program is stopped.
For Ex:-
When the flag is clicked , the sprite (cat) will turn by 15 degrees forever
Code:.
Output:
Let’s understand the code blocks – if, if else, wait until and repeat until blocks with examples
- If a block comes with a condition. For example: in the code below, the condition is touching the edge of the screen. If the condition is true, the computer executes the code written inside the if block. Whenever the cat touches the edge of the screen, the cat will change the color as shown in the output.
Code:
Output:
- If else block , there is a section added to the code above which is else block. Whenever the condition attached to the if is false , the computer goes to the else block and executes the code written inside the else block. For Ex: – In the code below , the cat changes the color whenever it touches the edge of the screen. If the cat is not touching the edge of the screen, the cat will show the original colour.
Code:
Output:
3.Wait until block has a condition attached to it, the computer will not execute the code put inside the wait until block till the condition is wrong. The moment the condition is true, the computer will start executing the code written inside the wait until block. For Ex: In the code below, the cat will keep increasing its size till the time is less than 10. The moment the time touched the value 10, the cat will stop increasing its size.
4. Waits until a certain condition is met. Repeat wait() until basically just put the script on hold until whatever is after until is equal to true. repeat … until is a loop that will keep running until met with a condition.
Clone Blocks
Whenever the cat touches the edge, it creates copies of itself as shown in the image below.
Whenever the clone is created , delete the clone. Hence, you see only one cat in the output as the clones get deleted every time it’s created on touching the edge.
Output:
Hope this is useful, thank you.
You may like to read: Boolean Block in Scratch, Block Palette in Scratch, & Microbit & MicroPython Programming for Kids.