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?!?
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