Original Post
Hi, can anyone see what is wrong with my resize function, I've been tweaking around with it since yesturday and can't seem to make it copy the tiles correctly. Which is strange because I've wrote a working resize function in the past. Maybe it's something silly I'm not seeing...
void tilemap::resize(const int width, const int height)
{
DWORD size = width * height;
BYTE* new_map = new BYTE[size];
memset((void*)new_map, 0, size);
const int copy_width = tm_width < width ? tm_width : width;
const int copy_height = tm_height < height ? tm_height : height;
for(int y=0; y < copy_height; ++y)
memcpy((void*)&new_map[y * width], (void*)&tiles[y * tm_width], copy_width);
delete[] tiles;
tm_width = width;
tm_height = height;
tiles = new_map;
}