GoalPlan scripts for two sprites so that they begin together, begin in the right places and finish together.
New words
routine · a set of moves done in the same orderstatic · not movingfinish together · end at the same moment
Explanation
When two sprites perform together, each one needs its own script. Both scripts start with the same event, so they begin at the same time. Each script starts with a go to block, so the sprite is in its right place on every run. Then we count the time each script takes. If one script is shorter, we add a wait block so both finish at the same moment. A sprite with no script, such as a tree, is static. It does not move, but it is still part of the picture.
Worked examples
Seconds
Butterfly: y
Bee: y
0
−60
−60
1
60
0
2
−60
60
The butterfly goes up in 1 second and comes down in 1 second, so its script takes 2 seconds. The bee glides up slowly in 2 seconds. Both finish after 2 seconds, but they are in different places: the butterfly is down at y: −60 and the bee is at the top.
Both scripts begin with the go to block. If we press the space key a second time, the sprites jump back to their start places before they move. Without this reset they would begin where they stopped.
The picture has a tree that never moves. It has no script, so it is static. It is not a mistake. Many projects have background objects that just stand there.
Class activity
Two dancers (with a friend): plan a routine on paper. Each dancer has a start spot, marked with a book or a shoe. On “Go!” both dancers do their own moves, such as “walk 3 steps, spin, clap”. The routine must take the same time for both, so use a count of beats: each move lasts 1 beat. Add a “wait” where one dancer has fewer moves. Test it and see if you finish together.
Practice
1
Dancer A waits 1 second and then glides for 2 seconds. Dancer B only glides for 2 seconds. They start together. What should be added to B so that they finish together?
A “wait (1) seconds” block in B, because A takes 1 + 2 = 3 seconds and B takes only 2.
2
In the butterfly script from the explanation, where is the butterfly after 1 second?
At y: 60. It has glided to the top.
3
Why does each script start with a go to block?
So the sprite starts in the same place every time the key is pressed.
4
A project has a sprite that is a drum with no script. Is that a mistake?
No. The drum is a static object. It does not need to move.