import java.awt.*;
import java.awt.image.*;


/*
 * This was decided to be implemented opposite of what perhaps is
 * convention and is a rather light class.
 * most of the crucial info such as position and how to draw
 * is taken care of in the Playfield class since this makes
 * more sense to me, in terms of association.
 *
 * Therefore, this class is little more than an image
 *
 */
public class Sprite extends Raster
{
    public static final int REGULAR1 = 0;
    public static final int REGULAR2 = 1;
    public static final int UP = 2;
    public static final int DEAD = 3;
    public static final int NON = 4;
    public static final int DEAD2 = 5;
    
    
    // state of the sprite
    int state = REGULAR1;
    
    public Sprite(Image img)
    {
        super(img);
    }

    /**
     * boolean returns whether a specific x,y coord is transparent
     */
    public boolean isTrans(int x, int y)
    {
        if(x < 0 || y < 0 || x > width || y > height)
        {
            return false;
        }
        if(getPixel(x, y) >> 24 == 0)
        {
            return true;
        }
        return false;
    }
    
    // returns what current state is
    public int getState()
    {
        return state;
    }
    
    //cycles states, returns what state is changed
    public int nextState()
    {
        int old = state++;
        state %= 4;
        return old;
    }
    
    //set's state
    public int setState(int st)
    {
        int old = state;
        state = st;
        return old;
    }
}