//SpritePerso
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#include <GL/gl.h>
#include <GL/glu.h>

#include <stdio.h>
#include <stdlib.h>
#include <stdexcept>
#include <vector>

using namespace std;

#include "SpritePerso.h"

#include "Moteur.h"

CSpritePerso::CSpritePerso()
{
	//Constructeur de la clase CSpritePerso ...
}

CSpritePerso::~CSpritePerso()
{
	//Et son petit destructeur!
}


void CSpritePerso::LoadTexPerso(const char *Name)
{

	char temp[100];
	int ii;

	for(int i = 0; i < 10; ++i)
	{
		ii = i + 1;
		sprintf(temp, "./Images/Personnages/%s/immobile%d.png", Name, ii);		
		TexImmobile[i] = Moteur.NouvelleTexture(temp);
	}


	for(int i = 0; i < 10; ++i)
	{
		ii = i +1;
		sprintf(temp, "./Images/Personnages/%s/marche%d.png", Name, ii);	
		TexMarche[i] = Moteur.NouvelleTexture(temp);
	}

	for(int i = 0; i < 10; ++i)
	{
		ii = i +1;
		sprintf(temp, "./Images/Personnages/%s/saut%d.png", Name, ii);	
		TexSaut[i] = Moteur.NouvelleTexture(temp);
	}
	
	for(int i = 0; i < 10; ++i)
	{
		ii = i +1;
		sprintf(temp, "./Images/Personnages/%s/accrocher%d.png", Name, ii);	
		TexAccrocher[i] = Moteur.NouvelleTexture(temp);
	}
	
	
}

void CSpritePerso::AffichePerso(int Etat, char nbAnim, int PosX, int PosY, int TailleX, int TailleY, bool Halo, GLubyte Red, GLubyte Green, GLubyte Blue, GLubyte Alpha, int offset, GLubyte HaloRed, GLubyte HaloGreen, GLubyte HaloBlue)
{
	int tex;
	
	switch (Etat)
	{
		case IMMOBILE:
			tex = TexImmobile[nbAnim];
			break;

		case MARCHE:
			tex = TexMarche[nbAnim];
			break;
			
		case SAUT:
			tex = TexSaut[nbAnim];
			break;
			
		case ACCROCHER:
			tex = TexAccrocher[nbAnim];
			break;
	}
	
	if(Halo) Moteur.AfficheTextureHalo(tex, PosX, PosY, TailleX, TailleY, Red, Green, Blue, offset, HaloRed, HaloGreen, HaloBlue, Alpha);
	else Moteur.AfficheTexture(tex, PosX, PosY, TailleX, TailleY, Red, Green, Blue, Alpha);
	
}
