0% found this document useful (0 votes)
33 views

Class-5 Computer-Gaming In Scratch (Notes)

This document provides notes for Class 5 students on using Scratch to create games, focusing on various Scratch blocks such as Control blocks and Sensing blocks. It outlines how to create a quiz game and a chase game, detailing the rules and steps for implementation, including the use of variables and message passing between sprites. The document emphasizes the importance of loops, conditional statements, and user interaction in game design.

Uploaded by

raghavojasvi777
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Class-5 Computer-Gaming In Scratch (Notes)

This document provides notes for Class 5 students on using Scratch to create games, focusing on various Scratch blocks such as Control blocks and Sensing blocks. It outlines how to create a quiz game and a chase game, detailing the rules and steps for implementation, including the use of variables and message passing between sprites. The document emphasizes the importance of loops, conditional statements, and user interaction in game design.

Uploaded by

raghavojasvi777
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

BML MUNJAL GREEN MEDOWS SCHOOL

SUBJECT- COMPUTER
CLASS 5
GAMING IN SCRATCH (Notes)

You can also use Scratch to design compelling games. To do so, it is necessary to be
familiar with certain Scratch blocks. Let us explore the different categories of blocks used
to develop games.
➢ CONTROL BLOCKS
The Control blocks let you control the flow of execution of steps in a script. You can use
conditional and iterative statements (often called loops) in your script with the help of the
Control blocks. These blocks provide you a lot of capabilities, such as event-driven
programming, creating loops, execution of control logic, and many more. The uses of
some of the most common Control blocks are discussed below:
• Using if-then Block
The if-then block performs a set of actions if the given
condition is true. The condition given here is a Boolean
expression that returns either true or false. For example,
on executing the script given in Figure, if the mouse
pointer touches the sprite; the sprite will change its
direction and colour.
• Using if-then-else Block
The if-then-else block is an extension of the if-then
block. Consider the script given in Figure 7.2 to
understand the use of the if-then-else block. In the
script, the block under the if-then block is executed
if the given condition evaluates to true; otherwise,
the block under the else block is executed.
• Using repeat<count> Block
The repeat <count> block is used to iterate or repeat
a set of commands a specified number of times.
For example, the script given in Figure shows that
the blocks inside the repeat block will be executed
four times.
Class 5, Computer, Gaming in Scratch (Notes), Page 1 of 6 PTO
• Using repeat until Block
The repeat until block is used in the same manner
as the repeat <count> block, except that it checks for
the given condition. The block of script is repeated
until the given condition results to true. As soon as
the condition becomes true, the script stops repeating.
The script given in Figure explains the working of the repeat until block.
• Using forever Block
The forever block is used to repeat a set of commands
forever, i.e., till infinity. In other words, if this block
is used, a set of commands will be executed without
stopping. Observe the script given in Figure
• Nesting of Blocks
You can put various blocks inside each other to perform
certain tasks. This is called nesting of blocks.
For example, you can place the repeat block inside the
forever block or the if-then block inside the repeat block.
The script given in Figure 7.6 describes the nesting of
blocks.
❖ USING ASK AND ANSWER BLOCKS
The Sensing block category has light blue colour-coded blocks, which are used to sense
the keyboard input while executing the script.
The block prompts the user to type input using the keyboard and the
block stores the input entered by the user.
The question appears in a voice bubble on the screen. The program waits until the user
types in a response by either pressing the Enter key or clicking on the check mark 
Let us use these blocks for creating a game.
Creating Quiz Game
While playing games, you must have observed that the score of the player increases or the
timer of the game decreases continuously. The game gets over when the value of the
timer becomes zero. You can create these effects in Scratch projects by updating the
variables repeatedly using the Control blocks, such as forever, repeat, and repeat until.
Class 5, Computer, Gaming in Scratch (Notes), Page 2 of 5 PTO
❖ RULES FOR THE GAME
The rules for creating the quiz game are listed below:
1. 1. The user is asked a question and the prompt for writing the answer will be displayed on
the screen.
2. If the user types in the correct answer, the value of the Score variable will increase by 10.
Also, a message showing 'Correct' will be displayed.
3. If the answer of the question is wrong, then 'Try again!' message will be displayed.
❖ CREATING THE GAME
1. Create a new project in Scratch. Add a backdrop and sprite as shown in Figure 7.7.
2. Click on the Variables block category. Click on the Make a Variable button. The New
Variable dialog box opens.
3. Type ‘Score’ in the New variable name text box. Select either For all sprites or For this
sprite only option and click on OK.
4. The Score variable is displayed on the stage. Now, create the script as shown in Figure7.8

Figure7.7: Creating a Quiz Game Figure7.8: Script for Quiz Game


5. Here, ask and answer blocks are used to ask the question and store the answer,
respectively.
6. Now, click on the Go (Green Flag) button symbol to run the script.
7. Observe that the value of the Score variable is getting modified when a correct answer is
written in the answer box.
8. You can add more than one ask and answer blocks in your script to make the quiz more
interesting.
Class 5, Computer, Gaming in Scratch (Notes), Page 3 of 5 PTO
❖ PASSING MESSAGES BETWEEN SPRITES: You may wonder as to how the actions
of sprites affect each other. For example, if you want sprite A to move when it gets a
message from sprite B, then you can use and
blocks From the Events block category to pass messages among sprites.
❖ You can even communicate between sprites and the stage by sending and receiving
broadcasts. Let us create another game where the sprites, Starfish and Shark, are
conversing with each other. You can add as many characters as you want to make the
scene interactive.
• Creating Chase Game
In this game, the Shark sprite has to catch the Fish sprite after receiving the message from
the Starfish sprite.
• Rules for the Game:
The rules for the game are as follows:
➢ The Starfish sprite sends a message to the Shark sprite
to catch the Fish sprite. On receiving the broadcast, the
Shark sprite moves and catches the Fish sprite.
➢ After this, a message will be displayed that it has caught
the Fish sprite.
Let us now create this story by following the given steps:
➢ Open a new Scratch project. Select 'Underwater 1' backdrop from the Choose a
Backdrop dialog box. Choose Starfish, Shark, Fish, and Crab sprites from the library and
add them to the stage.
➢ Place the sprites on the stage as shown in Figure 7.9. Then, select the Starfish sprite and
add the script as shown in Figure 7.10. Observe the broadcast() block used in the script.
This block is used to broadcast the message, "Go sharky, get the fish" to the sprites.

Figure 7.10 Script for the Starfish Figure: 7.11 Script for the Shark Sprite Figure: 7.12 Script for the Crab
Sprite Sprite

Class 5, Computer, Gaming in Scratch (Notes), Page 4 of 5 PTO


➢ Now, select the Shark sprite and add the script as shown in Figure 7.11.
➢ You can clearly see that in the script, the when I receive() block is used. This ensures
that the broadcast message sent by the Starfish sprite is received by the Shark sprite.
➢ The Shark sprite will act after getting the broadcast message, messagel. It will move
towards the Fish sprite and after reaching it, the message, "I caught the fish!", is
displayed.
➢ Add the scripts for the Crab and Fish sprites to make your story more interactive as
shown in Figures 7.12 and 7.13.
➢ Now, click on the Go (Green Flag) button to execute the Figure 7.13: Script for the Fish
Sprite Scratch project and observe the actions of the sprites.

Class 5, Computer, Gaming in Scratch (Notes), Page 5 of 5

You might also like