}
}
}
private void paintThingsAndCharacters(Graphics g) {
RealmMap realmMap = gameState.getRealmMap();
int numRows = realmMap.getNumRows();
int numCols = realmMap.getNumCols();
int playerRow = gameState.getPlayerRow();
int playerCol = gameState.getPlayerCol();
int minI = playerRow - SIGHT_RADIUS;
int maxI = playerRow + SIGHT_RADIUS;
int minJ = playerCol - SIGHT_RADIUS;
int maxJ = playerCol + SIGHT_RADIUS;
for (int i = minI; i <= maxI; i++) {
int rowIndex = (numRows + i) % numRows;
int baseY = (i - minI) * TILE_HEIGHT;
for (int j = minJ; j <= maxJ; j++) {
int colIndex = (numCols + j) % numCols;
Tile tile = realmMap.getTile(rowIndex, colIndex);
int x = (j - minJ) * TILE_WIDTH;
int y = baseY - 65 + tile.getHeight();
// Paint thing (if we haven't already)
Thing thing = realmMap.getThing(rowIndex, colIndex);
if (thing != null && !thing.isOccludedByTerrain()) {
g.drawImage(thing.getSprite(), x, y, null);
}
// Paint character
GameCharacter character = realmMap.getCharacter(rowIndex, colIndex);
if (character != null) {
if (thing != null) { y += thing.getYOffset(); }
g.drawImage(character.getSprite(), x, y, null);
}
}