package holo.bolt.render;

import holo.bolt.entity.EntityPlayer;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;

public class RenderPlayer extends RenderEntity
{
	EntityPlayer entity;
	Image texture;
	Image texture2;
	
	public RenderPlayer(EntityPlayer ent)
	{
		super(ent);
		entity = ent;
		
		try
		{
			texture = new Image(entity.getTextureLoc());
			texture2 = new Image(entity.getTextureLoc2());
		} catch (SlickException e)
		{
			e.printStackTrace();
		}
	}
	
	@Override
	public void doDraw(GameContainer gc, StateBasedGame game, Graphics g,
			int[] cameraPos)
	{
		Image i = this.getTexture();
		int[] pos = this.getLoc();
		i.draw(pos[0], pos[1]);
	}

	@Override
	public int[] getLoc()
	{
		return new int[]{(int)entity.pos[0], (int)entity.pos[1]};
	}

	@Override
	public void rotateImage(double theta)
	{
		texture.rotate((float) theta);
		texture2.rotate((float) theta);
	}

	@Override
	public void setImageRotation(double theta)
	{
		texture.setRotation((float) theta);
		texture2.setRotation((float) theta);
	}

	@Override
	public Image getTexture()
	{
		return entity.hasBolt ? texture : texture2;
	}

}