public void draw(Graphics g, Point position, int width, int height) { // Destination image coordinates int dx1 = (int) position.getX(); int dy1 = (int) position.getY(); int dx2 = dx1 + renderingSize; int dy2 = dy1 + renderingSize; // Source image coordinates int sx1 = spriteNumber * width; int sy1 = currentRow * height; int sx2 = sx1 + width; int sy2 = sy1 + height; g.drawImage(image.getImage(), dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null); }
@Override public void draw(Graphics g, Point position) { // Destination image coordinates int dx1 = (int) position.getX(); int dy1 = (int) position.getY(); int dx2 = dx1 + renderingSize; int dy2 = dy1 + renderingSize; // Source image coordinates int sx1 = spriteNumber * spriteSize + decalage * spriteNumber; int sy1 = currentRow * spriteSize + decalage * currentRow; int sx2 = sx1 + spriteSize; int sy2 = sy1 + spriteSize; g.drawImage(image.getImage(), dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null); }
public SpriteManagerDash(DrawableImage image, int renderingSize, int maxSpriteNumber) { this.renderingSize = renderingSize; this.image = image; this.maxSpriteNumber = maxSpriteNumber; this.spriteSize = image.getWidth() / maxSpriteNumber; }