Esempio n. 1
0
 public void draw(Graphics2D g, int layer) {
   for (int row = rowOffset; row < rowOffset + numRowsToDraw; row++) {
     if (row >= numRows) break;
     for (int col = colOffset; col < colOffset + numColsToDraw; col++) {
       if (col >= numCols) break;
       if (mapList.get(layer - 1)[row][col] == null) continue;
       if (mapList.get(layer - 1)[row][col].getTile() == 0) continue;
       MapTile rc = mapList.get(layer - 1)[row][col];
       int r = rc.getTile() / numTilesAcross;
       int c = rc.getTile() % numTilesAcross;
       g.drawImage(
           tiles[r][c].getImage(), (int) x + col * tileSize, (int) y + row * tileSize, null);
     }
   }
 }
Esempio n. 2
0
 public int getType(int row, int col) {
   try {
     MapTile rc = mapList.get(0)[row][col];
     //			System.out.println(row + " " + col + " " + mapList.get(0)[row][col].getTile());
     int r = rc.getTile() / numTilesAcross;
     int c = rc.getTile() % numTilesAcross;
     return tiles[r][c].getType();
   } catch (ArrayIndexOutOfBoundsException e) {
     System.out.println(
         "Actual [row : columns]: "
             + numRows
             + ":"
             + numCols
             + " -  Referred: "
             + row
             + ":"
             + col);
     e.printStackTrace();
   }
   return 0;
 }