package holo.bolt.render;

import holo.bolt.BoltMain;

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

public abstract class Render
{
	public void draw(GameContainer gc, StateBasedGame game, Graphics g, int[] cameraPos)
	{
		if (onScreen(this.getTexture(), this.getLoc(), cameraPos, BoltMain.ScreenHeight/2, BoltMain.ScreenWidth/2))
		{
			this.doDraw(gc, game, g, cameraPos);
		}
	}
	
	public boolean onScreen(Image t, int[] pos, int[] cameraPos, int sX, int sY)
	{
		int minX = pos[0];
		int maxX = pos[0] + t.getWidth();
		int minY = pos[1];
		int maxY = pos[1] + t.getHeight();
		
		if (maxX > cameraPos[0] - sX || minX < cameraPos[0] + sX || minY < cameraPos[1] + sY || maxY > cameraPos[1] - sY)
			return true;
		return false;
	}
	
	public void rotateImage(double theta)
	{
		getTexture().rotate((float) theta);
	}
	
	public void setImageRotation(double theta)
	{
		getTexture().setRotation((float) theta);
	}
	
	public abstract void doDraw(GameContainer gc, StateBasedGame game, Graphics g, int[] cameraPos);
	
	public abstract int[] getLoc();
	
	public abstract Image getTexture();
}