4. Loops¶
Three loop blocks cover the looping arrow from Unit 1:
repeat (10)
move (10) steps
repeat until <touching [treasure]?>
move (5) steps
forever
turn (1) degrees
repeat (10) runs a fixed number of times. repeat until <...> keeps going while a condition is false, and stops the moment it becomes true — this is the WHILE / REPEAT UNTIL pseudocode from Unit 1. forever never stops on its own.
Try it
Use repeat until to walk your sprite across the stage until it touches another sprite or object.
Tip
forever is great for animation (spinning, idle wobbling) but dangerous for game logic that's supposed to end — if you want a loop to stop, reach for repeat until.