We will learn how to use the double buffering technique to make things look smooth.
Here is how buffering works:
If you just draw everything to the screen, you will notice that you get a lot of flicker. This is because you are drawing directly to the screen, which is updated by the operating system at an unknown rate! Buffering gets rid of flicker because it minimizes direct drawing to the screen. If you draw each component onto the ‘buffer’, and then the complete screen sized buffer to the screen: flicker is eliminated since you draw everything at once in one pass. It’s that simple. You will also notice, in the unbuffered mode, that the ball will zoom across the screen (if you have a relatively fast computer). Even in buffered mode, things can move pretty fast (or slow – again depending on the speed of your computer). This problem is fixed using timers, which will be explained in the next lesson, so don’t worry about this for now.