Page 163 - Learn To Program With Scratch
P. 163




                                                                 
                                                                 
                                                                 



                                                                 








                          Figure 6-17: Script for the Guess My Coordinates game

                          2.  The script asks the user to enter the x-coordinate of the sprite and waits
                             for an answer.
                          3.  If the answer is correct, the script moves to step 4. Otherwise, it will call
                             the ShowAnswer procedure to display the correct coordinates of the
                             point.
                          4.  When the user enters the correct value for the x-coordinate, the script
                             prompts the user to enter the y-coordinate of the sprite and waits for an
                             answer.
                          5.  If the user answers correctly, the script displays the message “Good Job.”
                             Otherwise, it calls ShowAnswer to display the correct coordinates.

                             The ShowAnswer procedure is shown in Figure 6-18. The point variable
                          is first constructed to have a string of the form (X,Y) using the join operator.
                          The procedure then uses the say command to show the correct answer to
                          the user.












                          Figure 6-18: The ShowAnswer procedure





                                                                              Making Decisions   141

                                           www.it-ebooks.info
   158   159   160   161   162   163   164   165   166   167   168