package zero1hd.polyjet.entity;

import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.NinePatch;

import zero1hd.polyjet.Polyjet;

public class BarBeat extends Entity {
	NinePatch texture;
	float rate;
	
	public void initiate(float size, float rate, float spawnX, float spawnY, NinePatch texture) {
		hitpoints = 1;
		this.rate = rate;
		setPosition(spawnX, spawnY);
		this.texture = texture;
	}
	
	@Override
	public void act(float delta) {
		if (getY() + getHeight() < Polyjet.GAME_AREA_HEIGHT) {
			hitpoints = 0;
		}
		moveBy(0, -rate*delta);
		super.act(delta);
	}
	
	@Override
	public void draw(Batch batch, float parentAlpha) {
		texture.draw(batch, getX(), getY(), getWidth(), getHeight());
		super.draw(batch, parentAlpha);
	}
	
	@Override
	public int getDamageDealt() {
		return 10;
	}
	
	@Override
	public void reset() {
		texture = null;
		super.reset();
	}
}
