[SDL] Creating tiles

Nicolas Goy - kuon - 時期精 Nicolas Goy - kuon - 時期精
Tue Dec 12 12:50:12 PST 2006


On 12 Dec 2006, at 21:41, Ochal Christophe wrote:

>
>
>
>     SDL_Surface *buffer = NULL;
>     SDL_Surface *tiles[127];
>     SDL_Rect tilearea;
>     int i;
>     buffer = IMG_Load(tilefile);
>     if (buffer == NULL)
>        {
>        fprintf(stderr, "Couldn't load %s: %s\n", tilefile, \
> 	SDL_GetError());
>        return 1;
>        }
>     else
>        {
>        /* 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 \
> 			\n", SDL_GetError());
>               }
>            }
>        SDL_FreeSurface(buffer);
>

I'm not sure as I read this quite in a hurry, but tilearea.w = 10;  
and tilearea.h = 10; will be ignored, perhaps you should check  
your .x and .y.

Don't know if it helps, again just read that fast.

Regards

-- 
Kuon
CEO - Goyman.com SA
http://www.goyman.com/

"Computers should not stop working when the users' brain does."



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2434 bytes
Desc: not available
Url : http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20061212/1e39e5f7/attachment.bin 


More information about the SDL mailing list