[SDL] Tiles
Tane Piper
tane.piper at ukonline.co.uk
Sun Mar 23 13:00:03 PST 2003
Use this very handy function which was posted on this list before:
void BlitTile(SDL_Surface *tiles, int tile_x, int tile_y,
int tile_width, int tile_height,
SDL_Surface *destination,
int dest_x, int dest_y)
{
SDL_Rect src, dest;
src.x = tile_x;
src.y = tile_y;
src.w = tile_width;
src.h = tile_height;
dest.x = dest_x;
dest.y = dest_y;
dest.w = tile_width; /* Redundant */
dest.h = tile_height; /* Redundant */
SDL_BlitSurface(tiles, &src, destination, &dest);
}
Nwo you just use the function to specify the X & y pos + size of the tile
you want to copy, and the x & y location of where you want to blit it.
Regards,
Tane Piper
http://tane.cream.org
----- Original Message -----
From: "Salvo Di Fazio" <salvodif at libero.it>
To: "SDL" <sdl at libsdl.org>
Sent: 22 March 2003 18:28
Subject: [SDL] Tiles
> Hi guys,
> I have a little problem.
> I would like to make a program to cut tiles from a bitmap.
> So, I created two SDL_Surface, the first is bitmap and the second is
tiles.
>
> Now I want to copy a part of bitmap into tiles... but I couldn't do it
>
> Following you will find my code... tnx
>
>
> SDL_Surface *bitmap, *tiles;
> SDL_Rect src, dst;
>
> bitmap = SDL_LoadBMP(argv[1]);
>
> src.x = 0;
> src.y = 0;
> src.h = 32;
> src.w = 32
>
> dst = src;
>
> SDL_BlitSurface(bitmap, &src, tiles, &dst);
>
> SDL_SaveBMP(tiles, file);
>
>
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>
More information about the SDL
mailing list