1
Graphics / Concatenate tiles to an image
« on: December 16, 2010, 04:42:43 pm »
I tried that in all ways, but doesn't work.
I want to copy the vTiles[0] image to i_map multiple times, so draw_x and draw_y are the current position, where the tile belongs to the map.
But i_map doesn't change.
By the way, it would be cool, if someone could have a look at my algorithm to create the map and tell if it's okay or total bullcrap.
But main problem is the Copy function. It just does not want to work. I'm doing something wrong, but have no idea where the issue hides.
Code: [Select]
i_map.Copy(vTiles[0], draw_x, draw_y, sf::IntRect(0, 0, 64, 32), true);
I want to copy the vTiles[0] image to i_map multiple times, so draw_x and draw_y are the current position, where the tile belongs to the map.
But i_map doesn't change.
By the way, it would be cool, if someone could have a look at my algorithm to create the map and tell if it's okay or total bullcrap.
Code: [Select]
void CMapManager::LoadMap(sf::View* pView, float time)
{
int add_x, draw_x, draw_y;
sf::FloatRect offset = pView->GetRect();
int start_x = offset.Left / TILE_W + 1;
int start_y = offset.Top / TILE_H + 1;
int end_x = (WINDOW_W / TILE_W) + start_x + 2;
int end_y = (WINDOW_H / (TILE_H / 2)) + start_y + 4;
if(start_x < 1) {
start_x = 1;
pView->Move(SCROLLSPEED * time, 0);
}
if(start_y < 1) {
start_y = 1;
pView->Move(0, SCROLLSPEED * time);
}
if(end_x > MAP_W - 1) {
end_x = MAP_W - 1;
pView->Move(-SCROLLSPEED * time, 0);
}
if(end_y > MAP_H - 1) {
end_y = MAP_H - 1;
pView->Move(0, -SCROLLSPEED * time);
}
int posY = -(static_cast<int>(offset.Top) % 16) - 16;
for(int y = start_y; y < end_y; y++) {
int posX = -(static_cast<int>(offset.Left) % 64) - 64;
for(int x = start_x; x < end_x; x++) {
if(y % 2 == 0)
add_x = TILE_W / 2;
else
add_x = 0;
draw_x = posX + add_x + offset.Left;
draw_y = posY + offset.Top;
posX += 64;
i_map.Copy(vTiles[0], draw_x, draw_y, sf::IntRect(0, 0, 64, 32), true);
}
posY += 16;
}
s_Tile.SetImage(i_map);
}
But main problem is the Copy function. It just does not want to work. I'm doing something wrong, but have no idea where the issue hides.