View
217
Download
0
Category
Preview:
Citation preview
8/11/2019 Intro Adult Hour Scratch
1/43
ITEC Winter 2010 1
An intro to programmingconcepts with Scratch
Quick intro for college citizens.
George StockmanMSU CSE
8/11/2019 Intro Adult Hour Scratch
2/43
ITEC Winter 2010 2
A 10-minute PR clip
sallyAndHorse.sb
8/11/2019 Intro Adult Hour Scratch
3/43
ITEC Winter 2010 3
What can we do with Scratch? Learn some computing concepts.
Learn some practical algorithms. Have fun with Scratch creating stories,
games, art.
We are teaching Scratch after school tomiddle school kids with the goal ofincreasing interest in STEM.
8/11/2019 Intro Adult Hour Scratch
4/43
ITEC Winter 2010 4
Start scratch and lets go!
Click on the cat icon
If not on desktop, downloadfrom www.scratch.mit.edu
Scratch programming
environment comes up quickly We will first do simple ops
http://www.scratch.mit.edu/http://www.scratch.mit.edu/8/11/2019 Intro Adult Hour Scratch
5/43
ITEC Winter 2010 5
Scratch environment Stageis at upper right (where actors act and
information is displayed) Spriteis another name for actor (object).
Instruction menus/panel at left (instructionsfor the actors)
A scriptis another name for program ormethod; a script tells the actor what to do.
Programming panel in center; here is wherewe construct scripts for the sprites (Sprites are objects; their scripts are methods
or behaviors.)
8/11/2019 Intro Adult Hour Scratch
6/43
ITEC Winter 2010 6
We start with the cat sprite
We will learn to use other sprites
and many sprites LATER. Now weuse the cat as our only actor.
8/11/2019 Intro Adult Hour Scratch
7/43
ITEC Winter 2010 7
The LOOKS menu
Has operations for setting the color,size, and visibility of a sprite.
Constumes will be used LATER
8/11/2019 Intro Adult Hour Scratch
8/43
ITEC Winter 2010 8
The hello script (program)
Double click on the say hello lego block
Check your sprite behavior at the right
Then double click say hello for 2 secs
Your very first Scratch program!
8/11/2019 Intro Adult Hour Scratch
9/43
ITEC Winter 2010 9
Try some other looks
operations (double click items) Change color effect by 25
Change color effect by 25 again
Hide
Show
Change size by 10 Change size by 10 again
Set size to 100%
8/11/2019 Intro Adult Hour Scratch
10/43
ITEC Winter 2010 10
Lets write a script to Say hello for 2 seconds
Then change color by 25
Then think Hmm.. for 4 seconds
Then change color by 75
Then change size by 200
Drag the instructions from the menu to the center panel.Connect them into a single block. Edit the parameters toget the numbers we want.
8/11/2019 Intro Adult Hour Scratch
11/43
ITEC Winter 2010 11
Our script (program)
8/11/2019 Intro Adult Hour Scratch
12/43
ITEC Winter 2010 12
The WAIT instruction is needed to slow down the acting so
we can see or hear it properly(computers are too fast sometimes)
Get the wait instruction from theCONTROL menu. Please ignore theother menu options at this time.
Insert a wait in our looks script
8/11/2019 Intro Adult Hour Scratch
13/43
ITEC Winter 2010 13
3 second pause between
changing color and size
8/11/2019 Intro Adult Hour Scratch
14/43
ITEC Winter 2010 14
The MOTION menu
How to locate and orient a sprite;
position and angle; moving asprite
8/11/2019 Intro Adult Hour Scratch
15/43
ITEC Winter 2010 15
Position on the stage Using the Looks
menu, shrink
our cat to 25%. Click on the
Motion menu.
Click to check
the box for x-position and y-position
Drag your cataround and note itsx-y position.
8/11/2019 Intro Adult Hour Scratch
16/43
ITEC Winter 2010 16
Other instructions
goto x,y
glide to x,y
Move N steps
Set direction
8/11/2019 Intro Adult Hour Scratch
17/43
ITEC Winter 2010 17
The glide-to instruction
Drag the glide-to instruction into yourscript panel.
Edit in some coordinate values anddouble click to see where your spritesgoes.
8/11/2019 Intro Adult Hour Scratch
18/43
ITEC Winter 2010 18
The SENSING menu
Getting information from the user
or some other machine
8/11/2019 Intro Adult Hour Scratch
19/43
ITEC Winter 2010 19
Use the SENSING menu
1) Ask the user for age; 2) user types in age;
3) result stored in answer
8/11/2019 Intro Adult Hour Scratch
20/43
ITEC Winter 2010 20
User types 13 and the scriptstores the answer
answeris aSpecialScratch
variable
8/11/2019 Intro Adult Hour Scratch
21/43
ITEC Winter 2010 21
OUTPUT: Giving the user
information with say answer
Sayis in Looks menu;drag answer from
Sensing menu; click
8/11/2019 Intro Adult Hour Scratch
22/43
ITEC Winter 2010 22
Making an age variable
1) Click Variables menu; 2) click Make a variable
3) Type in age and click OK
Do you want todisplay for allsprites or just one?
8/11/2019 Intro Adult Hour Scratch
23/43
ITEC Winter 2010 23
We have an age variableDisplaying variable ageOperations for age
8/11/2019 Intro Adult Hour Scratch
24/43
ITEC Winter 2010 24
We canjointext and anumber to say things
Build this instruction fromthe parts above it.
From Looks
From Operators
From Sensing
Make the join
8/11/2019 Intro Adult Hour Scratch
25/43
ITEC Winter 2010 25
Storing a value in a variable;then saying it to the user
1) Setfrom Variables menu; 2) Sayfrom Looks menu; 3) Joinfrom theOperators menu joins your text with the answer
8/11/2019 Intro Adult Hour Scratch
26/43
ITEC Winter 2010 26
A first program for 6thgrade
The variable V now stores the computed average of A and B
8/11/2019 Intro Adult Hour Scratch
27/43
ITEC Winter 2010 27
Changing costumes
Another way to change the
appearance
of a sprite.
8/11/2019 Intro Adult Hour Scratch
28/43
ITEC Winter 2010 28
Making a new costume
1) Get bat2-a sprite fromthe sprite box.
2) Click on sprite
3) Click on Costumes
4) Click on Import
5) Now get bat-2b spritefrom the sprite box
8/11/2019 Intro Adult Hour Scratch
29/43
ITEC Winter 2010 29
Use a loop to make the bat fly!
1) Whenand repeatfrom Control menu and 2) next costume fromLooks menu.
8/11/2019 Intro Adult Hour Scratch
30/43
ITEC Winter 2010 30
Changing coordinates
We can randomly set the location of the
bat so it will flutter. Set X to a random number
Set Y to a random number
Move the bat to location (X,Y) Of course, the bat should remain on
stage!
8/11/2019 Intro Adult Hour Scratch
31/43
ITEC Winter 2010 31
Usingpick random
Click the stop sign at the stage upper right to stop the forever loop.
Do we need a wait in the loop? Try it to see the change in flying.
8/11/2019 Intro Adult Hour Scratch
32/43
ITEC Winter 2010 32
Multiple interactive bat flight
8/11/2019 Intro Adult Hour Scratch
33/43
ITEC Winter 2010 33
Adding a background
Click on theStageicon atlower right
Click onBackgrounds
Click on baticon (Sprite1)
Click onScripts
FLY AGAIN!
8/11/2019 Intro Adult Hour Scratch
34/43
ITEC Winter 2010 34
Controlling the bats direction
Lets create multiple scripts.
Click space bar for random moves
Click right arrow to move right Click left arrow to move left
The bat will behave differently
depending upon which key is typed! (So, could a gamer catch the bat?)
8/11/2019 Intro Adult Hour Scratch
35/43
ITEC Winter 2010 35
On to multimedia, games,stories
Detecting events;
sending messages;using music and audio;
8/11/2019 Intro Adult Hour Scratch
36/43
ITEC Winter 2010 36
See stock example: Mad Lib
Explore the available examples;
Mad Lib under stories;Study message sending;
8/11/2019 Intro Adult Hour Scratch
37/43
ITEC Winter 2010 37
Study Break Dance
Music and dance example;
Messaging;Use of stock music and costumes
8/11/2019 Intro Adult Hour Scratch
38/43
ITEC Winter 2010 38
Digitizing your own audio
Use din example
8/11/2019 Intro Adult Hour Scratch
39/43
ITEC Winter 2010 39
Composing with drum beats
8/11/2019 Intro Adult Hour Scratch
40/43
ITEC Winter 2010 40
8/11/2019 Intro Adult Hour Scratch
41/43
ITEC Winter 2010 41
Jodi jumps on the drum
Story teller script Jodis script
8/11/2019 Intro Adult Hour Scratch
42/43
ITEC Winter 2010 42
Recording from a mike (or aniPod or other music player)
1. Plug in microphone
2. Pick the speaker sprite
3. Click Sounds4. Click Record
5. Click red button and speak
6. Click square button to stop
7. Click triangle to hear it
8. Click OK if its OK
9. Use name of sound in a play-soundinstruction
8/11/2019 Intro Adult Hour Scratch
43/43
Where does all this lead?
Definitely engaging for grades 6,7,8.
Does it increase STEM interest of our kids?
Does it motivate college computing classes?Does Scratch make a smarter Lego bot?
Recommended