Topicm1bb3f12b9c1a7ae4_1528449000663_0Topic

The sprite crosses the roadroadroad

Levelm1bb3f12b9c1a7ae4_1528449084556_0Level

Second

Core curriculumm1bb3f12b9c1a7ae4_1528449076687_0Core curriculum

Grades IV‑VI

I. Understanding, analyzing and solving problems. The student:

2) formulates and writes in the form of algorithms commands consisting of:

c) controlling the robot or object on the screen;

3) distinguishes basic steps in algorithmic problem solving: determination of the problem and goal to be achieved, analysis of the problem situation, developing a solution, checking the problem solution for example data, writing the solution in the form of a diagram or program.

II. Programming and solving problems with the use of computer and other digital devices. The student:

1) designs, creates and writes in a visual programming language:

a) ideas of stories and solutions to problems, including simple algorithms using sequential, conditional and iterative commands and events,    
b) a simple program that controls a robot or other object on the computer screen;

Timingm1bb3f12b9c1a7ae4_1528449068082_0Timing

45 minutes

General objectivem1bb3f12b9c1a7ae4_1528449523725_0General objective

Creates a script that uses conditional statements.

Specific objectivesm1bb3f12b9c1a7ae4_1528449552113_0Specific objectives

1. Defines new variables.

2. Can change the background in the graphical editor.

3. Can apply conditional statements.

Learning outcomesm1bb3f12b9c1a7ae4_1528450430307_0Learning outcomes

The student:

- builds a script that uses conditional statements,

- defines new variables.

Methodsm1bb3f12b9c1a7ae4_1528449534267_0Methods

1. Discussion.

2. Work with computer.

Forms of workm1bb3f12b9c1a7ae4_1528449514617_0Forms of work

1. Individual work.

2. Group work.

Lesson stages

Introductionm1bb3f12b9c1a7ae4_1528450127855_0Introduction

Enter the following short code and observe how the sprite moves.

Explain what x and y mean in the entered commands.

[Illustration 1]

Procedurem1bb3f12b9c1a7ae4_1528446435040_0Procedure

Your task is to create an animation in which the sprite will cross the road when the traffic lighttraffic lighttraffic light turns green.

To create such animation, it is useful to know how to determine the positionpositionposition of the sprite accurately and to create scripts in which, after meeting certain conditions, the sprite performs actions that we planned for it. In this case, the sprite‑cat will cross the road after the traffic light turns green.

Sprite position on the stage:

The stage in Scratch is described by coordinatescoordinatescoordinates; therefore each element on the stage is assigned a pair of numbers or coordinates.

You can see them in the bottom right corner of the stage - when you move the mouse pointer on the stage, its current positionpositionposition is displayed. The horizontal position is x and the vertical position is y.

The size of the stage on which the sprite moves is fixed: the width is 480 points, and the height is 360 points.

Useful for the design of various scripts is the xy‑grid backdrop, which you can download from the Backdrop Library. It facilitates the placement of various elements, according to our ideas.

[Illustration 2]

Creating a backdrop:

Animation with the sprite crossing the roadroadroad can be carried out in many ways. In this example, you'll see how you can use the backdrop to create a traffic light that changes the colours of lights from green to red.

To create a traffic lighttraffic lighttraffic light standing at the pedestrian crossingpedestrian crossingpedestrian crossing, the Urban2 backdrop from the Backdrop Library was used. In the Scratch graphic editor, the traffic light was added. The changed backdrop was duplicated. On one copy a green colour was added to the traffic light, on the second - red. These backdrops will then be used in animation.

What was the effect of these changes you can see on the slideshow.

[Slideshow]

Task 1

Make your own boards with the traffic light. You can use a ready backdrop from the Backdrop Library or do it yourself from scratch in any graphic program.m1bb3f12b9c1a7ae4_1527752256679_0Make your own boards with the traffic light. You can use a ready backdrop from the Backdrop Library or do it yourself from scratch in any graphic program.

Task 2

You already have ready boards with a traffic light. Create a script that will change the lights within a specified time interval. Switch on the green light first, and after 6 seconds it will turn red. The script should be started with the green flag button. The lights are changing until the script is switched off using the red button.

Solution:

[Illustration 3]

Task 3

You already have a crossing where the traffic lights work. Let's agree that one traffic lighttraffic lighttraffic light will serve the whole crossing for the time being.

Build a script that will place the sprite in front of the pedestrian crossing. The sprite task is to go through the first and the second pedestrian crossing. At this stage, do not worry if the sprite passes red or green light.

Tips:

To place the sprite in front of the pedestrian crossingpedestrian crossingpedestrian crossing, you need to find the coordinatescoordinatescoordinates of the point at which the sprite will start moving. Let the sprite always start from the same position (e.g. let it look right).

Then turn the sprite in the direction of the passage. After crossing the sprite should turn again towards the next passage.

Solution:

[Illustration 4]

Creating your own blocks:

Sometimes it happens that we want to repeat a series of commands in the script. Every change you want to make requires careful addition of information in many places. This can be avoided by creating a new variable where we will change the settingssettingssettings only once.

To create a new variable, in the More Blocks category, click on the Make a Block button. Give it a name. Then we attach other blocks to it, which we usually use in several places. In the old script, in place of the removed blocks insert a new block that contains all the commands.

Take a look at the drawing below. It shows how we can create a new block.

[Illustration 5]

Task 5

The sprite can already pass through the crossing, but it does so incorrectly, without waiting for the green light.

Modify the script in a way that the sprite will cross the roadroadroad on the green light. When the light is red, the sprite must wait for the light to change.

Tip:

A block of conditional instructions is helpful in solving the problem. The commands contained therein will only be executed if the logical condition is true. We build conditions from blocks from the Sensing and Operators category.

[Illustration 6]

If we want the sprite to cross the road on the green light, and wait on the red light, we can solve it in the way shown in the picture (using the variable previously defined).m1bb3f12b9c1a7ae4_1527752263647_0If we want the sprite to cross the road on the green light, and wait on the red light, we can solve it in the way shown in the picture (using the variable previously defined).

[Illustration 7]

Example solution:

[Illustration 8]

Lesson summarym1bb3f12b9c1a7ae4_1528450119332_0Lesson summary

Conditional instructions are useful in solving various problems. In Scratch you can also define your own variables.

Selected words and expressions used in the lesson plan

boardboardboard

conditional statementconditional statementconditional statement

coordinatescoordinatescoordinates

pedestrian crossingpedestrian crossingpedestrian crossing

positionpositionposition

roadroadroadroadroad

settingssettingssettings

traffic lighttraffic lighttraffic light

m1bb3f12b9c1a7ae4_1527752263647_0
m1bb3f12b9c1a7ae4_1527752256679_0
m1bb3f12b9c1a7ae4_1528449000663_0
m1bb3f12b9c1a7ae4_1528449084556_0
m1bb3f12b9c1a7ae4_1528449076687_0
m1bb3f12b9c1a7ae4_1528449068082_0
m1bb3f12b9c1a7ae4_1528449523725_0
m1bb3f12b9c1a7ae4_1528449552113_0
m1bb3f12b9c1a7ae4_1528450430307_0
m1bb3f12b9c1a7ae4_1528449534267_0
m1bb3f12b9c1a7ae4_1528449514617_0
m1bb3f12b9c1a7ae4_1528450135461_0
m1bb3f12b9c1a7ae4_1528450127855_0
m1bb3f12b9c1a7ae4_1528446435040_0
m1bb3f12b9c1a7ae4_1528450119332_0
road1
road

ulica

Rm0zFK3IYPO7d1
wymowa w języku angielskim: road
traffic light1
traffic light

sygnalizator

R1D6dOpdqPHPe1
wymowa w języku angielskim: traffic light
position1
position

pozycja

R1Y4aNXPyE5G81
wymowa w języku angielskim: position
coordinates1
coordinates

współrzędne

RnkbvzDuCIdLH1
wymowa w języku angielskim: coordinates
pedestrian crossing1
pedestrian crossing

przejście dla pieszych

RjOzid1Nf7eSZ1
wymowa w języku angielskim: pedestrian crossing
settings1
settings

ustawienia

R1HHcNdjVK1VQ1
wymowa w języku angielskim: settings
board1
board

plansza

RVN3k5D1uV1GA1
wymowa w języku angielskim: board
conditional statement1
conditional statement

instrukcja warunkowa

R1BFiHK2PrX211
wymowa w języku angielskim: conditional statement