#ifndef SPRITE_H
#define SPRITE_H
#include "SDL.h"
#include "SDL_opengl.h"
#include <string>
#include <iostream>
#include <map>

typedef enum { LEFT = -1, RIGHT = 1 } xDirection;
typedef enum { UP = -1, MIDDLE = 0, DOWN = 1 } yDirection;

class Sprite
{
public:
	Sprite(){;}
	/*
	filename of a png to be the sprite.
	*/
	Sprite(std::string filename);
	Sprite(std::string filename, int width, int height);
	Sprite(Sprite *sprite);
	/*
	level coordinates of the location to draw the sprite 
	(hopefully passed to it by the object whose sprite it is)
	*/
	virtual Sprite* instance();
	virtual void draw(int x, int y, bool origin = LEVEL);

	virtual void clean(){;};

	// WARNING: this is too specific FIXME (probably not)
	virtual void drawBox(int x, int y, SDL_Rect drawBox);

	int width(){return _rect.w;}
	int height(){return _rect.h;}
	void setHeight( int h ){ _rect.h = h; };
	void setWidth( int w ){ _rect.w = w; };
	virtual SDL_Rect rect(){return _rect;}
	virtual SDL_Rect box(){return _box;}
	void setRect( SDL_Rect r ){ _rect = r; };
	void setBox( SDL_Rect b ){ _box = b; };
	std::string filename() {return _filename;}
	int getTexture() {return _hTexture;}

	virtual void update(){;}
	virtual void reset(){;}

	static Sprite* loadSprite( std::string filename );
	static Sprite* loadText( std::string filename );
	static void cleanSprites();


	xDirection getDirection() {return _direction;}
	void setDirection(xDirection direction) {_direction = direction;}

	//static const bool LEFT = true;
	//static const bool RIGHT = false;
	static const bool LEVEL = true;
	static const bool SCREEN = false;

protected:

	static std::map<std::string,Sprite *> SPRITES;


	std::string _filename;
	unsigned int _hTexture;
	GLfloat _coords[4];
	SDL_Rect _rect;
	SDL_Rect _box;
	xDirection _direction;
};

#endif