@Override public void render(Graphics g) { if (map.needsToBeRendered() || reRender) { Graphics g1 = cachedViewport.getGraphics(); // Draw a black background g1.setColor(Color.BLACK); g1.fillRect(0, 0, viewportWidth, viewportHeight); // Get the avatar's location. This location will be shown in the center of the viewport. Point logicalPoint = avatar.getLocation(); Point pixelPoint = new Point(viewportWidth / 2, viewportHeight / 2); // Create a 2D graphcis obj Graphics2D g2 = (Graphics2D) g1.create(); // Clear the existing status bar locations this.entityLocationTuples.clear(); breadthFirstRender(logicalPoint, pixelPoint, g2); map.setNeedsToBeRendered(false); reRender = false; g1.dispose(); } // draws the viewport g.drawImage(cachedViewport, 0, 0, viewportWidth, viewportHeight, getDisplay()); for (EntityLocationTuple et : this.entityLocationTuples) { drawEntityHealthBar(g, et); } if (displayDebugInformation) { g.setColor(Color.WHITE); g.drawString( avatar.getLocation().toString(), viewportWidth - g.getFontMetrics().stringWidth(avatar.getLocation().toString()) - 50, 25); } }