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:
This is the Scratch Interface or Integrated Development Environment (IDE).
- The Blocks palette
- The Script editor
- The Stage
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.
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
- Scratch is pretty intuitive. Complete this script:
- Sprites:
- Open Scratch
-
- Sprites, like the cat 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.
- Sprites, like the cat move and interact on the Stage.
- To find information about your sprite, click on the i
Current Sprite Info shows a sprite's name, x-y position, direction, lock state, and pen state.
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.
Enable can drag in player to change the sprite's ability to be dragged.
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.
-
Drag a move block onto the script area
- Click on the block.
- Drag out a PLAY DRUM and snap it onto the MOVE block.
- You can choose different drums from the pull-down menu.
- Add another MOVE block. Attach it to the previous block. Click inside
the block and type in a minus sign.
- Click on any of the blocks to run the stack.
- Add another PLAY DRUM block, then choose a drum from the menu. Click to run.
- 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.
- Drag out a When Green Flag
block and snap it on top.
- Whenever you click the green flag, your script will start. Click the stop button at the top of the screen to stop.
- Drag out a CHANGE EFFECT block.
- Click on the block to see what it does.
- Snap on a When space key pressed
- You can choose a different key from the pull-down menu.
- Open Scratch
- Explain the difference of these two scripts:
- 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. - This draws a square:
Using a Repeat draw the following regular shapes:- Equilateral Triangle
- Pentagon
- Hexagon
- Octagon
- Circle
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? - Draw a five pointed star:
How far in degrees does your character need to turn when you draw a star? -
- 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.
- Make a version where the tempo increases faster.
- Create a variable and name it note. Set note to 50. Make a script that plays every other note from 50-100.
-
Make a new variable named Length. Start with length at 150. Draw the "Squiral" (Square+Spiral):
- Draw a picture (to draw faster, use the hide block):
- To get a random number between 1 and 10 (inclusive):
Move your character randomly around the stage. Reverse the direction if you hit a wall. You should have 4 variables xSpeed, ySpeed, xDir, yDir