[SDL] Creating tiles
ochal at kefren.be
Tue Dec 12 12:41:00 PST 2006
I'm currently trying to write a routine to load tiles into an array of
*surfaces from a png file, but BlitSurface fails to copy the parts of
the image into the proper cells of the array.
I'm hoping someone can tell me what i did wrong.
Oh, the tiles are actually used to hold a fixed width font sized 10*10.
This is the code:
SDL_Surface *buffer = NULL;
buffer = IMG_Load(tilefile);
if (buffer == NULL)
fprintf(stderr, "Couldn't load %s: %s\n", tilefile, \
/* file loaded, blit the tiles to the proper cells */
for (i = 0;i<127;i++)
tilearea.x = 0;
tilearea.y = i*10;
tilearea.w = 10;
tilearea.h = 10;
if (SDL_BlitSurface(buffer, &tilearea, tiles[i], \
NULL) < 0)
fprintf(stderr, "Failed blitting the tile into the cell \
More information about the SDL