Page 73 - IT_V5.0_Class8
P. 73

Example 2: Moving a sprite to a random position at 90 degrees

                 Follow the given steps:
                 Step 1:  Drag and drop the when clicked block from the Events category.
                 Step 2:  Drag the go to block and drop it below the when clicked block.
                 Step 3:  Drag the glide block and drop it below the go to block.

                 Step 4:  Drag the point in direction block and drop it below the glide block.
                 Step 5:  Drag the glide block and drop it below the point in direction block.
                 Step 6:   Click on the Green Flag button. The sprite moves to a random position, glides for 1
                           second to another random position, points in the 90-degree direction, and then glides
                           to a final random position when the green flag is clicked.




























                 Example 3: Making a sprite moves to a specific position, changes its position by 10 units along
                 the x-axis, and bounces back if it touches the edge.
                 Follow the given steps:

                 Step 1:   Drag and drop the
                           when clicked block
                           from  the  Events
                           category.
                 Step 2:   Drag  the  go  to  x
                           block and drop  it
                           below  the  when
                           clicked block.
                 Step 3:   Drag the change x
                           by block and drop
                           it below the go to
                           x block.
                 Step 4:   Drag the If on edge, bounce block and drop it below the change x by block.

                 Step 5:  Click on the Green Flag button to see the output.



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