Skip to main content
GameDev.net gamedev.net
🔒 Locked

Resizing my tilemap

Started by Essentric Mar 15, 2011 at 9:26 PM 1 replies 1.3k views
Original Post
Essentric
Essentric
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;
}
Wooh
Wooh
Can't see anything wrong with your code. The problem must elsewhere.
Essentric
Essentric
I found the problem. I made a mistake in the dialog proc...



case IDOK:
{
tilemap::tm_width = ctrl_num(hDlg, IDC_EDIT1);
tilemap::tm_height = ctrl_num(hDlg, IDC_EDIT2);
tilemap::resize(tilemap::tm_width, tilemap::tm_height);

EndDialog(hDlg, 0);
return TRUE;
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.