Message-Id: <199904060223.WAA05318@delorie.com> Comments: Authenticated sender is From: "George Foot" To: "Don Ingalls" Date: Tue, 6 Apr 1999 03:20:49 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: sprites CC: djgpp AT delorie DOT com X-mailer: Pegasus Mail for Win32 (v2.42a) Reply-To: djgpp AT delorie DOT com 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