Page 81 - iPlus_Ver_2.0_class_6
P. 81

To draw a pattern, follow the given steps:


                            2  Code the Sprite.                  3  Click on Go button to see the pattern.






















                                                        1  Delete the cat Sprite
                                                        and add a new Sprite.



                 You can change the Sprite, the values of blocks and create new patterns.
                  i +  USE OF CONDITIONAL CONTROL BLOCKS

                 Many times, you have to do a task which is dependent on some condition. For example, you have
                 to make mango shake. There are two conditions:

                 a.   Go to the refrigerator and check if there are mangoes. If mangoes are there, then you will
                    make mango shake.
                 b.   If the mangoes are not there, you will make cold coffee.

                    Here the condition is the availability of mangoes.
                    We can also write this in two ways:
                    1.  if                                          2.  if
                           mangoes are available                           mangoes are available

                       then                                            then
                           make the mango shake                            make the mango shake

                                                                       else

                                                                           make cold coffee

                          In such situations we use conditional blocks. Scratch has two conditional blocks. They are:
                 1.   If…then block: In this block if the condition is true, the blocks inside conditional block will
                    run. If the condition is false, the blocks inside conditional block will not run. Only the blocks
                    outside the conditional block will run.

                 2.   If…then…..else block: In this block if the condition is true, the blocks inside then condition
                    will run. If the condition is false, the blocks inside else condition will run.






                                                                                                                  79
                                                                           Scratch Programming—Game Creation
   76   77   78   79   80   81   82   83   84   85   86