int y = playerPosition.y;
int x = playerPosition.x;
for (int i = y - 5; i < y + 5; i++)
for (int j = y - 5; j < y + 5; j++)
{
switch (MainMap[j])
{
case 0:
zeros.setPosition({ j * 20.f, i * 20.f });
window.draw(zeros);
break;
case 1:
ones.setPosition({ j * 20.f, i * 20.f });
window.draw(ones);
break;
case 2:
twos.setPosition({ j * 20.f, i * 20.f });
window.draw(twos);
break;
}
}
player.setPosition({ playerPosition.x * 20.f, playerPosition.y * 20.f });
window.draw(player);
Would this be a correct way to approach this? My "Map" has 5 "walls" on each side (top, bottom, left, right) so that there will always be a drawing on the left,right,top,bottom regardless of where the player should be.
However, when I run this with the rest of my code, I get a small map that isn't centered around the player. I'm trying to figure out how to get the player centered all the time so that the map essentially follows the player. Does that make sense?
As I was saying, I get a strange map that has some pieces appearing and disappearing at different points where the player ball just moves around wherever with some strange limitations.