On this page, you will change the script so that the sprites don't move forever, but only until they touch.
forever
block with a repeat until
block.repeat until
block. Set it to repeat until it is touching
Leader.touching
Follower.move
block with a small number so Follower doesn't catch Leader too quickly.move
is 0?
When a program keeps running forever, that's called an infinite loop.
mouse y
, which isn't built into their language). So this example translates them to numFishand
MouseY().
()or box after
MouseYis that
MouseY()is a procedure call even though it doesn't take any inputs.
The script
would be written as
REPEAT UNTIL(mouseY() < 0) { DISPLAY(numFish) }
Remember, you don't need to learn to write the made-up language used on the AP exam. You just have to be able to read and answer questions about it.
Right now, when the sprites meet, they just stop. Make them have a conversation when they stop. You can do that by adding code like this to Leader's script. Make up your own conversation. You can use any language you can type. Here's an example using several languages.
A code segment is a sequence of connected instructions that carry out a purposeful action, such as the one pictured on the left, which animates a conversation. The instructions in the code segment are carried out in order, from top to bottom.