Page 89 - 2502_Pakistan-kifayat_C-8
P. 89

To move a sprite forward by a total of 100 steps, use the following script:















                    forever block: The forever block runs continuously without stopping. It is useful
                   when you want something to keep happening, like making a background keep
                   moving.

                 To make a sprite say "Hello!" repeatedly, use the following script:

















                 Complex Loops

                 A repeat until block in Scratch keeps performing an action again and again
                 until a certain condition is met. The repeat until block is used to create a loop
                 that stops when a condition is true. For example, a sprite can keep moving
                 until  it  touches the  edge  of  the  screen. This  loop  helps  you  repeat tasks
                 without knowing exactly how many times, but you know when to stop.

                 For example, if you want a sprite to keep moving forward until it touches the edge of the screen, you
                 would use the repeat until block. This loop makes the sprite move again and again until it reaches the
                 edge, and then it stops automatically.

                 To move a sprite until it touches the edge, use the following script:

















                 The                       block found in the Sensing category, detects if a sprite is touching any of the

                 four edges of the stage.


                                                                                     #Intermediate Level Programming  87
   84   85   86   87   88   89   90   91   92   93   94