Programming in Scratch
Programming in Scratch
SCRATCH
DAY 1: INTRODUCTION TO
SCRATCH
WHAT IS SCRATCH?
Scratch is a high-level block-based visual programming language. It is
an educational tool for programming.
Explaining key terms: A high level programming language is a
programming language with strong abstraction from the details of the
computer. A visual programming language is any programming
language that lets users create programs by manipulating program
elements graphically rather than by specifying them textually.
There are four main elements in Scratch: the stage, the sprites, the
script, and the programming palette.
RUNNING APPLICATION IN
PRESENTATION MODE
Presentation mode, also called full screen
mode is accessed by clicking on the button at
the top right of the scratch program. This
displays your application in full screen, it
presents your project. Projects are tested
before uploading. While in presentation
mode, projects cannot be edited.
WORKING WITH SPRITES
Sprites are images you can create and program in the
scratch interface. They can take the form of shapes,
characters, animals, people, and more.
A sprite performs functions controlled by scripts. Think of
a sprite as an object in your program that will perform
actions.
You could work with multiple sprites, animate them, make
them interact. Sprites are like cast in a show or movie.
WORKING WITH SCRATCH
TOOLBAR
The toolbar is located at the top of the program and it contains many
important functions in Scratch.
At the extreme left is the text ‘SCRATCH’ .
Next is an image of a grey sphere or a globe. Clicking on this offers a drop-
down list with all the languages that Scratch is available in.
Next, there are several menu options:
File menu:
• New: creates a new project from a blank template.
• Load from your computer: opens an already existing project saved on
your computer.
WORKING WITH SCRATCH
TOOLBAR
• Save to your computer: this saves your current project.
Edit menu:
• Restore: this would undo the last action carried out in the current
project.
• Turbo mode: sets the player into turbo mode where the code is
executed very quickly.
Tutorials: this shows a series of guidelines on how to create various
projects.
Scratch project: this just species that you’re working on something.
WORKING WITH SCRATCH TOOLBAR
Click the ‘file’ button at the top left corner of your screen. Select ‘save
to your computer’. Choose the destination you want your project to be
saves at. Rename the file, and click on ‘save’.
DAY4:MOVING THINGS AROUND
WORKING WITH MOTION CODE BLOCKS
Just as the name says, motion blocks sets which ever sprite you’re
working on in motion. You could move a certain number of steps, or
turn around, go to a specified position, amongst many others.
All you need to do is drag the block you would want to use.
MOVING AND ROTATING SPRITES
If you want the sprite to move, then use the following code:
When green flag clicked forever if up arrow pressed change y by 10, if
right arrow pressed change x by 10, if left arrow pressed change x by -10,
and if down arrow pressed change y by -10. If you want it to go faster or
slower, change the numbers in code.
To rotate a sprite:
It has a single input parameter where you can set the number of
degrees it should rotate the sprite.
Blocks that designate direction can be used instead of a number
by placing them in the circle to replace it.
SETTING SPRITE DIRECTION
A sprite's direction value controls how much a sprite is rotated. It is
measured in degrees (°) and ranges from -180° to 180°.
Select the ball sprite from the sprites list, and find the script that
contains the point in direction () block.
Let's simplify the direction change. Drag the green number block that
currently contains the calculation 90 - direction out of the value of
the point in direction() block. You can drag it down to a blank spot in
the scripts area. Change the value of the point in direction block to 180.
CHANGING AND REPOSITIONING OF SPRITE
The look of a sprite can also be changed by using costumes. The current
costume of a sprite can be changed by clicking on the "costumes" tab
and clicking on the desired costume of choice, or by using Looks blocks
to select the sprite's costume.
Go to Your Starting Point, reset your sprite at the beginning of the
game. Drag your sprite to where you want it to start. Then, click the
motion category.
WORKING WITH SCRATCH CARDS
Scratch Cards are cards that are used to teach Scratchers(these are
people that use Scratch) how to program in Scratch. These cards do not
require a computer to learn Scratch; users can quickly learn how to
program in Scratch, no matter where they are. Scratch Cards can also
be used for reference.
Because of their portability and simplicity, Scratch Cards can be used
when Scratchers first start learning Scratch, and can be used by Scratch
clubs and classes.
DAY 5: PROJECT
DAY 6: SENSING SPRITE POSITION AND CONTROLLING
ENVIRONMENTAL SETTING
The Scratch Folder environment setting is the location of a folder you
can use to write file-based data, such as shapefiles, text files, and layer
files. Writing output to the scratch folder will make your code portable,
as this folder will always be available or created at execution time.
The primary purpose for the scratch workspace environment is for use
by Model Builder. Model Builder needs a workspace to write
intermediate datasets—datasets that are of no use once a model is run.
Although its primary purpose is for Model Builder, there may be times
when you want to set it for tool dialog boxes.
WORKING WITH SENSING CODE BLOCKS
Sensing blocks can be used for a number of different things. They can
be used to keep track of how long things take within your program.
They can be used to ask questions and then store the answers to be
used within other blocks, and they can also be used to detect whether
a key has been pressed on your keyboard or if there’s been movement
of your mouse.
RETRIVEING MOUSE BUTTON AND COORDINATE STATUS