Introduction



Scratch was developed by the Lifelong Kindergarten group at the MIT Media Lab as a tool to teach design, thinking, collaborating, communicating, analyzing, and programing in a computer language.

When you open Scratch, this is what you will see:
Scratch IDE

This is the Scratch Interface or Integrated Development Environment (IDE).

  • The Scratch interface is divided into
    1. The Blocks palette
    2. The Script editor
    3. The Stage
    In the middle you will see the Blocks palette:
    blocks.png
    Each type of block is color-coded so that you can identify them in your scripts.

    To create a script you drag, drop, and snap blocks into place in the Scripts area.

    Lingo
    Text from veritas.eecs.berkeley.edu



    Click the Presentation Mode button in the upper right hand corner when you want to present your project. To exit Presentation Mode, press the Esc key or the back arrow on the top left.

    Click the arrow between the windows to switch between small and large Stage view.

    You can use small Stage view to display Scratch on small screens or to expand the Scripts Area.



    Click the minus, equal or plus sign to resize your blocks.



    To find out what a block does, click on the help button.




    To drag a stack, pick it up from the top block.

    To delete a block, drag it from the script palette back towards the block palette.

    Click on any block to run the block.

    To stop a script, click the stop button at the top of the screen.




    Exercises

    1. Scratch is pretty intuitive. Complete this script:



    2. Sprites:
      1. Open Scratch


        • Sprites, like the catcat.png move and interact on the Stage.


        • The Stage is 480 units wide and 360 units tall. It is divided into an x-y grid. The middle of the Stage has an x-coordinate of 0 and a y-coordinate of 0.


        • To find out x-y positions on the Stage, move the mouse (the cursor) around and look at the mouse x-y display just below the Stage.
          xy.png


      2. To find information about your sprite, click on the i
        info



        Current Sprite Info shows a sprite's name, x-y position, direction, lock state, and pen state.
        sprite info



        You can type in a new name for the sprite.




        The sprite's direction indicates which direction the sprite will move when it runs a move block (0=up, 90=right, 180=down, -90=left). The blue line on the thumbnail shows the sprite's direction. You can drag this line to change the sprite's direction.

        direction



        Enable can drag in player to change the sprite's ability to be dragged.
        direction



        To save a sprite to a local file a , Ctrl+click the sprite on the Stage or in the Sprite List.

        This process saves the sprite as a .sprite file, which can then be imported into another project.
        export_sprite.png

      3. Drag a move block onto the script area
        move block


      4. Click on the block.


      5. Drag out a PLAY DRUM and snap it onto the MOVE block.



      6. You can choose different drums from the pull-down menu.
        drums.png

      7. Add another MOVE block. Attach it to the previous block. Click inside the block and type in a minus sign.
        minus.png

      8. Click on any of the blocks to run the stack.


      9. Add another PLAY DRUM block, then choose a drum from the menu. Click to run.


      10. Drag out a FOREVER block and drop it on top of the stack. You want the mouth of the FOREVER to wrap around the other blocks.
        minus.png

      11. Drag out a When Green Flag block and snap it on top.
        greenFlag.png

      12. Whenever you click the green flag, your script will start. Click the stop button at the top of the screen to stop.


      13. Drag out a CHANGE EFFECT block.
        changeEffect.png

      14. Click on the block to see what it does.


      15. Snap on a When space key pressed
        space.png


      16. You can choose a different key from the pull-down menu.





    3. Explain the difference of these two scripts:
      meow-3.jpgmeow-4.jpg


    4. Create a flowchart that describes this situation:
      Move the cat sprite to the right by five steps as long as the location of the sprite is less than 268. If the sprite is greater than 268, move the sprite to -268.


      Then build the program to test your logic.


    5. This draws a square:
      SquareExample.gif

      Using a Repeat draw the following regular shapes:
      • Equilateral Triangle
      • Pentagon
      • Hexagon
      • Octagon
      • Circle
      Hint:
      Sum of Interior Angles = (n-2) x 180°
      Each Angle (of a Regular Polygon) =(n-2) x 180° / n

      How far in degrees does your character need to turn when you draw a triangle?
      How far in degrees does your character need to turn when you draw a pentagon?
      How far in degrees does your character need to turn when you draw a hexagon?


    6. Draw a five pointed star:

      How far in degrees does your character need to turn when you draw a star?


    7. drumTempo_repeat4.gif
      • Make a version where the tempo increases faster.

      • Make another version where the tempo increases much-slower.

      • Make another version where the tempo starts out fast and then decreases.

      • Make another version where the tempo starts out slow, then gets fast, then gets slow again.




    8. Create a variable and name it note. Set note to 50. Make a script that plays every other note from 50-100.


    9. Make a new variable named Length. Start with length at 150. Draw the "Squiral" (Square+Spiral):



    10. Draw a picture (to draw faster, use the hide block):



    11. To get a random number between 1 and 10 (inclusive):
      Random.jpg
      Move your character randomly around the stage. Reverse the direction if you hit a wall. You should have 4 variables xSpeed, ySpeed, xDir, yDir