Author Topic: grab a region with SDL  (Read 2906 times)

creek23

  • Guest
grab a region with SDL
« on: June 13, 2011, 02:22:49 am »
Hi all!

I have a tiled image which is a tileset for a map and I'm trying to grab a region (or tile) from the image to construct the map. I created this function below and call it with grabRegion(16, 16, 16, 16, tset, tile);, then blit the tile onto the map's surface. Problem is, whatever value I set to grabRegion's X and Y, I keep getting the top-leftmost tile, which has the coordinate of (0,0).

What could be wrong in the function I made?!?

Code: [Select]
void grabRegion(int x, int y, unsigned int w, unsigned int h, SDL_Surface* source, SDL_Surface* dest)
{
SDL_Rect coordsD;
coordsD.x = 0;
coordsD.y = 0;
coordsD.w = w;
coordsD.h = h;

SDL_Rect coords;
coords.x = x;
coords.y = y;
coords.w = w;
coords.h = h;

SDL_BlitSurface(source, &coords, dest, &coordsD);
}

~creek23
« Last Edit: June 13, 2011, 02:25:52 am by creek23 »

 

Post a new topic