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

Workshop

Workshop: Block tracing, events, cycles, conditions, status and project missions.

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

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

Each task requires not only an answer, but also a short explanation. After the review, move the idea to Block Studio and check it on the real game code.
Tracking
debugging
project
01
Trace and understanding
1. Post-cycle coordination
x = 10
then four times "change x by seven." What is x?
Response and review
38.
Four changes are 28:
10 + 4 × 7
.
2. Canvas axis
Sprite has y=120.
y -= 30
?
Response and review
Sprite goes up to y=90 because the y axis grows down.
3. Events
The script begins with a "when the key is pressed" block. Will it be fulfilled after the flag is pressed?
Response and review
Every scenario has its own launch event.
4. Condition
Which branch is executed in "if not the wall, move, otherwise, say stop"?
Response and review
The branch "other": denial makes the first condition false.
5. Variable
Why should the account be stored in a variable, not just drawing the text "Bill: 5"?
Response and review
The text is a performance, and the change is needed for the next calculation, verification of victory, and reconstruction.
6. Two scenarios
Two processors add to x by 5. What risk?
Response and review
The speed will double or the result will depend on the order of processing. One owner of the coordinate or a clear combination of actions is needed.
02
Find the mistake.
Sprite passes the wall.
x = x + speed
if touches_wall(x, y):
x = x
The old x is already lost.
next_x
test him and then change his condition.
Winning every shot
if score = 3:
say("Победа")
For comparison
==
Moreover, a victory state is better preserved so as not to trigger every shot.
Cycle doesn't end.
while x < 100:
say(x)
x does not change, so the condition is always true. Add a change of x or limit the number of steps.
Restart incomplete
if key == "space":
x = 70
We need to restore the whole condition: y, bill, list of objects, timer and mode.
03
Project missions
Labyrinth.
Add at least three walls, start and exit, prove that there's a way out, and ban the way through the walls.
Collector.
Create two types of objects with different values, show me the score and the condition of victory.
Timer.
Add the number of moves left. Each input reduces it; zero translates the game into losers.
My own mechanic.
Make teleport, key and door, accelerator, or moving hazard. Change blocks and at least one Python function.
04
Self-verification of the project
I can explain how the blocks are executed.
The state of the game is stored in data, not just on Canvas.
The project has a purpose, a victory or a loss and a restart.
I've changed the Python generated and I understand the change.
The edges, the walls, the re-launch, and the quick presses are checked.

Structural map of textbooks