1 An intro to programming concepts with Scratch Session 3 of 10 sessions Repetition and variations.

Slides:



Advertisements
Similar presentations
Create a Simple Game in Scratch
Advertisements

Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Create a Simple Game in Scratch
30 min Scratch July min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)
Scratch for Storytelling Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
Pong! “The oldest commercially available game in history” Resources created from the video tutorials provided by David Phillips on
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Write Your First Computer Game!. Coding: Programming Languages Just like you can speak Chinese to someone who understands Chinese to tell them what to.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
Scratch Programming Session 9 of 10 Review elements to use in stories, games, etc.
Scratch Programming Session 6 of 10 If-then-else statements interactions Final projects specifications.
Session 5 of 10 Review + Multiple Sprites
1 An introduction to programming concepts with Scratch.
An intro to programming concepts with Scratch Session 2 of 10 sessions I/O, variables, simple computing.
1 An introduction to programming concepts with Scratch (in 5 hours + homework)
1 An intro to programming concepts with Scratch Session 1 of 10 sessions Looks and Motion.
ITEC Winter An intro to programming concepts with Scratch Quick intro for college citizens. George Stockman MSU CSE.
Madlib-Input, Strings, and Lists in Scratch Barb Ericson Georgia Tech June 2011.
Digital Art in Scratch part 1 Barb Ericson Georgia Tech Oct 2010.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Every week: Sign in at the door If you are new: Fill in Registration Form Ask a Mentor how to get started Make sure you are on the Athenry Parents/Kids.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
INTRODUCTION TO THE SCRATCH PROGRAMMING ENVIRONMENT.
CATCH SCRATCH! Programming from Scratch. Remember Scratch?
Code Club Session 2 Dance Party. What will we learn ?  How to change the background  How to create animations  How to make objects talk to each other.
Section 3 Calculations National 4/5 Scratch Course.
Summer Computing Workshop. Session 2 Input in Scratch  Multi-Character input - This is used when the user is prompted to enter a number or word.  Problems.
Objects and Methods in Scratch 1. 2 Scratch environment Stage is at upper right (where actors act and information is displayed) Sprite is another name.
2015 CSE/EGR Summer Camps 1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed.
Digital Art in Scratch part 1 Barb Ericson Georgia Tech May 2011.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
TRIGGERS Triggers tell a script to start executing There are four types of triggers: When green flag is clicked When I am clicked When is pressed When.
WHAT IN THE WORLD IS SCRATCH??? AN INTRODUCTION TO COMPUTER PROGRAMMING By MD Showman.
Making a Sprite Dance Barb Ericson Georgia Tech June 2011.
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Computer Programming Modeling a Passive Solar Home.
1 Project designed and created by M. Shajith Kumar.
24 Background Building 25 Computing Terminology, and Speed/Velocity Module 4 Notes: Sensing, Or Operator, Conditional Logic 28 Module 4 Algorithms,
Variables and Random Numbers Computer App Session 4.
Using MIT Scratch for Programming and Control Exercise 1 Creating movement Year 11 DTG 2012.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
How to create a sprite Delete a sprite (e.g. the cat) by right clicking on it and choosing delete. Go to the bottom right hand corner and choose a new.
How to create a sprite Delete a sprite (e.g. the cat) by right clicking on it and choosing delete. Go to the bottom right hand corner of the stage and.
Introduction to Computer Programming - Project 1 Intro to Digital Technology.
Scratch for Interactivity Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
How to create a basic game in Scratch. The Scratch Stage The Scratch stage is 480 pixels wide and 360 pixels high x increasesx decreases.
ICT/COMPUTING RULES Only use software allowed by the teacher
Computer Programming Modeling a Passive Solar Home.
Madlib-Input, Strings, and Lists in Scratch Barb Ericson Georgia Tech.
Computer Programming with Scratch JAOIT 8. Scratch Scratch is a programming language that makes it easy to create your own interactive stories, animations,
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Introducing Scratch Learning resources for the implementation of the scenario
Introduction to Scratch
Create a Halloween Computer Game in Scratch
Scratch for Interactivity
Scratch Unit Overview We are going to look at computer programming and how to create your very own computer game The piece of software we will be using.
Unit 2 Getting Started With
Scratch for Interactivity
Introduction to Object-Oriented Programming
Scratch Programming Intro
Learn… Create… Program
Learn… Create… Program
An intro to programming concepts with Scratch
Building a Game in Scratch
Learn… Create… Program
Learn… Create… Program
Creating a Simple Game in Scratch
Presentation transcript:

1 An intro to programming concepts with Scratch Session 3 of 10 sessions Repetition and variations

2 Session 3 goals Learn how to program with repetition Changing costumes Controlling execution (behavior) using special keys

3 The sneezing cat script We repeat 20 times Say “AAAHHHH” for a short time Then grow the cat 5% bigger

4 Exercise: bring the cat size down to normal Repeat 20? times Briefly say “CCHHEEEW” Then shrink the cat’s size by 5% Repeat N times and repeat forever are in the Control menu

5 Program to compute the average An optional piece: to omit this, proceed to slide #18

6 A better average algorithm ( do blackboard work first) Let’s average N numbers Say 5 numbers { 12, 14, 15, 10, 10} Variable sum will be used to add them After we add all the numbers, we then divide by N In the example above, sum =0, 12, 26, 41, 51, and finally 61 Then average = 61/5 = 12.2

7 Exercise at your seat with paper Write SUM = 0 Write N = ____ Repeat with the class get the NEXT number __ __ __ __ __ add it to the SUM __ __ __ __ __ Compute the average by dividing the sum by N _____

8 Doing it in a Scratch program Ask the user how many numbers (N) Set our SUM to 0 Repeat the following N times ask the user for the NEXT number reset SUM to SUM + NEXT Set AVERAGE to SUM / N Tell the user the AVERAGE

9 Making the script We need variables N, SUM, and NEXT We need a repeat N loop We need to ask the user for a number NEXT inside the repeat loop We need to add NEXT to SUM each time We need to say the answer

10 AVG : making the variables Make variables for: N: how many to average NEXT: the next number SUM: the sum of the numbers AVERAGE: the average of the numbers

11 AVG : asking for the numbers Try this loop first and watch Try this loop; watch the value of NEXT change with your input.

12 Let’s write the program in 3 steps, and slowly execute it Step 1: get N Step 2: ask the N numbers and add them up Step 3: compute and say the average

13 AVG 1: get N from user 3 parts of our program: (1) ask user for N; (2) add up the N numbers; (3) compute and say the average. Click on each part to see it run!

14 AVG 2: add N numbers to SUM We just added 12 and 14 and are ready to add 15. We added 12 and 14 to sum and are asking for 15.

15 AVG 3: execute the 3 rd part Check all the variables to see if they are correct for this problem

16 Exercise: make a single script and run it on new numbers

17 Save your average program You can always use it again in the future. That is what programs are for. So, file it.

18 Exercise: have the cat do a flip by rotating 20 degrees 18 times. Repeat from the Control menu: set the number of repetitions to 18 Rotate from the Motion menu: set the size of each small rotation to 20 degrees

19 Changing costumes Another way to change the appea rance of a sprite.

20 Making a new costume 1)Get bat2-a sprite from the “sprite box”. 2)Click on sprite 3)Click on “Costumes” 4)Click on “Import” 5)Now get bat-2b sprite from the sprite box

21 Use a loop to make the bat fly! 1) When and repeat from Control menu and 2) next costume from Looks menu.

22 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!

23 Using pick 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.

24 Controlling the bat’s direction Let’s 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?)

25 Multiple interactive bat flight

26 Exercise: Add a behavior (script) to move the bat up with the up arrow. Add a behavior to move the bat down with the down arrow.

27 Adding a background Click on the Stage icon at lower right Click on Backgrounds Click on bat icon (Sprite1) Click on Scripts FLY AGAIN!

28 Changing background Click on the stage icon New menu of operations appears Click each menu operation to see what it does. How can we program changes of background? More later.

29 Exercise: can we make Cassie do jumping jacks? Search the sprite locker to find different costumes for Cassie. Make a script that makes her move by contolling the changes in costumes.

30 End of Session 3: outcomes Student should be able to write a program controlled by a loop, and execute a script by clicking special keys. The student should also know how to use “costumes” to change the appearance of a sprite.