ilovepdf_merged

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

INTRODUCTION TO

SCRATCH PROGRAMMING
INTRODUCTION

Programming is the art of writing


instructions to tell a computer what to do.
A set of instructions is called a program.
The instructions are written in what’s
known as a programming language, and
there are thousands to choose from.
WHAT IS SCRATCH?

Scratch is a programming language that is


perfect for making games, animations,
interactive stories and other visually rich
programs. It provides a great introduction
to programming for people of all ages. It’s
widely used in schools and colleges.
WHY SCRATCH PROGRAMMING
Scratch is easier to use than most other programming languages for
a number of reasons:
• You don’t have to remember or type any commands: they’re all
on screen, so you can just drag and drop them.
• Commands fit together like jigsaw pieces, so there are strong
visual hints about how you can combine them.
• Error messages are rare. Because Scratch commands lock
together, programs always make some kind of sense. It is possible
to still write programs with logical errors in, if they don’t do what
you expected, but Scratch guides you to write things that work,
rather than nagging you when they don’t.
• The commands are color-coded and
categorized, so you can easily find a
command when you need it.
• The commands in Scratch simplify common
activities in games, such as testing whether a
missile has hit an alien (collision detection),
or rotating a character on screen.
USING THE SCRATCH SCREEN
The main parts of the screen are:
• Stage: This is where you can see your animations
and games in action. When Scratch starts, there’s a
large orange cat in the middle of the Stage.
• Sprite List: The cat is a ‘sprite’, which is like a
character or object in a game. Your project might
include lots of sprites, such as the player’s spaceship,
invading aliens and a missile. In the Sprite List, you
can see all the sprites that are in your project, and
click them to switch between them. In both versions of
Scratch, the Sprite List is underneath the Stage
Blocks Palette: In Scratch, you give the computer
commands by using blocks, which are instructions that fit
together like jigsaw pieces. The Blocks Palette presents
you with all the blocks you can use. When you start
Scratch, you can see the Motion blocks, which are color-
coded in dark blue, and are used for moving sprites
around the Stage. You can browse a different set of
blocks in the Blocks Palette by clicking one of the
buttons above it, such as the Looks button or the Sound
button.
http://www.itrackls.co.uk/tutor/scratch.pdf

Main Screen
Main Menu Rotate Sprite Sprite Start Stop
Options Toolbar Button Button

Instruction
Banks
Sprite

Scripts Area
for
Instructions

Sprite
Toolbar

Sets the
Background

Rotate Sprite Options


Rotate Smoothly Blue line shows the
direction the sprite
Just flip left to right will move

Don’t rotate at all


Grow
Sprite Toolbar Copy Delete Sprite

Shrink
Move
Sprite

ViewFirst
My full screen
Program
presentation

1
My First Program

 Start a new Scratch project.

 Set the Rotate Sprite Option to just flip right-left.

 Click on the Yellow Control Button.

 Drag the instruction to the


Scripts area.

 Drag the shape onto the scripts area and change the

value to 11.

Link it under the when clicked shape.

 Click on the Blue Motion Button

 Drag the shape onto the scripts


area and change the value to 20.

Link it inside the Repeat shape.

 Click on the Yellow Control Button

 Drag the shape onto the scripts area and change the
value to 0.2.

Link it inside the Repeat shape

 Click on the Blue Motion Button

 Drag the shape onto the scripts area and change


the value to 180.

Link it inside the Repeat shape.

 Click on the Yellow Control Button

2
 Drag the shape onto the scripts area and change the
value to 0.2.

Link it inside the Repeat shape.

 Now RUN the program by clicking on the START button.

Now let’s make the program more interesting

 Click on the Stage button

 Click on the Backgrounds tab

 Click on Import

 Double click on the Outdoors folder

3
 Click on the all-sports mural and then click on ok

Let’s add some music!

 Click on the Sounds tab

 Click on Import

 Double Click on Music Loops

4
 Click on HipHop and then click OK

 Click on Sprite 1

 Then click on the Scripts Tab

 Click on the Pink Sound Button

 Drag the shape onto the scripts area and change

the value to HipHop.

Link it above the Repeat shape.

5
 Your program should now look like this:

 Run the program again.

Now pick your own sprite and background and see if you can get it to move.

6
Saving Your Programs

 Click on Save As from the Main Menu at the top of the screen

 Then click on Computer

 Double Click on the


H: drive

 You are now in your My Documents

 Double click your Computing folder and create a New Folder called

My Scratch Programs

 Double click this folder

 Type a suitable Filename at the bottom and click OK to save

7
Program 2 – Drawing Shapes Programs

 Open up a new Scratch project

 Click on the Costumes tab

 Click on import

 Double click on the Animals folder

 Select starfish1-a

 Click on Shrink Sprite from the sprite tool bar

 Place the shrink cursor over the star fish and click 10 times.

 Set the Rotate Sprite Option to just flip right-left.

The next program will move the starfish in a SQUARE pattern,


where each side of the square is a different colour.

a) Copy this program carefully


and see if it will draw a square.

b) Now change the program so that


it will draw a rectangle with sides
of 100 and 200.

c) Delete the program instructions and write


a program to draw a triangle with sides of
200.
{Remember – triangles have 3 sides}

To calculate the angle in the sprite has to turn


to make each shape:

Angle = 360/number of sides.

8
d) Copy down the following table and complete the blank boxes. The
make up programs for the Octagon and the Decagon.

Shape Number of Sides Angle


Square 4 90
Triangle 3
Octagon
Decagon

Program 2 – Drawing Shapes Programs

The instructions for the last set of programs were quite long because the
same instructions were used over and over again. We have seen in the
Dancing Cat program that instructions can be repeated inside a LOOP.

Create programs using a Repeat Loop which could be used to draw each of
the shapes in the table above.

{Hint – The following instructions might be useful}

9
Program 3 – Bouncing Ball Game

 Start a NEW Scratch program

 Click on Choose a New Sprite from file

 Double click on Things

 Select Beachball1
and click OK.

You have to delete the Cat sprite by clicking on the scissors and then on
the Cat.

10
The instructions for the program are shown below.

These instructions are carried out on the bouncy ball sprite you have chosen.

The yellow Repeat until loop will carry out all the instructions inside it
until the mouse pointer touches the bouncy ball Sprite.

The instructions if on edge bounce will stop the ball from staying on the
edge of the screen.

How long does it take you to click on the ball.

Run the program by clicking on the start button.

Save your game as Bouncing Ball in your My Scratch Programs Folder.

11
Program 4 – Editing a Sprite

Sprites can be changed to create animations. This is done in a ‘Paint’ type


screen.

 Choose the sprite called ‘Squaregirl’ or ‘Squareguy’ from the People


folder.

 Delete the Cat Sprite.

 Click on Costumes

 Choose Copy

 And then Edit from squaregirl2

12
The paint screen should appear. Some of the tools are described below.
Shrink or Enlarge Sprite Rotate or Flip Sprite

Change size of
Eraser/ brush/
Line thickness/ etc

Zoom in or out

 Change the mouth slightly as if the sprite was trying to say something
and click on OK.

 Repeat the Copy and Edit instructions a few more times until the
sprite seems to ‘talk’ to you when you run the program.

 Use the purple Look instructions to create a program to make the


sprite talk, pay particular attention to the “switch costume
instructions”

 Save your program as Chat in your My Scratch Programs Folder.

 Try drawing or importing a different sprite and animate it in a suitable


way.

 E.g. A person kicking a ball, a bird flapping its wings etc.

 REMEMBER to COPY and then EDIT the Sprite.

Save your program in your My Scratch Programs Folder.

13
Program 5 – Moving to a new Stage

Some games that you play at home have different levels, each with a
different background or level of difficulty. In the exercise you will play a
simple Maze game which has 2 levels and then you can add another level
by yourself.

Instructions

 Start Scratch and open up the program Maze Game from S1 on


Grove/Computing/Scratch/Maze Game.

 Try to complete both levels of the maze.

Creating Another Stage

 Click on Stage

 Click on Backgrounds

 Use Copy at Maze 2 then Edit


Maze 3 to draw another maze.

THE SCRIPT FOR THE PROGRAM NEEDS TO BE CHANGED.

14
Script

 Look at the code for Sprite1 (the ball)


What the Instructions Mean

Start at position x: -215 y: 96

If the ball touches a black line


Display the message
Stop the program

If the ball touches a red line


Display the message
Send the program the message
Yippee
Go to position x: 2 and y: 14

This instruction operates the down arrow


key. When the down arrow key is
pressed the sprite points down and moves
down the Y Axis

 You should add in 3 more sets of instructions like this one which
operate the:
o Up Arrow Key REMEMBER
o Left Arrow Key
o Down Arrow Key X Axis is horizontal (across the way)
Y Axis is vertical (up and down the way)
 Each If statement controls a level.
o The colour to finish each level should be different
o so should the message in the speech bubble
o and the word broadcast.

 To see the code for the broadcast message, click on Stage and then
Scripts.
When the program starts Maze 1 will be
displayed.

When the program receives the message


Yippee, the background Maze 2 will be
shown.
15
 To create another level, Click on Stage then Backgrounds.

 Copy Maze 2 and edit Maze 3 to create a different Maze.

 REMEMBER to make the finishing line a different colour.

You can now add the code to make it play the next level.

 Click on Sprite1 (the ball) to see the Scripts.

 Add another If statement after the end of the second if statement


so that if the ball touches the BLUE line:
o A message will be displayed
o A message is broadcast
o The ball is moved to the Start position in the next level.

 Make sure that your new section of code is inside the forever
loop!

 Now click on Stage and then Scripts. Add code to show maze 3

 HINT – Look at the code that is already there.

 Save your program in your My Scratch Programs Folder.

 You can add as many levels to this program as you like.

Scratch Challenge

Write a program to draw this picture on the screen.

16
2/7/23, 8:02 PM Intro to Scratch

NAME :
CLASS :
Intro to Scratch
15 Questions DATE :

1. What is Scratch?

A A Programming Language B An Animation

C A Computer System D A Code

2. A good way to get started in Scratch is to?

A Start from Scratch. B Create a sample project.

C Remix a sample project. D Make a complicated game.

3. As well as being a programming language Scratch is also a?

A Tutorial B Social Media

C Community D Project

4. How much does Scratch cost to download?

A $1.99 per month B Free

C $24.99 D $9.99 per month

https://quizizz.com/print/quiz/5714c8df5df6890a309f6bcc 1/4
2/7/23, 8:02 PM Intro to Scratch

5. How do you create a loop in scratch?

A Snap a Block B Use a Cat Sprite

C Use a Condition Block D Use a Repeat Block

6. How do you create code in Scratch?

A Draw blocks in the editor. B Copy and paste code.

C Write code in the editor. D Snap blocks together.

7. Collaborating on your program means?

A Plagiarising others. B Sharing your project online.

C Working with others. D Using example projects.

8. Who develops the Scratch software?

A Manchester Institute of Technology B Manchester Information Technology

C Massachusetts Institute of Technology D Montreal Institute of Technology

https://quizizz.com/print/quiz/5714c8df5df6890a309f6bcc 2/4
2/7/23, 8:02 PM Intro to Scratch

9. The cat in Scratch is an example of a..?

A Template B Character

C Sprite D Avatar

10. In Scratch which blocks are yellow?

A Variables B Control

C Sensing D Motion

11. In Scratch which blocks are blue?

A Looks B Sound

C Control D Motion

12. In Scratch which blocks are purple?

A Motion B Variables

C Looks D Sensing

https://quizizz.com/print/quiz/5714c8df5df6890a309f6bcc 3/4
2/7/23, 8:02 PM Intro to Scratch

13. The blocks / code that controls a sprite is called the..?

A Lines B Instructions

C Script D Actions

14. What do are the blocks that stores values called e.g. "eaten" in
Shark Attack?

A Looks B Operators

C Constants D Variables

15. To change the appearance of a sprite we can give it a different..?

A Style B Stage

C Look D Costume

https://quizizz.com/print/quiz/5714c8df5df6890a309f6bcc 4/4

You might also like