Coding Workshop Procedures
Notes:
Ice-Breaker:
Turn to the person to your closest to you.
Ask the person next to you where they are from.
If they live in the same time zone as you, give them a high-five.
If the don’t (ELSE), shake their hand and introduce yourselves.
First nominate three or four students to act as robots, then divide the remaining students into three or four teams. Each team are in a race to see who can get a 'robot' around the classroom or 'maze'. Note that this could be an outdoor task. Explain to the 'robots' that they are to play dumb and only follow the instructions they are given. Then, begin the race.
Throughout the race, ensure that students are using instructions like "step forward 10 paces" or "turn 90 degrees to the right".
After the race has been won, discuss any problems the teams encountered getting their robot to follow their instructions. Draw out through questioning that the robot could not make decisions for itself, and so the students had to be very specific about turns and steps.
Explain that a computer works by executing statements one after another in a specific order. A given order of statements is called a program. Each program executes with a given control flow ; this describes which statement we are executing, and what the next statement will be.
Software is the term given to programs that run on the computer system and make the hardware work. Software has many uses, such as making a calculation or organising files. There are two main types of software: system software which runs and manages your computer, and application software which performs a specific task or function.
Intro to Scratch
5 explorations (1 of each category) 3 minutes each
Music
Game
Art
Story
Simulation
Understand the Code
Guided practice: (15 minutes)
Look at code in Maze Starter
Examine code for Ball sprite. (Click the big blue See Inside button on top right.)
Look at bottom chunk of code and its corresponding comment. Examine other bits of code for this sprite and “translate” to English as shown in the comment in the Ball sprite.
Click on Goal sprite. Read the code. Right-click in the empty area and add a comment translating the code to English
Optional: What are some possible options for improving this game. Consider, for example, how commercial video games win, lose, give positive and negative feedback, as well as providing help.
Remix (10 minutes)
“Almost all video games provide feedback in the form of sound. Let’s remix this one by adding sounds for when the user does something good and when the do something bad.”
Show options for adding sound: Choose from Library, Record your own, and upload a file.
Click Sounds tab in the Ball sprite, then Electronic. Choose a sound that makes sense for when the ball touches the maze (That’s bad). The sound should be short and convey “badness.”
Click Sounds tab in the Goal sprite, then Electronic. Choose a sound that makes sense for when the ball touches the goal (That’s good). The sound should be short and provide positive feedback.
“What other changes could you make? How would you make this game harder? How would you make it easier”
Scratch Basics tutorial: (30 Minutes) (Note to instructor: VARIABLES is called DATA in Scratch 2.0. Some of the commands in CONTROL section of Scratch 1.4 are in the EVENTS section of 2.0)
Note to instructor: This tutorial is a 10-step procedure. After the first few steps, some students will adopt an “I got this” attitude and start playing with what they have already learned. It is important that all students complete all 10 steps of this tutorial.
Explore and create, based on what you know (10 minutes)
Naming conventions: Be sure to give descriptive names to all sprites, variables, BROADCAST commands, etc. (Programming becomes much harder if these are not named. -- I tell students that I will not help them if their sprites are not named.)
LOOKS Commands (15 minutes)
SAY vs. THINK
SET vs. CHANGE (Absolute vs. Relative)
Explore Graphics Effects (Brightness, Fisheye, Mosaic, etc.)
COSTUME change (change appearance or for animation) (5 minutes)
Importing Costumes is the same as importing Sprites, except it happens under the Costumes tab.
Animation such as flying and walking. (See built in sprites for this: bird, dog, bat, dancing girl.
Create a sprite with two costumes.Using the Repeat and Wait commands, have the Sprite change costumes .
MOTION and the Coordinate Plane. (5 minutes)
Move mouse around and see x, y coordinates change.
Create a script that makes a sprite go to a specific coordinate and then glide to another place on the Stage.
Create a script where the sprite moves in a square.
Introduce the Pen commands.) Challenge: Make the sprite draw a square, circle (Use the Repeat command), octagon, etc.
Have students have a sprite write their name. Using the Pen Up, and Pen Down commands. (Use the spreadsheet below. Sheet # 2, called, Example, provides a good example.
Have students experiment with PEN color, size, and shade.
Introduce OPERATORS- Random numbers
Have a sprite move randomly around the stage by putting random numbers in the coordinates of the Glide command. The random numbers should be between -180 to 180 for the y axis and -240 to 240 for the x axis.
Challenge: How would students structure these to maximize the amount of gliding? One possible solution:
Note: This is a good place to introduce Monitors. Monitors in Scratch show the value of an item that may change, such as a sprite’s position, the value of a variable, a sound’s volume and more. In this case, Go to MOTION and check the boxes for x position and y position.
Have students look at these values on the stage as the sprite is moving about the screen. -- Typically monitor are used during development and turned of once the program is “released.” There are many exceptions to this, the most obvious would be Score.
Challenge: Change PEN color, size, and shade change based on random numbers. This involves knowing the possible values for a command. (200 for Pen Color, 100 for Pen Shade: A pen shade of 0 is completely black, a pen shade of 100 is completely white.)
The following variation changes the line color with each movement
Change values in Graphics Effects (Brightness, Fisheye, Mosaic, etc.) based on random numbers.
Free explore time.
NEXT STEPS - Project brainstorming ideas
MOTION
COSTUME Changes
LOOKS
OPERATORS - Random Numbers
COMMENTS right click in grey area to add comments. (Note: Comments are not required, but highly encouraged. Helps collaborators understand code. Also helps author, especially if there has been some time between coding sessions. Programmers sometimes get in a “zone” while coding and may not recall their thinking from a prior session.)
Share out Ideas for their choice for Project #1
Scratch Challenges (10 minutes) and share out solutions.
Editing Costumes: Making a sad cat. (15 minutes)
Click the Cat sprite on the stage.
Click the Costumes tab.
Click the name of the existing costume and change it to “happy cat.”
Click the Copy button.
Rename the new costume to “sad cat.”
Click Edit on the sad cat costume.
Using the editing tools, make the cat look sad.
CONTROL - Conditionals: If, Forever If, and If → Else
Conditionals: If → Then, and Forever If (Note to instructor: There is no FOREVER IF command in 2.0. Wrap a FOREVER block around an IF block to achieve the same effect.)
Using a FOREVER IF command, create code have the Sprite change costumes if it touches another (specific) sprite. (Note: Touching a Sprite tends to work better than touching a color.) - (More about touching: Touching between sprites is triggered when the assigned center(s) touch. One can assign a sprite’s center when editing the sprite. It, of course, does not need to be the actual center of the sprite.)
Initialization: (Concept) One must program in the starting sprite positions and backgrounds, variables- basically, anything that changes.
Examples of initialization
Backgrounds: Backgrounds are essentially costumes on the Stage.
Creating new backgrounds.
Changing backgrounds.
Challenge: make background change after a specified time and/or key press:
Examples of changing backgrounds.
Introduce Show and Hide (LOOKS section.)
Challenge: Make sprite show and hide based on conditions such as touching another sprite or touching another color. Note: If sprites change their visibility based on Show and Hide, the beginning state state must be initialized. In other words, if you want a sprite to be visible when the program starts, that must be coded. In the following example, we want the cat to disappear when the dog touches it. When the program starts again, Scratch does not “know” to show the cat unless we tell it.
Introduction to VARIABLES. Adding score to the Cat and Dog game.
Add a variable in the Data (Scratch 2.0) or Variables (Scratch 1.4) section. Be descriptive when naming variables. In this case, let’s name our first variable “score.”
It’s best to get in the habit of immediately initializing anything that will change. So we need to SET score to 0.
Let’s create the code so that every time the dog touches the cat, it increases the variable score by 1.
Practice
Challenge: Create a variable called lives. Initialize its the value of lives to 9. Have the variable lives go down by 1 each time the dog touches the cat.
Built-in VARIABLES: ask, answer, size, x position, y position, direction, costume #, volume, tempo, loudness, and timer.
Don’t forget to initialize all variables in any program using SET.
The SENSING Ask command:
Practice: Storing user name as a variable and using it in a SAY command. Whatever is typed into an ASK command is stored in the built-in variable ANSWER.
Practice using ASK and ANSWER.
Intro to the OPERATORS JOIN command;
Have students ask user’s name and say “Hello, (name)!”-- Two JOIN commands are needed to include the end punctuation for this one. There is no limit to the number of Join commands that can be combined.
Assigning user input to a variable
Any variable can hold only one value at a time. Assuming we will ASK for more information in addition to name, it is a good idea to always assign the value of ANSWER to a new variable. In the example above, let’s create a variable called name and SET the value of name as soon as the user types in their names.
By storing the value of answer in the variable called name, we can ASK the user for more information without losing the value of the first ASK command. In the example below, when we ASK for the user’s age, we still have their name.
Challenge: Describe the output of this code:
Possible answer:
Asks user for their name.
Sprite says “Hello, (their name).”
Sprite asks user’s age.
If user types in a number greater than 18, the sprite says: “Wow, you are old, (value of variable name).”
Introduction to OPERATORS
1) Create calculations with numbers: “Say 4 x 5.”
2) Create calculations with random numbers.
Creating Calculations with numbers input by users using the ASK command.
Guided - Create a program that calculates dog years. (20-30 minutes).
Challenge: Create a program that calculates users age in months, days, hours, and/or minutes.
How else might you use a conditional based on calculation? (Ex: if score is greater than 10, then switch levels (backgrounds).
Communication between sprites: Broadcast & Receive
Broadcast and Receive allows sprite to communicate with other sprites and/or the background.
A BROADCAST command is a message sent out to all sprites and the background. Any sprite or background with a WHEN I RECEIVE command can perform actions based on that BROADCAST command
In the example below, When the dog touches the cat, the cat script broadcasts the (coder-created) message “Go to level 2.” (Broadcast messages are created by clicking “New” in the BROADCAST block.) We have created a WHEN I RECEIVE ““Go to level 2,” the background switches. Like variables, BROADCAST commands should be as descriptive as possible.
In the cat’s script
In the Stage’s script
Challenge: Change background (level) when score is more than 5.
More with Conditionals: WAIT UNTIL and IF →Else
Challenge: Ask user a question & provide feedback for right and wrong answers using IF →Else.
Review
Blocks used so far
MOTION
COSTUME Changes
LOOKS
OPERATORS - Random Numbers
VARIABLES (Built-in vs. Created)
CONTROL - Conditionals: If, Forever If, and If → Else
SENSING - Touching, ASK If, and Key press, x position, and y position
Creating Flags: Flags are used to keep track of any aspect of a program or some other information. For example, a game may have instructions appear before the game begins. In this case, one might create a VARIABLE called GameStart. It would be assigned the value “No” during the intro and “Yes” during the game. If sprites are hidden until the game starts, then one might assign those sprites FOREVER IF GameStart=No, then HIDE.
Practice: Create the scenario mentioned above.
Compound Conditions
Example: If score > 20 AND Game_Start = Yes, the BROADCAST next level.
Practice: Create the scenario mentioned above.
Important: if users will input text for an answer, make sure that correct answers aren’t perceived as incorrect. Consider this code;
Ask Who was the 16th President
If ANSWER=Abe Lincoln, then SAY “Correct.”
Under this scenario, both “Lincoln” and “Abraham Lincoln” would be considered incorrect, as they do not match what is in the code.
Compound Conditionals
One could code this “Lincoln” OR “Abraham Lincoln” OR “Abe Lincoln.” -- Still not ideal. It is best to make user input as simple as possible.
Data Validation/error capture
Example of data validation:
ASK “Type a number between 1-100.”
IF ANSWER is NOT > 0 AND < 101, SAY, “No silly. Type a number between 1-100.”
Work time
Reflection
Reflect on projects: What are you working on. What would you like to do that you don’t know how to do yet?
Prepare for Project #2. Which category? (Hybrids encouraged).
Animation
Story
Game of skill
Simulation
Games of chance
Interactive art
Music
Simulation
What makes a good program? Brainstorm.
Get students to check out projects on the Scratch website and identify what qualities made for a good project. It is easy to find the good and bad projects because statistics are kept for each uploaded project. A popular project will have lots of love-its, re-mixes and downloads.
Together with students list some of the characteristics of a good project. For example some of the good project qualities: the project works well, easy to use, easy to understand, creative, fun to play, funny, cool, advanced scripts, cool sprites and backgrounds, creative drawings, and creative stories.
Use student feedback to create categories for evaluation. For example project design/creativity, user friendliness, programming, backgrounds and sprites.
Come up with different levels of quality. For example: excellent, good, average and needs more work.
Create the rubric keeping in mind discussions of common problems and the qualities of good and not so good projects.
Using the freshly created rubric, chose several projects and evaluate them in groups or as a class.
Plan for project #2. (May be an extension of #1)
Optional: Teacher creates a Google Form of the student-created rubric. Students use the form to evaluate their own projects as well as those of their peers.
.
“Gallery walk” - projects set-up on computers and then have kids move around the room trying things out.
Scratch Reference
The Stage
Dimensions and Directions on the stage 480 by 360
Code Blocks
Stack blocks are code blocks with a notch at the top or a bump at the bottom. The notches and bumps serve as visual indicators that identify how the blocks can be snapped together to create programming logic. The majority of code blocks provided by Scratch are stack blocks.
Hat blocks are code blocks with a rounded or curved top and a bump at the bottom, visually indicating that it can be snapped on top of other stack blocks. Hat blocks provide the ability to create event-driven scripts.
Reporter blocks is a code block that has either rounded or angled sides and is specifically designed as a mechanism for providing input for other code blocks to process.
Commenting
Comments within a script help the reader understand the Scratch program. It might also help the programmer later and/or if someone else tries to work with your scripts, she will be glad to see the scripts explained in comments.
Sprites
Moving a Sprite
How far
How fast?
Which direction?
Concepts in Movement
Changing values in instructions
Initialization refers to instructions that set values when a script is run from its beginning. Most scripts will have an initialization consisting of several such instructions to ensure that the script always starts running from the same state.
Absolute vs relative movement
Go to and Glide are absolute
Move and Change x (or y) by are relative.
Task 1: Construct an animation that causes the cat (or any sprite) to move 100 steps and then turn 90 degrees counterclockwise each time it is run (by clicking the green flag).
Variation: Have the cat draw a square, triangle, heptagon.
Where do Sprites come from?
Costumes and Costume changes (Absolute vs. Relative)
Change costume vs. Next Costume vs. Costume #
Editing costumes using paint and draw tools
Sounds
Backgrounds
Loops
Task 2: Make the cat and mouse run forever.
Conditionals: Forever and Forever if
Task 3: When the mouse touches the cat, the cat looks sad.
Adding Interactivity #1
Task 4: Move the cat move using the arrow keys.
Task 5: When the cat catches the mouse, the mouse says something and his appearance changes.
Intro to Variables
Task 6: Every time the cat catches the mouse, the mouse scores a point and the mouse loses 10 health points.
Communication between sprites: Broadcast & Receive
Task 7: When the when the cat touches the mouse three times, a new sprite appears on the stage and says, “ I am here to help.” Option: Change background
Variables and Text: The ASK command.
More with text: the JOIN Command.
Task 8: When the when the cat asks the user their name, he replies “Hello, ‘name.’ I am hungry for a mouse.'"
Animation with costume changes
Phase II Exploring the examples
Phase III: Advanced Concepts
Changing size, appearance, speed and /or position, with variables.
Conditional
If and If Else
Comparing Values in a conditional statement
Compound conditions AND & OR
Show and Hide
Random Numbers
Graphic effects
Pen up and pen down
Websites
Scratch Curriculum Guide
http://scratched.media.mit.edu/sites/default/files/CurriculumGuide-v20110923.pdf