I used this technique together with the level editor , I explained to you a few chapters ago in my game Snaking . Well here comes a short description of the problem: We want to Snake Movement game in applet Java around but we don’t want to repaint the whole applet everytime we execute the thread. To make this possible, we will add a new Snake Element at the head of the snake and we repaint the last element of the snake in a new color (the color of the background). Well all the other things are in the sourcecode (you can download it at the end of the chapter). I know it won’t be simple to understand it, because all comments are in German but if you are a experienced programmer it should be no problem for you and this is really a difficult chapter!
Oh, well, click on the applet and move the snake with the cursor keys. If you want to make the snake longer, you have to press Space Bar. Alright here comes the download link: