Page 73 - CloudGPT_C5_Flipbook
P. 73

Let us make a small script.

                   Change the sprite to butterfly and change the backdrop to flowers.

                 Drag the Event block, when Green Flag clicked to the script area.
                 Drag the control block, forever to the script area and put it to the
                 Green Flag block. Drag the move block and put it inside the forever

                 block. Now, drag the if on edge, bounce block and put it inside the
                 forever block.

                 Now, put the control block if, then inside the forever block and snap
                 the sensing block, touching color  in the hexagon of the if loop.




                                                 The butterfly changes colour and size
                                                 when it touches the colours selected in
                                                 the touch block.

                                                 Similarly, you can create scripts with

                                                 two  sprites, and  they  change  colour
                                                 when they touch each other.






                                   Suppose, you have to code a dance party in Scratch where characters keep dancing
                                   in a loop until stopped? Which block will you use for this and which songs would you
                                   play in the program?


                 LOOPS


                 All the programs or projects developed till now ran 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 Control category.

                 The Repeat block is used to run a set of instructions for a specified number of             repeat  10

                 times.

                 The Repeat until block is used to run a set of instructions till a condition is         repeat  until
                 satisfied.

                 The Forever block is used to run a set of instructions continuously until stopped.          forever
                 The instructions inside this block will be executed in a loop until the Stop button
                      is clicked by the user.





                                                                                                 More on Scratch   71
   68   69   70   71   72   73   74   75   76   77   78