/** * Updates the whole map image. * * @param playerCoords Coordinates of the player. */ private void updateMapImage(Coord playerCoords) { currentScreen = new BufferedImage( mapLevel.getWidth() * ImageBank.FEATUREWIDTH, mapLevel.getHeight() * ImageBank.FEATUREHEIGHT, BufferedImage.TYPE_INT_ARGB); Graphics2D surface = currentScreen.createGraphics(); int mapHeight = ((mapLevel.getHeight() - 1) * ImageBank.FEATUREHEIGHT); surface.setColor(Color.GRAY); surface.fillRect(0, 0, currentScreen.getWidth(), currentScreen.getHeight()); for (byte x = 0; x < mapLevel.getWidth(); x++) { for (byte y = 0; y < mapLevel.getHeight(); y++) { if (mapLevel.getMapSquare(x, y).isVisited()) { surface.drawImage( createSquare(mapLevel.getMapSquare(x, y)), null, x * ImageBank.FEATUREWIDTH, mapHeight - (y * ImageBank.FEATUREHEIGHT)); } } } // draw player arrow. if (playerCoords.getZ() == mapLevel.getLevel()) { Polygon arrow = getArrow(playerCoords); surface.setColor(Color.RED); surface.fillPolygon(arrow); surface.setColor(Color.WHITE); surface.drawPolygon(arrow); } setPreferredSize( new Dimension( mapLevel.getWidth() * ImageBank.FEATUREWIDTH, mapLevel.getHeight() * ImageBank.FEATUREHEIGHT)); revalidate(); }
/** * Retrieves the depth of this map. * * @return byte */ public byte getLevel() { return mapLevel.getLevel(); }
/** * Updates another square and repaints. * * @param coords Coord to update. */ public void updateNonPlayerSquare(Coord coords) { if (coords.getZ() != mapLevel.getLevel()) return; // This square is not on this level... updateSquare(coords.getX(), coords.getY()); repaint(); }
/** * Update the square the player is based on the passed coordinates. Repaints * * @param coords Coord of player */ public void updatePlayerSquare(Coord coords) { if (coords.getZ() != mapLevel.getLevel()) return; // This square is not on this level... updateArrow(coords); repaint(); }