The repeat until loop in Scratch executes the statements inside the loop until the specified event happens. The event used in the repeat loop in program 2 is “touching the edge” which corresponds to reaching the edge of the stage.This implies that the ball moves to the right until it touches the edge of the stage.
For teachers already familiar with Python, we point out that repeat until loops are similar to while loops in Python. In particular, “repeat until touching the edge” corresponds to “while not touching the edge”.
- Scratch link: http://scratch.mit.edu/projects/16287109/. Click the ‘see inside’ icon on the webpage to see the code.
- Program file: P2_repeat_until.sb2
The statement “set x to 0” positions the circle to be at the middle of the stage. The circle then moves to the right. The statements inside the repeat-until loop are executed until the circle touches the edge. This means the circle rolls until it reaches the right edge of the stage.
Having circles or other objects roll around the stage is a great way to try different conditions. Students generally like these problems and many create interesting new versions. Video Length: 2:41