LandRow.java :  » Game » javadungeoncrawlerv01 » land » Java Open Source

Java Open Source » Game » javadungeoncrawlerv01 
javadungeoncrawlerv01 » land » LandRow.java
package land;

import interfaces.Visible;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import abstracts.Level;

public class LandRow implements Visible {
    private BufferedImage img = null;
    private Rectangle.Double pos = new Rectangle.Double();

    public LandRow(double x, double y, double width, double height, Level level) {
        pos.x = x;
        pos.y = y;
        pos.width = width;
        pos.height = height;
        // img = new BufferedImage((int) width, (int) height,
        // BufferedImage.TYPE_INT_ARGB);

        // This is SUPPOSEDLY a "better" way to create an image...
        img = level.getApplet().getGraphicsConfiguration()
                .createCompatibleImage((int) width, (int) height,
                        Transparency.TRANSLUCENT);
    }

    public Graphics getGraphics() {
        return img.getGraphics();
    }

    @Override
    public void draw(Graphics g) {
        g.drawImage(img, (int) pos.x, (int) pos.y - 16, null);
    }

    @Override
    public double getDepth() {
        return pos.y;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.