Students create scripts in which a sprite follows the mouse around the stage and its position is sensed and followed by a second sprite. They also continue to build experience with control structures for which conditions can be set (e.g., loops and conditionals) without yet formalizing. Resist the urge to "teach" these concepts at the outset; instead, allow students to learn how these work in context, applying them to their programs. Students will get lots of experience with loops and conditionals and will codify this learning later.
This lab also solidifies students' understanding of multiprocessing: the fact that two sprites can each run its own script in parallel.
Reading the mouse position will be used repeatedly in later units. It's not something to make a fuss about, but if you skip this lab's first page you may spend the time later teaching about mouse coordinates.
forever
block to initiate an action that continues until the script that contains it is stopped.mouse x
and mouse y
position blocks from the sensing palette.point towards
block.forever
block.repeat until
block to avoid the possibility of an unintended infinite loop.touching?
predicate block to sense if one sprite is touching another.think
block to make a sprite "think" something. (Much like say
, this block makes the sprite display a thought bubble containing the message, as in a cartoon.)tell
block.tell
another sprite what to do.say
and think
blocks for creative expression.repeat until
and forever
?REPEAT UNTIL(condition) { <block of statements> }in which the code in
block of statementsis repeated until the Boolean expression
conditionevaluates to
true.
REPEAT UNTIL(condition)iteration, an infinite loop occurs when the ending condition will never evaluate to
true.
REPEAT UNTIL(condition)iteration, if the conditional evaluates to
trueinitially, the loop body is not executed at all, due to the condition being checked before the loop.