/** Paints the sprite */ @Override public void paint(Graphics g) { Graphics g2 = dbImage.getGraphics(); g2.setColor(new Color(25, 155, 105)); g2.fillRect(0, 0, dbImage.getWidth(), dbImage.getHeight()); Layer l; for (int i = 0; i < parent.layers.size(); i++) { l = parent.layers.get(i); if (dir == -1) for (int y = 1; y <= Map.DIRECTIONS; y++) { if (step == -1) for (int x = 1; x <= NPC.WALKCYCLE; x++) { l.setFrame(x, y); l.setX((x - 1) * width); l.setY((y - 1) * height); l.paint(g2); } else { l.setFrame(step, y); l.setX(0); l.setY((y - 1) * height); l.paint(g2); } } else if (step == -1) for (int x = 1; x <= NPC.WALKCYCLE; x++) { l.setFrame(x, dir); l.setX((x - 1) * width); l.setY(0); l.paint(g2); } else { l.setFrame(step, dir); l.setX(0); l.setY(0); l.paint(g2); } } g.drawImage(dbImage, 0, 0, dbImage.getWidth() * 2, dbImage.getHeight() * 2, null); }
public BufferedImage save() { BufferedImage b; b = new BufferedImage( width * NPC.WALKCYCLE, height * Map.DIRECTIONS, BufferedImage.TYPE_4BYTE_ABGR); Graphics g2 = b.getGraphics(); Layer l; for (int i = 0; i < parent.layers.size(); i++) { l = parent.layers.get(i); for (int y = 1; y <= Map.DIRECTIONS; y++) for (int x = 1; x <= NPC.WALKCYCLE; x++) { l.setFrame(x, y); l.setX((x - 1) * width); l.setY((y - 1) * height); l.paint(g2); } l.paint(g2); } repaint(); return b; }