
public class Piston extends Entity {
	
//	boolean sideBlock = false;
	
	/** The animation frames */
	private Sprite[] animation = new Sprite[6];
	
	/** The time since the last frame change took place */
	private long lastFrameChange;
	/** The frame duration in milliseconds, i.e. how long any given frame of animation lasts */
	private long frameDuration = 250;
	/** The current frame of animation being displayed */
	private int frameNumber = 0;
	
	public boolean up = true;
	
	public Piston(Game game, int x, int y) {
		super("sprites/mech/p1.png", x, y, 10, 10, 70, 203, true); // "sprites/block.png"
		
		animation[0] = ResourceFactory.get().getSprite("sprites/mech/p1.png");
		animation[1] = ResourceFactory.get().getSprite("sprites/mech/p2.png");
		animation[2] = ResourceFactory.get().getSprite("sprites/mech/p3.png");
		animation[3] = ResourceFactory.get().getSprite("sprites/mech/p4.png");
		animation[4] = ResourceFactory.get().getSprite("sprites/mech/p5.png");
		animation[5] = ResourceFactory.get().getSprite("sprites/mech/p6.png");
	}

	public void collidedWith(Entity other) {
		
	}
	
	public void move(long delta) {
		lastFrameChange += delta;
		
		if (up) {
			if (frameNumber > 0) {
				if (lastFrameChange > frameDuration) {
					lastFrameChange = 0;
					// update the frame
					frameNumber--;
					sprite = animation[frameNumber];
				}
			} else {
				setBounds((int) x + 10, (int) y + 0, 70, 213);
			}
		} else { // Down
			if (frameNumber < 5) {
				if (lastFrameChange > frameDuration) {
					lastFrameChange = 0;
					// update the frame
					frameNumber++;
					sprite = animation[frameNumber];
				}
			} else {
				setBounds((int) x + 10, (int) y + 180, 70, 33);
			}
		}
	}
}
