package edu.wisc.cs.games10.chrononaut;

import processing.core.*;

public class Creature extends SimpleMovable {

	PImage creatureImg;
	private BodyPart bodypart;
	Era era;
	boolean dead;
	
	public Creature(Vector2D _loc, Era e, String path, PApplet canvas, BodyPart bp) {
		creatureImg = canvas.loadImage("creatures/" + path + "/alive.png");
		dead = false;
		loc = _loc.copy();
		bodypart = bp;
		era = e;
		
		tileHeight = creatureImg.height / 32.0f;
		tileWidth = creatureImg.width / 32.0f;
	}
	
	public Era getEra() {
		return era;
	}

	public BodyPart getBodyPart() {
		return bodypart;
	}
	
	public void update(float time) {
		// ai and animation can go here
	}
	
	public void render(PApplet canvas) {
		canvas.pushMatrix();
		canvas.translate(loc.x, loc.y);
		canvas.beginShape(PConstants.QUADS);

		canvas.texture(creatureImg);
			canvas.vertex(0, 0, 0, 0);
			canvas.vertex(tileWidth, 0, creatureImg.width, 0);
			canvas.vertex(tileWidth, tileHeight, creatureImg.width, creatureImg.height);
			canvas.vertex(0, tileHeight, 0, creatureImg.height);
		canvas.endShape();
		
		canvas.popMatrix();
	}
	
	public void kill() {
		dead = true;
	}
}