Free Trial

Chapter 1

Introduction to Scratch Programming

Scratch programming is a great tool for kids to kick-start their coding journey.

Its pictorial nature allows young coders to grasp the basic programming concepts easily.

Through the process, you will learn coding fundamentals effectively which form the very basics of all computer programming languages.

For the start, we will learn to create simple sequences, loops and conditional codes. This will build the basics for programming an interactive game of your own.

We will also be covering the following in this exercise:

• Code Blocks
• What are Sprites
• How to use Scratch Control Panel
• Adding Sprites & Background
• Input Triggers

Duration: 30 mins

scratch logo introduction to scratch programming

What You Need

1 x Laptop/PC

laptop

Code Blocks

Computer coding uses logical blocks to perform calculation and computation.

Such logical blocks are used in all other programming languages.

In scratch, you will be using code blocks to build your program. Each code block does its own function and can be chained together to form a code stack.

Some code blocks can move your characters and some can repeat your codes.

scratch code block

What are Sprites

In a game or animation project, we need to create characters or objects. They are called sprites in Scratch.

scratch sprites

Sprites can be customized, moved and response by the codes as you wish.

The codes written will control your sprites and make it behaves according to the code scripts.

codes control sprites.

Scratch Control Panel

Before we move on with our project, we need to understand the scratch control panel.

The scratch panel is divded into three areas:

Stage:
Display your creation.

Code Palette:
Each of these eight buttons lets you choose functions (called code blocks) for programming your sprites.

Script Area:
The area where you build your programs. Stacking blocks together here lets you control the sprites in your project.

scratch control panel

Adding Sprites & Background

To create a game project, we need to add characters called sprites.

We can then write codes for the sprites created and program them to move, talk or behave as we wish.

We can also add a background to the stage to beautify our games.

create new sprite

1) Click choose sprite from library

sprite library

2) Select a sprite to be added

choose background

3) Click choose a background

Input Triggers

Code script can be written to control the sprites.

To run a script, we need to first tell the program when to start.

In this exercise, we will explore the use of start trigger events block to run our codes.

Build the below codes to see how your sprites move.

green flag

Sequences

Code blocks can be put together to form a stack of codes that represent a particular function.

Codes will execute from TOP to BOTTOM.

In this excercise, we will try to make the sprite goes a full round.

To do that, we need the srpite to move and then rotate at each corner

sequence

Loops

If you need to repeat the codes, loops can be used effectively to do multiple repeats.

This will avoid long stacks of codes that does the same thing in pattern.

Using the code stack below, the sprite can be programmed to go around the stage the same way as before.

create new sprite

Rotate one round

sprite library

Rotate forever

loop

Rotate around the stage

Well Done!

Learn about Conditionals in the next chapter.