Quiz
- With double-buffers, what does it mean when the graphics system "swaps" the "front" and "back" buffer (what happens to the "front" buffer when it gets swapped)?
Imagine two whiteboards. The camera is focussed on one, while the animator is drawing on the other. Then, when the picture is finished, they swap places: the camera switches to the new finished picture, and the animator erases the other board and starts drawing the next frame.
the upside: never an unfinished picture. The downside: twice as many whiteboards.
- "In the UFO code, what is the following chunk of code doing and what purpose does it serve?"
TW.randomBell = function(center,range) { // sample from an approximately bell-shaped distribution var i, sum = 0; for( i=0 ; i < range; i++ ) { sum += 2*Math.random()-1; } return center + sum; };
It's a "quick-and-dirty" random number generator that gives roughly bell-shaped numbers: most in the middle, fewer at the extremes.