+ All Categories
Home > Education > Programming in scratch

Programming in scratch

Date post: 14-Apr-2017
Category:
Upload: hussam-mostafa
View: 382 times
Download: 0 times
Share this document with a friend
58
Programming in scratch Eng. hussam mostafa
Transcript
Page 1: Programming in scratch

Programming in scratch

Eng. hussam mostafa

Page 2: Programming in scratch

The purpose of that work• This work was made for the memory of my friend Ahmed Elzeki who

passed away in 2016. you're allowed to use this presentation in any educational purpose for free. Just please pray for Ahmed.

فى المنيه وافته الذي الذكي أحمد صديقي لذكرى تخليدا تم العمل هذاتعليميه. 2016عام أغراض ألي الملف هذا استخدام أحد ألى مسموح

دعائكم. من أحمد تسنوا ال رجاء فقط مجانا

Page 3: Programming in scratch

What’s scratch?• MIT's block-based programming language.• With Scratch, you can program your own interactive stories, games,

and animations — and share your creations with others in the online community.• Scratch helps young people learn to think creatively, reason

systematically, and work collaboratively — essential skills for life in the 21st century.• Scratch is a project of the Lifelong Kindergarten Group at the MIT

Media Lab. It is provided free of charge.

Page 4: Programming in scratch

PrerequisitesScratch will run in the following browsers:• Chrome 35 or later• Firefox 31 or later• Internet Explorer 8 or later• In addition, you must have Adobe Flash Player 10.2 or later installed

in order to run Scratch.

Page 5: Programming in scratch

How to open scratch?• Visit http://scratch.mit.edu to get started. You should see a webpage

that looks similar to this:

Page 6: Programming in scratch

CREATING A SCRATCH ACCOUNT AND SIGNING IN• At the top right corner of the Scratch page, you'll see a "Sign in"

button.

Page 7: Programming in scratch

Getting started• Once you've logged in, click on the "Create" button at the top left

corner of the webpage. This will take you to a new page where you can start working on a new Scratch project!

Page 8: Programming in scratch

Scratch programming language• Tabs (for blocks):• In the top center of the Scripts tab of the Scratch editor, there is a list

of colored rectangles and types of blocks. These are the block tabs. We use them to look at lists of the different kinds of blocks.

Page 9: Programming in scratch

Scratch programming languageTabs (for each Sprite):• In the top center of the Scratch editor, there are three tabs that say

"Scripts", "Costumes", and "Sounds". These are the tabs for each sprite.

Page 10: Programming in scratch

Scratch programming language• Blocks:• Blocks are the colored pieces that we move around to make Scratch

programs. Different colored blocks are used to do different things. The block color is the same color that goes with the block tab where you find that block.

Page 11: Programming in scratch

Scratch programming language• Script:• A script is a group of connected blocks that does something when you

double click on it.

Page 12: Programming in scratch

Scratch programming language• Sprite:• A sprite is a Scratch character. Each sprite has its own scripts,

costumes, and sounds. Sprites are shown on the stage and in the sprites area in the bottom left part of the screen.

Page 13: Programming in scratch

Scratch programming language• Costume:• The appearance of the sprite on the stage. Each sprite can have

multiple costumes.

Page 14: Programming in scratch

Scratch programming language• Stage:• The stage is in the upper left part of the Scratch editor. This is where

you can see what happens when you run your scripts.

Page 15: Programming in scratch

COMPUTER SCIENCE LINGO• We'll also use computer science lingo in this class! These words

describe things that are in Scratch and other programming languages.

Page 16: Programming in scratch

Quiz • Which area is the "scripts area"?

Answer

B

Page 17: Programming in scratch

Moving Pieces• CREATING SCRIPTS• In your Scratch project, drag some blocks onto the "Scripts" area.

Page 18: Programming in scratch

Moving Pieces• Now try to connect the blocks to create this script below!

Page 19: Programming in scratch

REMOVING A BLOCK• How can you remove the block from the

script you just wrote so that it looks like the script below? Figure this out now!

Page 20: Programming in scratch

RUNNING SCRIPTS• Try connecting some of play note blocks in the scripts area. Run the

script you made by double clicking on it (there should be a yellow glow around it).

Page 21: Programming in scratch

NAMING YOUR PROJECT• You can change the name of your project by filling in the box at the

top of the stage, in the upper left portion of the screen. In this picture, we're naming our project "1. Repeats in a Song".

Page 22: Programming in scratch

SAVING YOUR PROJECT• It's really important that you save your Scratch projects often.

Otherwise, you might lose something you've been working really hard on! It hurts, I promise.• To save your project in Scratch, click "Save Now" in the upper right

corner of the screen, next to your username. You can also click the "Save Now" option in the "File" menu in the upper left part of the Scratch editor.

Page 23: Programming in scratch

Repeat • to make the song below where we play the notes 60 and 62 over and

over again, we need 8 pieces!

Page 24: Programming in scratch

Repeat • THE REPEAT BLOCK• To make our work easier, we can use repeat blocks! Click on the

"Control" tab in the middle of the Scratch window.

• A repeat block can do a snippet of code over and over again. The number next to the word repeat tells us how many times we want to do the things inside of the repeat block.

Page 25: Programming in scratch

EXPERIMENT WITH REPEAT• Try to make a script that uses different numbers after the repeat. Here

are some examples.Repeat 3:

Repeat 1:

Repeat 0:

Page 26: Programming in scratch

EXPERIMENT WITH REPEAT• Try to put pieces before, after, and inside the repeat, like below.

• Hint: If you click on a block with the right button on the mouse ("right-click"), you should see "duplicate", "delete" and "add comment" options. Select "duplicate" to make a copy of the block you clicked on and all blocks below that block. If right-clicking doesn't work, you can press shift and then click to see the menu.

Page 27: Programming in scratch

QUIZ• How many times does the note 52 play when you double click the

script below?

• How many times does the note 62 play when you double click the script below?

Answer

0

Answer

1

Page 28: Programming in scratch

NESTED REPEATS• We can put one repeat inside of another repeat! We call this a nested

repeat. • How many times will the note 62 play when you double click on this

script?

Answer

6

Page 29: Programming in scratch

COMPLEX NESTED REPEATS• Nested repeats (a repeat within a repeat) can be really complicated!!!• How many times does the note 55 play when you double click the

script?

• How many times does the note 60 play when you double click this script?

Answer

4

Answer

2

Page 30: Programming in scratch

Tricky Nested Repeats

• It is important in computer science to figure out exactly what instructions get executed (when a script runs). • When the script is run, what is the first note that is played?

• When this script is run, what is the last note that is played?

• When this script is run, is the note 40 ever played twice in a row?

• When this script is run, is the note 60 ever played twice in a row?

40 60

NO NO

Page 31: Programming in scratch

Project: Make a Song• For your first project - make a song! You can make a Scratch script for

a song written by someone else, or come up with a new song on your own! You should make a new Scratch script and not use parts of someone else's script.• Start by making a new project in Scratch. Click on "File" in the gray bar

at the top of the screen and you'll see a menu pop up. Click on "Go to My Stuff". This should take you to the page with all your projects.

Page 32: Programming in scratch

Project: Make a Song• Now click on the button that says "+ New Project".

• This will open a new project for you.• To make your song, you can try using any of the blocks in the Sound tab.

Page 33: Programming in scratch

Project: Make a Song• Also, you can make more than one script with a "green flag" block on

top. That way, when you click the green flag, more than one script will play! This is called parallel execution.

• NOTE : you must put the green flag in the beginning of your script so that others can play you song. You’ll find it there

Page 34: Programming in scratch

HOW TO SHARE YOUR PROJECT• Before you post a link to your project, you need to share the project.

Do this by pressing the gray Share button in the upper right corner of the Scratch editor, under your Scratch username.

Page 35: Programming in scratch

HOW TO SHARE YOUR PROJECT• After you've shared your project, you will see the word "shared" in

parentheses under the name of your project, and you will no longer see the "Share" button next under your username in the upper right corner.

Page 36: Programming in scratch

HOW TO SHARE YOUR PROJECT• To post your project, copy the URL of your project and paste it. The

URL for your Scratch project should be at the top of the browser page.

• NOTE: don’t forget to use more than 3 instruments and the repeat block

Page 37: Programming in scratch

Intro to Drawing• Reset Script• When we're drawing in Scratch, it's helpful to be able to reset the

stage. Resetting the stage moves the character to the center of the screen and removes older drawings from the stage.

Page 38: Programming in scratch

Drawing a Square• Now you'll try drawing a square yourself! Create a new project in

Scratch. But, for your square, try to use the repeat block.• The blocks below will probably be helpful too!

Page 39: Programming in scratch

HINT• You might want to make your character smaller so that it is easier to

see where it is drawing (check out the 4 buttons on the at the top right of the stage--stamp, scissor, and 2 buttons with arrows--these could be helpful!).

Page 40: Programming in scratch

HINT• You might want to see your character drawing the shape you want.

Using delay will help you achieve that.

• Try this out!

Page 41: Programming in scratch

Drawing a Triangle Quiz• Someone wants to draw a triangle in Scratch (like the one below). At

each turn, does the character turn more or less than 90 degrees? The sprite will be turning right.

• Less than 90 degrees• 90 degrees exactly• More than 90 degrees

FALSEFALSETRUE

Page 42: Programming in scratch

Drawing a Triangle Quiz• Someone tried to make a triangle but it doesn't quite look like a

triangle. Would you recommend that they have the character turn MORE at each turn or LESS at each turn?

• More• Less

TRUEFALSE

Page 43: Programming in scratch

Drawing a Triangle Quiz• Someone made tried to make a triangle but it doesn't quite look like a

triangle. Would you recommend that they have the character turn MORE at each turn or LESS at each turn?

• More• Less

FALSETRUE

Page 44: Programming in scratch

DRAWING A TRIANGLE WITH REPEAT• Using a REPEAT try to draw the following shape, an equilateral

triangle:

Page 45: Programming in scratch

Quiz • How many degrees did the sprite turn in total when it drew the

square?

• How many degrees did the sprite turn in total when it drew the triangle?

360

360

Page 46: Programming in scratch

Draw a Pentagon• Use Guess and Check to have the sprite draw a pentagon in Scratch.

• 1. How many degrees did the character turn in total when it drew the pentagon?

360

Page 47: Programming in scratch

Drawing Circles• Have your character draw a circle in Scratch.

• Building off the circle you just made, draw 2 more circles. One should be smaller than the first circle you drew and one should be larger than the first circle you drew.

Page 48: Programming in scratch

Quiz • Which of these scripts will draw a larger circle?

TRUE

FALSE

Page 49: Programming in scratch

Quiz • Draw a staircase across the Scratch stage using repeat.

Page 50: Programming in scratch

Quiz • Draw a dotted line that goes across your Scratch screen. Hint: You

should use repeat.

Page 51: Programming in scratch

Quiz • Assume the sprite starts at the arrow, facing the same direction as the

arrow. Choose which path the sprite will follow when this script is run.

FALSE

TRUE

FALSE

Page 52: Programming in scratch

Draw beautifullyin scratch you can adjust drawing with great features.• Change colors• Change color shade• change font size

Page 53: Programming in scratch

Change font size• You can use change pen size by () and put the value you wish. If it’s

+ve the pen thickness will grow else if it’s –ve the pen thickness will shrink • You also can use set pen size to () and put whatever the value you

want

Page 54: Programming in scratch

Change color• To change the color you use just press the colored square and go with

your mouse anywhere in the page and the color you click on will be you color.

• If you’re using repeat you can use to change the colors each iteration. This will make you able to draw colorful shapes

Page 55: Programming in scratch

Change color • For example. This script draws this colorful square

Page 56: Programming in scratch

Change shade• Changing shade will make the color darker or lighter• The below script draws the right square which go darker every

iteration due to the -20.• If you changed -20 to +20 it’ll draw the left square which go lighter

every iteration.

Page 57: Programming in scratch

Putting all together• Not use your imagination to draw wonderful shapes with music in the

background • Don’t forget to use the “WAIT” block to make your drawings into

animations• Don’t forget to use the “when clicked greed flag” block to enable as

play your wonderful work when you share it.

Page 58: Programming in scratch

THANK YOU! Resources• https://goo.gl/mBFZVw

• Contact• 01022495616• [email protected]


Recommended