290 likes | 688 Views
30 min intro to Scratch. A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available). Objectives of Scratch unit. Intro to visual programming environment Intro to programming with multimedia Story-telling | music-making | game-making
E N D
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
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 30 min Scratch July 2009
Secondary objectives • Increase student skills with computers • Increase student interest in programming • Student achievement on fun project • Learn Cartesian coordinates, distance computations, etc. 30 min Scratch July 2009
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 30 min Scratch July 2009
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 30 min Scratch July 2009
Click on the “Looks” button at the top left. 30 min Scratch July 2009
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 30 min Scratch July 2009
Let’s implement an algorithm to average two numbers • Make a variable “number1” (click and drag and set) • Make another one “number2” 30 min Scratch July 2009
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 30 min Scratch July 2009
Average script as 4 operation sequence. Change the two numbers and click the sequence to execute the block again. 30 min Scratch July 2009
But Scratch computes with multimedia – color, sound, … • Can make cartoons • Can create stories • Can create video games 30 min Scratch July 2009
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! 30 min Scratch July 2009
Make the cat 50% larger • Select “Looks” operations • Drag the “change size” operator into your script • Click and edit for a 50% change (increase) • Double click your one operation script • Did your cat sprite get 50% bigger? 30 min Scratch July 2009
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” 30 min Scratch July 2009
Some new operations • color change (Looks) • wait (Control) • move (Motion) 30 min Scratch July 2009
Starting a looped script 30 min Scratch July 2009
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. 30 min Scratch July 2009
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 30 min Scratch July 2009
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) 30 min Scratch July 2009
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) 30 min Scratch July 2009
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 30 min Scratch July 2009
Interacting with your sprite or story • Using mouse • Entering a character • Asking the user a question 30 min Scratch July 2009
Sprite follows the mouse Try changing the number of steps or the wait time. 30 min Scratch July 2009
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 30 min Scratch July 2009
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? 30 min Scratch July 2009
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 30 min Scratch July 2009
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? 30 min Scratch July 2009
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. 30 min Scratch July 2009