package holo.bolt.render;

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

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 TileRender extends Render
{
	public Image texture;
	public Tile tile;
	
	public TileRender(Tile tile)
	{
		this.tile = tile;
		try
		{
			texture = new Image(tile.textureLoc());
		} 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 texture;
	}

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

}
