Page 53 - PlusGPT_V2.1_C1_Flipbook
P. 53

Control Block

                 They have looping blocks which are used when the same blocks have to be repeated for a number of
                 times. The most commonly used control blocks are:

                                block pauses the running of the script for the number of seconds given in the block. You
                   can use this block when two move or speak blocks are coming one after the other.

                    The repeat block repeats a set of blocks for a given number of times. This block is also used to draw
                   shapes where we have to give the same blocks again and again for a number of times.
                    The forever block keeps on repeating a set of blocks till the stop button is clicked.
                   This block is similar to repeat block and expands automatically to accommodate

                   the blocks you snap inside it.

                  Let’s practice                                                                  Computational Thinking


                   Write the script for the cat sprite to say Meow 10 times without stopping and then move 20
                   steps.
                     This should happen













                      a.  when the Go button is clicked,           b.  when the sprite is clicked.



                        SETTING THE SPRITE POSITION


                 The stage is divided into different values of x and y. Each dot on the stage is made up of both x and y
                 values. The value of x gives the horizontal (left to right) location of the Sprite.

                 The value of y gives the vertical (top to bottom) location of the Sprite. The centre of the stage has x
                 and y values as 0.

                                block helps you to fix the position of the sprite at the beginning of a script. Sometimes
                 due to some scripts, the sprite goes beyond the stage. This block helps to bring the sprite to the desired
                 location.


                       REPEAT BLOCK


                 If you want to repeat a block of code a fixed number of times, the Repeat block is used. With the
                 Repeat block, you can draw Polygons. Examples of polygons are triangle, square, pentagon, hexagon,
                 heptagon, octagon, nonagon, decagon, etc.



                                                                                              Scratch Programming  51
   48   49   50   51   52   53   54   55   56   57   58