30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of...

28
30 min Scratch July 2009 1 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

Transcript of 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of...

Page 1: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 1

30 min intro to Scratch

A Quick-and-Dirty approachLeaving lots of exploration for the

future.(5 hour lesson plan available)

Page 2: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 2

Objectives of Scratch unit Intro to visual programming environment Intro to programming with multimedia Story-telling | music-making | game-

making Intro to programming concepts objects and attributes sequence, repetition conditions, events, I/O

For instructors

Page 3: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 3

Secondary objectives

Increase student skills with computers

Increase student interest in programming

Student achievement on fun project Learn Cartesian coordinates,

distance computations, etc.

Page 4: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 4

Computer scientists Create solutions to problems using

computers Study information Invent algorithms Write programs to implement the

algorithms Reuse a lot of existing program

and machine parts

Page 5: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 5

Start scratch and let’s go!

Click on the cat icon Or, find “scratch” under “Programs” When home, download from

www.scratch.mit.edu Scratch programming environment

comes up quickly

Page 6: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 6

Click on the “Looks” button at the top left.

Page 7: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 7

Major components

At right: the stage with sprite[s] or objects or actors

At left: operations and attributes for the sprites

Center: scripts or program[s] for the behavior[s] of the sprites

Your sprites are actors that you direct with your scripts

Page 8: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 8

Let’s implement an algorithm to average two numbers

Make a variable “number1” (click and drag and set)

Make another one “number2”

Page 9: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 9

Compute average first as sum

Make variable average

Drag a “set operation” to script area

Drag a + operation

Drag variables number1 and number2 to parameters

Click to execute

Page 10: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 10

Average script as 4 operation sequence.

Change the two numbers and click the sequence to execute the block again.

Page 11: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 11

But Scratch computes with multimedia – color, sound, …

Can make cartoons Can create stories Can create video games

Page 12: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 12

The “hello” script Can do it in 57 languages – java, C++,

… Scratch Easy in Scratch: select “Looks”

operations and drag the “hello operation” onto your center panel.

Then double click on this “lego block”: check your sprite behavior at the right

Your very first Scratch program!

Page 13: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 13

Make the cat 50% larger

1. Select “Looks” operations

2. Drag the “change size” operator into your script

3. Click and edit for a 50% change (increase)

4. Double click your one operation script

5. Did your cat sprite get 50% bigger?

Page 14: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 14

Scripting a sequence of ops

Do ops in the following order by dragging operation blocks into a single connected block

Say hello Move 200 steps forward Grow 50% bigger Make the “meow sound”

Page 15: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 15

Some new operations

• color change (Looks)

• wait (Control)

• move (Motion)

Page 16: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 16

Starting a looped script

Page 17: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 17

Exercise: write a script to

Make the cat move along a square path

Say “hi” at all four corners Wait 3 seconds at each corner Change color at all four corners Double size when back to the original

starting location. Say “That’s all folks” when done.

Page 18: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 18

Elements of Scratch: objects Colors Sounds Locations in 2D space Sprites Costumes Variables (to remember the state of

things) Events: that are broadcast for

communication

Page 19: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 19

Elements of Scratch: control

Sequence of operations Loops or repetition Detecting events (key or mouse

pressed, sprites overlapping each other, sprites hitting edge of stage, sensor giving value)

Page 20: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 20

Loop constructs in Scratch Repeat N times Repeat forever Repeat forever if

some condition exists (suppose I’m a sprite wandering about this lab until someone asks a question)

Page 21: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 21

Conditions can be checked Do something if

sprite k hits sprite m

Do something if a certain key is pressed

Do something is some variable takes a certain value

Page 22: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 22

Interacting with your sprite or story

Using mouse Entering a character Asking the user a question

Page 23: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 23

Sprite follows the mouse

Try changing the number of steps or the wait time.

Page 24: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 24

Play and examine MadLib

Choose the “file” option at the top of the window

Choose “open”, then “examples” Choose “stories” Choose “MadLib” and then read the

authors instructions Click OK, wait for load, click green

flag

Page 25: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 25

About the MadLib story How many actors (sprites)? What is the role of the girl? How are the answers you give

'remembered' and then used in later actions?

What is the role of the little whale? What makes the little whale flip around? What makes the big whale spout?

Page 26: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 26

Sprites can interact with each other Can detect when colors overlap in

space Can detect when sprites bump into

edge of the stage See “bouncing balls” example under

Simulations under Examples Interact with this simulation Check out the rather complex scripts

Page 27: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 27

Check out the break dance

Open examples; music and dance; break dance

How does break dancing begin? What are the roles of the sprites? What events are in the scripts? What should happen when the

boom box is clicked?

Page 28: 30 min Scratch July 20091 30 min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)

30 min Scratch July 2009 28

Experiment with Scratch as time permits

Try your own scripts: make moves, sounds, interactions in simple cases

Try the examples and learn what makes them work

Download Scratch on your own machine and experiment some more

Direct a story; or a simulation; or create a video game.