Package puppyeyes.engine.Actors

Source Code of puppyeyes.engine.Actors.Draw

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package puppyeyes.engine.Actors;

import java.awt.Graphics2D;
import puppyeyes.engine.Actor;
import puppyeyes.engine.Animation;
import puppyeyes.engine.GameWindow;
import puppyeyes.engine.Settings.GameSettings;
import puppyeyes.engine.Sprite;

/**
*
* @author majora
*/
public class Draw {
    private boolean visible = false;
    private Animation animation = new Animation();
    private int layer = 0;
   
   
   
    private Actor parent;
   
    public Draw(Actor parent) {
        this.parent = parent;
    }
   
   
    public void setVisible(boolean value) { visible = value; }
    public boolean isVisible() { return visible; }
   
   
    public void setAnimation(Animation animation) { this.animation = animation; }
    public Animation getAnimation() { return animation; }
    public int countFrames() { return animation.size(); }
    public double getCurrentFrame() { return animation.currentFramePosition(); }
    public void setFrame(int frame) { animation.setFrame(frame); }
    public void addFrame(String location) { addFrame(new Sprite(location)); }
    /**
     * Adds a new sprite to the actor
     * @param sprite the sprite to add to the actor.
     */
    public void addFrame(Sprite sprite) { animation.addFrame(sprite); }
   
   
    public void setLayer(int layer) { this.layer = layer; }
    public int getLayer() { return layer; }
    public void moveLayerUp() { if ( layer!=GameWindow.getLevel().countLayers()) { layer++; } }
    public void moveLayerDown() { if (layer!=0) { layer--; } }
   
    public void moveToTopLayer() { setLayer(GameWindow.getLevel().countLayers()); }
    public void moveToBottomLayer() { setLayer(0); }
   
    public int getWidth() { return animation.getWidth(); }
    public int getHeight() { return animation.getHeight(); }
   
    public int getHalfWidth() { return animation.getWidth()/2; }
    public int getHalfHeight() { return animation.getHeight()/2; }
   
   
    public void draw(Graphics2D graphics, int x, int y) {
        if (isVisible() && animation.size()!=0) {
           
            //Rotation commands
            if (parent.motion.getRotation()==true) {
                graphics.rotate(parent.position.getDirection());
            }
           
            animation.drawAnimation(graphics, (int) parent.position.getX() + x, (int) parent.position.getY() + y);
        }
    }
   
   
}
TOP

Related Classes of puppyeyes.engine.Actors.Draw

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.