Algorithms with myBlocks

You have actually been creating algorithms since you first started coding.  Only, you may have not been naming these algorithms, which means that you cannot re-use them.  You can encapsulate an algorithm by using abstraction to create your own custom-built "block" in Scratch.  my block

 

For this example, let's create algorithms for drawing different shapes.  Once we name these algorithms with their own block, we can re-use them as often as we'd like.  

Decomposition

  1. Create a sprite that will "draw" a shape at a random point on the screen
  2. Create an algorithm for the following shapes:
    1. square
    2. triangle
    3. circle
  3. When you click the flag, "call" (i.e., use) your new blocks several times.

Play media comment.