I have an two arrays of a Tile class I made for a Map Editor I'm making. One contains data on the tiles that can be seen and one contains data on tiles on the whole map. Now what I want to do is change the Graphic variable in one tile to something different. But what it does is it changes every tiles in that arrays Graphic variable to the new one. This happens in both arrays. I cannot figure out why.
I am using this code to change the Maps Graphic:
LoAMap.Tiles[currGlobalTileX][currGlobalTileY].Graphic = "data/imgs/stone.jpg";
LoAMap.Tiles[currGlobalTileX][currGlobalTileY].foregroundGFX = "data/imgs/rock.gif";
Then this code to update the visible tiles array:
//If the map has been made
if(mapMade)
{
if(mapChanged)
{
for(int i = 0; i < 16; i++)
{
for(int y = 0; y < 16; y++)
{
int globalTileX = ((centreTileX - i) + centreTileX) + 1;
int globalTileY = ((centreTileY - y) + centreTileY) + 1;
tmpTile = LoAMap.Tiles[globalTileX][globalTileY];
Tiles[y] = tmpTile;
}
}
mapChanged = false;
}
}
Please help this is very frustrating! BTW Tiles[][] is the visible Tiles array and LoAMap.Tiles[][] is the map tiles array.
It's not a bug... it's a feature!