Explaining TopPublic, Confidential, Readable, and WritableAnimations

Animations

Last time we created a rather pathetic version of pong. This time we talked about the real thing. The key is to create a loop that operates at the same time as the rest of our program executes. E.g.., having the animation go on shouldn't stop the program from responding to mouse actions.

Animated object will need to import the "animation" library, which is pre-compiled in the web browser. To create an animated object we must be in a file that imports "animation" at the beginning, e.g.

   import "animation" as animator

This animator object supports two new forms of "while" loops:

   animator.while {cond} pausing (ptime) do {stuff}
   animator.while {cond} pausing (ptime) do {stuff} finally {endStuff}

Both loops work similarly. If cond evaluates to true then execute stuff, phase by ptime and then repeat. While all of this is going on the rest of the program after the end of the while loop continues to run.

The only difference between these two constructs is that the second one executes endStuff immediately after the evaluation of cond returns false.

That is really all there is. We saw how this worked last time with FallingBall.


Explaining TopPublic, Confidential, Readable, and WritableAnimations