public void render() { Graphics g = screen.getGraphics(); // Drawing Things! sky.render(g); level.render( g, (int) sX, (int) sY, (pixel.width / Tile.tileSize) + 2, (pixel.height / Tile.tileSize) + 2); character.render(g); inventory.render(g); health.render(g); for (int i = 0; i < mob.toArray().length; i++) { mob.get(i).render(g); } g = getGraphics(); g.drawImage(screen, 0, 0, size.width, size.height, 0, 0, pixel.width, pixel.height, null); g.dispose(); }
@Override public void renderGameLoop(Graphics2D g) { // TODO Auto-generated method stub super.renderGameLoop(g); Point levelRenderOffset = new Point( (int) Math.round((this.getCanvasWidth() / 16) * 0.5), (int) Math.round((this.getCanvasHeight() / 16) * 0.5)); level.highlightTile = new Point(Math.round(player.origin.x), Math.round(player.origin.y)); level.render(g, player.origin.x - levelRenderOffset.x, player.origin.y - levelRenderOffset.y); for (Projectile p : projectiles) { Point2f renderPoint = new Point2f( (p.origin.x - player.origin.x) * 16 - levelRenderOffset.x + 8, (p.origin.y - player.origin.y) * 16 - levelRenderOffset.y + 8); g.drawImage( p.getImage(), (this.getCanvasWidth() / 2) + Math.round(renderPoint.x), (this.getCanvasHeight() / 2) + Math.round(renderPoint.y), null); } player.render(g, (this.getCanvasWidth() / 2) - 8, (this.getCanvasHeight() / 2)); for (MobAI mob : mobs) { Point2f renderPoint = new Point2f( (mob.origin.x - player.origin.x) * 16 - levelRenderOffset.x, (mob.origin.y - player.origin.y) * 16 - levelRenderOffset.y + 8); mob.render( g, (this.getCanvasWidth() / 2) + Math.round(renderPoint.x), (this.getCanvasHeight() / 2) + Math.round(renderPoint.y)); if (mob.health < mob.maxHealth) drawHealth( g, mob.health / (float) mob.maxHealth, (this.getCanvasWidth() / 2) + Math.round(renderPoint.x), (this.getCanvasHeight() / 2) + Math.round(renderPoint.y)); } }
public void render() { BufferStrategy bs = this.getBufferStrategy(); if (bs == null) { createBufferStrategy(3); return; } // --- a paint brush Graphics g = bs.getDrawGraphics(); // RENDER HERE g.fillRect(0, 0, WIDTH * SCALE, HEIGHT * SCALE); l1.render(g); player.render(g); // END RENDER g.dispose(); bs.show(); }
public void draw(SpriteBatch batch) { level.render(); for (GameObject obj : objs.getObjects()) { obj.draw(batch); } }
public void render(Graphics g) { g.setColor(Color.WHITE); g.fillRect(0, 0, 4000, 3000); level.render(g); }