Posted 24 August 2012 - 10:03 AM
Figure out which tile column is the first/last one on the screen and same for tile rows, then only loop across those. You can do this by comparing your tile's positions (top-left corner known from pos and width/height known from TILE_SIZE, which gives you the bottom-left corner) with the bounds of your window. Compare coordinates to do this, e.g. go over a tile row, and go "is the x coordinate less than zero, yes, keep going... yes, etc... ah, this one is more than zero, so this is the first tile in each row to be shown on the screen!" and so forth. You can actually also calculate quickly which tiles are the "boundary tiles" with a formula if your tiles are all the same size, but it's best you try and do it the explicit way first so you don't get confused.
Does it make sense?