Ok so this is more of a general help question versis sfml based but please hear me out because i couldnt find any solution for this online
In my game, the maps / movement are supposed to work like in pokemon where your character stays centered on the screen and the map moves around you, which is handeled by a camera manager holding which hold a cell which then hold the tiles and any object on the screen which needs to be moved when you move. Although that isnt the exact problem at the moment. Because of how i want the game to be set up the map consists of 64x64 tiles which are linked together by a database and loaded into the game. Fine so far, but here is the problem. When im doing the initial load into my game which takes a double array of of tiles and puts them into the active camera cells i get an access read violation when i use a counter within the loop.. Let me show you instead of just sayinf my problem
int xCnt = 0, yCnt = 0;
for (int coordX = (thisPlayer.regionX - 5); coordX < (thisPlayer.regionX + 6); coordX++)
{
for (int coordY = (thisPlayer.regionY - 4); coordY < (thisPlayer.regionY + 5); coordY++)
{
theCam.activeCells[xCnt][yCnt].setLocalX(xCnt);
theCam.activeCells[xCnt][yCnt].setLocalY(yCnt);
if (!mnger.LoadTile(thisPlayer.regionID, coordX, coordY, theCam.activeCells[xCnt][yCnt].mTile))
{
return false;
}
if (theCam.activeCells[xCnt][yCnt].mTile.tileType == 1)
{
theCam.activeCells[xCnt][yCnt].mTile.tileTexture = grassBGImg;
}
else if (theCam.activeCells[xCnt][yCnt].mTile.tileType == 2)
{
theCam.activeCells[xCnt][yCnt].mTile.tileTexture = dirtBGImg;
}
else
{
theCam.activeCells[xCnt][yCnt].mTile.tileTexture = grassBGImg;
}
theCam.activeCells[xCnt][yCnt].mTile.tileSprite.setTexture(theCam.activeCells[xCnt][yCnt].mTile.tileTexture);
theCam.activeCells[xCnt][yCnt].mTile.tileSprite.setPosition(theCam.activeCells[xCnt][yCnt].getXPos(), theCam.activeCells[xCnt][yCnt].getYPos());
yCnt++;
}
xCnt++;
}
^ is the piece of code which is giving me the access writing violation, and the actual line which is giving me the error is xCnt++;
I cant understand for the life of me why this counter is breaking my game, please help