Page 62 - ModularV1.1 _c5_flipbook
P. 62

touching  color       ?         Becomes true when the sprite touch-
                                                            es a defined colour
                         color      is touching     ?       Becomes  true when  color1 touches
                                                            color2


                          key space  pressed?               Becomes true when a defined key is
                                                            pressed on the keyboard


                   ask  What's your name?  and  wait        Asks a question to the user and waits
                                                            for the answer

                                      answer                Stores the answer or input given by
                                                            the user



                                                        Let us develop a simple program
                                                        where  the cat  sprite moves
                                                        towards  a basketball when the
                                                        right arrow key is  pressed. The
                                                        code  for  the  cat  sprite  can  be
                                                        similar to this.                               Sensing block



                      STORING USER INPUT

                  The program can also be developed to take input from the

                  user. Earlier, we developed a program  to divide 12 by 5.
                  Scratch gives an option to take input from the user also. To

                  develop a program to divide two numbers and find the
                  quotient, define the script of the sprite as:
                  When the program is run, a small text input box opens at the

                  bottom of the stage. Type the value of the variable and press
                  the Enter key or click on the tick mark symbol on the right

                  side of the text box. The final output of the program will be
                  similar to this.



















                  60      Modular (Ver. 1.1)-V
   57   58   59   60   61   62   63   64   65   66   67