nw_barnes at yahoo.com
Sun Aug 24 20:44:07 PDT 2003
--- Max Countryman <maxc at mac.com> wrote:
> One more quick question because I am too lazy to look it up, and/or
> figure it out... If I have two images on the screen, say a scrolling
> background and a sprite, how do I layer these images? Example code
> helps immensely, thank you much,
I don't think there's specific functionality for this built into SDL,
but SDL does support it very nicely. The use of SDL_Surface to store
graphic data that is kept separate and then blitted sequentially to the
display (prior to the buffer flip) should fill your need excellently.
In my current project (a tile-based tactical RPG), the background for
level is built from a dataset and a .bmp that contains images for each
tile. A factory object builds the Stage object out of the data and the
images, blitting from the SDL_Surface with the tile images to a
Surface made to store the terrain for that level. Then the Actor
objects are read in from storage and associated with their image data
from other .bmps.
As the game runs, a sub-section of the terrain is blitted to the
main-display (scrolling used to work, I broke it yesterday 'cause it
was badly in need of re-implmentation), then the Actor objects, all of
which know how to draw themselves and are aware of their position,
blit themselves on top of the terrain.
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
More information about the SDL