Mada za sehemu hiiDesign simple computer programmesMada 1
- Develop simple games that use a single shape by using block-based programming language
Block-Based Programming: Creating Simple Games with a Single Shape
Block-based programming uses visual blocks that you drag and connect to create computer programs. In this topic, you will learn to create simple games using the Scratch program with just one shape (called a Sprite). This helps you think logically and understand how computers follow instructions.
Scratch is a computer program that helps you create simple games and animations. It uses block programming, which means you don't need to type complicated code. Instead, you drag colorful blocks and connect them together like puzzle pieces.
Parts of the Scratch Window
The Scratch window has four main parts:
- Block Menu — Contains all the blocks you can use to create your program
- Script Area — The place where you connect blocks to make your program
- Stage — The area where your game is displayed
- Sprite List — Shows the characters or objects in your game

Step 1: Open Scratch
- Click the Windows button on your computer
- Type "Scratch" in the search bar
- Click on Scratch to open it
Step 2: Choose Your Sprite
The Sprite is the shape or character that will move in your game. For a single-shape game, you will use just one Sprite.
- Click on the Sprite icon in the Sprite List area
- Choose a shape, for example, the Cat or City Bus
Step 3: Add Movement Blocks
To make your Sprite move, follow these steps:
- Click on the Events block menu
- Drag the "when clicked" block to the script area
- Click on the Motion block menu
- Drag the "move (10) steps" block and attach it below the "when clicked" block
Now click the green flag to see your Sprite move!
Worked Example: Making a Sprite Move Forward
Let us create a game where a Sprite moves forward:
When clicked →
move 70 steps
When you click the green flag, the Sprite will move 70 steps forward on the stage.
Adding Sound to Your Game
You can also make your Sprite produce sound:
- Click on the Sound block menu
- Drag the "play sound until done" block
- Attach it below the movement block
Your program will look like this:
When clicked →
move 70 steps
play sound until done
Making the Sprite Rotate
To make your Sprite turn or rotate:
- From the Motion menu, drag the "turn (15) degrees" block
- Change 15 to a bigger number like 45 or 90
- Click the green flag to see the Sprite rotate
Sometimes you want an action to repeat many times. Use the repeat block:
- Click on the Control block menu
- Drag the "repeat (10)" block
- Put other blocks inside it
Example:
When clicked →
repeat 10 times →
move 10 steps
play sound until done
This will make the Sprite move and play sound 10 times.
You can also make your game decide what to do based on a condition:
- Click on the Control menu
- Drag the "if ( ) then" block
- Click on the Operators menu
- Use the "greater than" block to compare numbers
Example:
When clicked →
if (10 > 6) then →
play sound until done
The sound will play because 10 is greater than 6.
Always save your game when you finish:
- Click on File
- Select Save to your computer
- Type a name for your project
- Choose where to save (like Desktop)
- Click Save
| Block Menu | What It Does |
|---|---|
| Events | Starts your program (when clicked, when key pressed) |
| Motion | Makes Sprite move, turn, or go to a position |
| Sound | Plays sounds in your game |
| Control | Repeats actions or makes decisions |
| Sensing | Detects key presses or conditions |
In Tanzania, block-based programming skills are used in small businesses and schools. For example, a shop owner in Dar es Salaam can create a simple game to teach children about counting Tanzanian shillings — where a Sprite moves to show different coin amounts, helping young learners practice math while playing. This same skill can be used to create educational games for teaching numbers, colors, or basic math in primary schools across the country.
Swali
What is the main purpose of the Scratch program as described in the chapter?
Ingia ili kuwasilisha jibu lako na lihesabiwe katika umahiri wako.
Ingia ili kufanya mazoeziMwalimu
Umekwama? Niulize chochote kuhusu mada hii.
Ingia ili kumuuliza Mwalimu wa AI wa Sonza kuhusu swali hili.
Ingia ili kuuliza