package holo.bolt.render;

import holo.bolt.world.map.tile.InteractableTile;

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 RenderInteractableTile extends Render
{
	public Image texture1;
	public Image texture2;
	public InteractableTile tile;
	
	public RenderInteractableTile(InteractableTile tile)
	{
		this.tile = tile;
		try
		{
			texture1 = new Image(tile.textureLoc());
			texture2 = new Image(tile.textureLoc2());
		} catch (SlickException e)
		{
			e.printStackTrace();
		}
	}
	
	@Override
	public int[] getLoc()
	{
		int[] loc = new int[2];
		loc[0] = (int) StrictMath.floor(tile.pos[0]);
		loc[1] = (int) StrictMath.floor(tile.pos[1]);
		return loc;
	}

	@Override
	public Image getTexture()
	{
		return tile.used() < tile.uses() ? texture1 : texture2;
	}

	@Override
	public void doDraw(GameContainer gc, StateBasedGame game, Graphics g, int[] cameraPos)
	{
		int[] pos = this.getLoc();
		this.getTexture().draw(pos[0], pos[1]);
	}

}