May 2019
Intermediate to advanced
496 pages
10h 38m
English
Our lines and turtle are now animating nicely. However, we still need to handle the second type of draw commands: rotations. Just like with movement, our turtle moves with a constant speed when rotating to a new angle. A 360° rotation should take one second to complete, and we can use this to calculate the duration of rotation. For example, a 90° rotation will be 0.25 seconds to complete.
In the last section, we started with a test to check that we were calling requestAnimationFrame. I'm going to skip that for brevity; it's also not essential, since we've already proved the same design with drawing lines. We can jump right into the more complex tests, using the same triggerRequestAnimationFrame ...
Read now
Unlock full access