public void render(Graphics2D g2) { //ENTRY POINT OF RENDERING ENGINE FROM BOARD PAINTCOMPONENT(g) //Repainting this.graphics = g2; camera.repaint(g2); for (int i = layersList.length - 1; i > -1; i--) { layersList[i].renderLayer(camera); } //int spriteNumber = 0; while (activeSpriteCompositeList.hasNext()) { ActiveGraphic graphic = activeSpriteCompositeList.get(); graphic.composite.draw(camera); //spriteNumber++; } // g2.setColor(Color.CYAN); // g2.drawString( "Rendering Engine: Sprites: "+ spriteNumber , 20, 300); //Overlays for (OverlayComposite overlay : visibleOverlayList) { overlay.paintOverlay(camera.getOverlayGraphics(), camera); } }
public ActiveGraphic addGraphicsCompositeToRenderer(GraphicComposite graphic) { try { ActiveGraphic newActiveGraphic = new ActiveGraphic(graphic); newActiveGraphic.listPosition = activeSpriteCompositeList.add(newActiveGraphic); return newActiveGraphic; } catch (ClassCastException exc) { System.err.println("Rendering Engine attempted to add spriteless entity."); return null; } }
public ActiveGraphic addGraphicsCompositeToRenderer(GraphicComposite graphic, int layer) { try { ActiveGraphic newActiveGraphic = new ActiveGraphic(graphic); layersList[layer].addGraphicToLayer(graphic); return newActiveGraphic; } catch (ClassCastException exc) { System.err.println("Rendering Engine attempted to add spriteless entity."); return null; } }
public void paintOverlay(Graphics2D g2, MovingCamera cam) { cam.setColor(Color.GREEN); g2.setColor(Color.GREEN); g2.setFont(contextFont); g2.drawString("SPRITE OVERLAY", 500, 30); g2.setFont(defaultFont); g2.drawString("Active Sprites: " + activeSpriteCompositeList.size(), 500, 45); while (activeSpriteCompositeList.hasNext()) { ActiveGraphic graphic = activeSpriteCompositeList.get(); Shape relativeShape = graphic.composite.getGraphicRelativeBounds(0); camera.drawShapeInWorld(relativeShape, graphic.composite.getOwnerEntity().getPosition()); } }