Mail Archives: djgpp/1999/04/05/22:23:32
On 5 Apr 99 at 20:04, Don Ingalls wrote:
> How do I make multiple sprites without the flickering?
You need to time things so that the user never sees the screen
without the sprites being displayed. There are two simple ways
to do this; most people actually use both.
The first is double buffering. Allocate some memory, and use
that as if it were the screen. In Allegro this is just a
memory bitmap, but you didn't say whether or not you were using
Allegro. You do all your drawing (and erasing) to this memory
area, then copy the whole thing to the screen in one go. This
way your sprites are always displayed on the screen; there's no
time during which they are erased from it.
The second way is to synchronise your drawing with the end of
the frame. In Allegro you just call `vsync', and it waits for
the monitor to finish drawing a frame. Then you can do what
you like for a short while, and know that the monitor is not
currently displaying anything. So you can erase and rewind
without the user noticing.
Combining the two can be a good thing because if the copy in
the first system occurs when the monitor is halfway through
drawing a frame, the user will see the top part of one frame
and the bottom part of another, which can look messy -- it's
called `shearing'. If you do the vsync before blitting the
buffer to the screen, and the blit gets done before the monitor
starts displaying the next frame, you'll get rid of the
shearing.
Note that `vsync' is a delay call; your frame rate will drop to
something that divides the refresh rate of the monitor.
--
George
- Raw text -