Page 95 - TP_Play_V2.1_class5
P. 95
USE OF LOOP BLOCKS
All the programs or projects developed till now run only once. If you want to run
a set of statements more than once, you will either run the code again or write
the script again. In Scratch, we can save our time and effort by repeating the code
without writing the program again or writing the script again. The automatic
running of a set of instructions more than once is called looping. The blocks for
looping are given in the Control category.
The repeat block is used to run a set of instructions for a specified
number of times.
The repeat until block is used to run a set of instructions till a condition
is satisfied.
The forever block is used to run a set of instructions continuously
until stopped. The instructions inside this block will be executed in a
loop until the Stop button is clicked by the user.
The Repeat and Repeat Until blocks can be used to display the table of a number
input by the user. The script for the sprite can be like this (using the Repeat Until
block). Following is the script for displaying table of a number:
The output of the program will be similar to this.
You can also use the forever and repeat blocks with if...then block.
Let us make a small script. Change the sprite to butterfly and change the backdrop
to flowers.
Creating a Game in Scratch 93

