Alterna · учебный материал

Blocks and algorithms

Sequence, parameters, cycles, conditions and trajectory of block programmes.

Что в этом материале

Содержание и основные понятия

The visual program remains an exact algorithm. Each block has an input, action, and result. To find the error, the program is traced in the same way as the text code.
algorithm
cycle
condition
01
Six block families
Developments
Scenario hats: flag, key, click, message. They don't fit into the normal sequence.
Movement
Change coordinates and direction: cross, rotate, slide, change x or y.
Management
Repeating, waiting, branching, and stopping the scenario set the implementation pattern.
Sensors
The values are returned whether the sprite touches the edge or whether the key is pressed where the index is located.
Looks
Shows the image, the line, the size, the layer, and the graphic effect without replacing the condition.
Data
Changed lists and lists keep accounts, lives, speed and collection of game objects.
02
Sequence and Parameters
When the flag is pressed
go to x: 0 y: 0
Say "Start!" 1 second.
change x to 40
Command
изменить x на 40
uses current x, a
перейти в x: 40
Substitutes the coordinates. Parameter is part of the command: without the number the block does not set the full effect.
x = 0
print("Старт!")
x = x + 40
03
Cycle instead of copying
If the same commands are manually repeated, the program is longer and harder to change. The cycle stores the body and the number of repeats.
repeat 4:
move 50
turn 90
When the flag is pressed
Repeat 4 times
50 Steps
turn 90°
Invariant
After each repetition, another side is drawn, and the sprite is at the top of the future side. After four repeats, it returns to the starting point and direction.
04
Condition reading sensor
The Romboid Sensor returns truth or lies.
если
Chooses whether or not to comply with the input commands.
если — иначе
One branch is executed.
When the arrow is pressed to the right
if not relevant to the wall
change x to speed
Otherwise, say "Leave closed"
05
Tracking
Initial value
x = 10
III. Three times implemented
x = x + 5
and then checked
x > 20
.
Step
x to
Command
x after
1
10
x + 5
15
2
15
x + 5
20
3
20
x + 5
25
condition
25
x > 20
Truth

Structural map of textbooks