Original Post
Playing around with a smooth scrolling tile engine and having a bit of a round with the bounds checking. I got something that works but it doesn't seem like it would be right. I checked it with a couple different sized maps and it stopped correctly just thinking there has to be a better way. I've got the minus two because I need the one extra for the partial tiles then the other is because OpenGL likes pop in a line of tiles so I just render the extra off screen and let it scroll in.
if (keys[VK_DOWN]) {
keys[VK_DOWN]=FALSE;
if (map_yoffset < (map_height - (display_y-2)) * TILE_HEIGHT
- (TILE_HEIGHT/2) + MOVE_SIZE)
map_yoffset += MOVE_SIZE;
}
if (keys[VK_RIGHT]) {
keys[VK_RIGHT]=FALSE;
if (map_xoffset < (map_width - (display_x-2)) * TILE_WIDTH - (TILE_WIDTH/2))
map_xoffset += MOVE_SIZE;
}