Original Post
I know this has been asked and answered a hundred times, but I can't seem to get it to work for me. I'm trying to implement a scrollable tilemap but when I move right, the map seems to repeat instead of move the character to the right edge of the screen as I get closer to the right edge of the tilemap. Here is my map-rendering code: Hero.mapy and Hero.mapx just keeps track of where the character is in relation to the entire map. For example if character starts at 0,0 and I move right, mapx becomes 1. If I move down mapy becomes 1. If I move back up, mapy becomes 0. Perhaps this is not the way I should be approaching the problem but this is what I gleaned from some posts and articles here on Gamedev. Can anyone suggest where I might be messing up? Thanks, Han
void drawMap()
{
for(int i=0;i<CAMERA_HEIGHT;i++)
{
for(int j=0;j<CAMERA_WIDTH;j++)
{
//drawIMG(surMap[j],(j * TILE_SIZE),(i * TILE_SIZE) + MAP_OFFSET);
drawIMG(surMap[i + Hero.mapy][j + Hero.mapx],(j * TILE_SIZE),(i * TILE_SIZE) + MAP_OFFSET);
}
}
}