Original Post
The problem is it doesnt work. I have a scrolling function Scroll(int x, int y); The 2 variables are Upperleft(the tiles thats the upper left tile to be rendered) and scrollpix(upperleft pixel within the tile). it works perfectly when i scroll in positive directions but i cant seem to reverse it to work right in negative directions. for positive directions the code is....
if(x > 0)
{
Mapinfo->UpperLeft.x += (Mapinfo->ScrollPix.x + x)/Mapinfo->TileSize.x;
Mapinfo->ScrollPix.x = (Mapinfo->ScrollPix.x + x)%Mapinfo->TileSize.x;
}
my idea for the negative directions was
if( x < 0)
upperleft.x += (scroll.x + x)/tilesize.x;
int remainder = (scroll.x + x)%tilesize.x;
if(ramainder == 0)
{
scroll.x = 0;
}
else
{
upperleft.x--;
scroll.x = tilesize.x - remainder;
}
}
but this just doesnt work. any ideas?