Big picture: the topic of animation is a source of confusion both in App Lab AND generally.
Generally speaking you can’t use loops to create animation effects in App Lab - this has to do with the event-driven paradigm of App Lab. If you’re running a loop, that takes over the machine and it can’t do other things in parallel, like listen for events. The source of confusion is of our own making – when you use loops with the Turtle it does cause an animation-like effect. That’s because we did behind the scenes magic to make it seem like you’re using a loop to cause animation. We did that with the thinking that it’s a natural way for students to think about iterative behavior and we wanted to reduce barriers to using loops in the first place - otherwise it’s hard to justify using a loop in an event-driven environment for things besides data processing.
Thus, to make animation work in an event-driven paradigm you have to…use events! That’s what the timedLoop
command is for. What timedLoop
does is fire an event at a given interval of time. So rather than a continuous loop that takes over the machine, you get to process the code in the event-handling function at every interval.
Hope that makes some kind of big-picture sense.
Baker
CSP Team