To complete the illusion of sprite movement, you need a way to erase the sprite's image from the background before you draw it at its new location. You could reload the entire background and redraw the sprite, but a great deal of performance would be lost. Instead, you can keep track of the rectangle that is the sprite's last location and redraw only that portion. This method is called "patching." To patch the sprite's old location, redraw the sprite's old location with a copy of the original background image, which you previously loaded on an off-screen surface. The process works well, because it doesn't waste a lot of processing time blitting an entire surface each cycle.
This process can be described in the following simple steps:
1.Set the patch rectangle to the last sprite location.
2.Patch the background at that location by blitting to the background image from the off-screen master copy.
3.Update the sprite's destination rectangle to reflect its new location.
4.Blit the sprite to its newly updated rectangle in the background image.
5.Repeat.
Using straightforward C/C++ combined with the graphics power provided by DirectDraw, you can implement this process to make a simple sprite engine.