I'm trying to load a tile map from a text file, but when I render it on the screen, it goes sideways, so the left block goes to the right of the screen, the right one goes to the left. am I doing anything wrong here please help.
void blocks::genBlocks(blocks getBlocks) {
ifstream mapFile("Data/block_map.txt");
if (mapFile.is_open()) {
while (!mapFile.eof()) {
blockData = 0;
mapFile >> blockData;
if (mapFile.peek() == '\n') {
loadCounterY++;
loadCounterX = 1;
}
else {
loadCounterX++;
}
if (blockData == 1) {
blockRect.setPosition(loadCounterX * 110, loadCounterY * 40);
blocksVec.push_back(getBlocks);
}
}
}
}
void blocks::renderBlocks(RenderTarget &window) {
for (int i = 0; i < blocksVec.size(); i++) {
window.draw(blocksVec[i].blockRect);
}
}
it should look like this: (1 means draw something, 0 means draw nothing)
0 0 0 0 0 1
0 0 0 0 0 1
0 0 0 0 0 1
0 0 0 0 0 1
0 0 0 0 0 1
0 0 0 0 0 1
but turns out it looks like this:
1 0 0 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0