
#include <oslib/oslib.h>


//declaration
OSL_OBJECT *zelda, *fumee, *zou, *bac ;
extern OSL_FONT *maFonte;


//define pour les annimations
#define ZELDA_HAUT 50*2
#define ZELDA_BAS 50*3
#define ZELDA_GAUCHE 50*1
#define ZELDA_DROITE 0

#define ZOU_HAUT 60*2
#define ZOU_BAS 60*3
#define ZOU_GAUCHE 60*1
#define ZOU_DROITE 0


void ToucheAnnimation();


void animation10()
{



	//chargement des sprites
	zelda = oslCreateSprite(oslLoadImageFile("media/zelda.png", OSL_IN_RAM, OSL_PF_5551),ZELDA_BAS, 3 ,50,50,12);
	fumee = oslCreateSprite(oslLoadImageFile("media/fume.png", OSL_IN_RAM, OSL_PF_5551),0, 4 ,76,72,30);
	zou = oslCreateSprite(oslLoadImageFile("media/zou.png", OSL_IN_RAM, OSL_PF_5551),ZOU_BAS, 3 ,56,60,15);
	bac = oslCreateSprite(oslLoadImageFile("media/bac.png", OSL_IN_RAM, OSL_PF_5551),0, 4 ,32,32,25);

	//indique que tout et en mode annimation
	oslAnimationPlay(bac);
	oslAnimationPlay(zelda);
	oslAnimationPlay(zou);
	oslAnimationPlay(fumee);


	//possition des objets
	zelda->sprite->x = 50;
	zelda->sprite->y = 50;

	fumee->sprite->x = 0;
	fumee->sprite->y = 272 - fumee->sprite->stretchY;

	zou->sprite->x =  200;
	zou->sprite->y =  50;

	bac->sprite->x =  350;
	bac->sprite->y =  200;

	//utilise une fonte
	oslSetFont(maFonte);


	while (!osl_quit)
	{
		//Debut du dessin
		oslStartDrawing();
		oslCls();

		ToucheAnnimation();

		oslPrintColorShadow(2, 2,JAUNE,"UTILISE LES FLECHES", 0);

		//dessine les objets
		oslDrawImageAnime(bac);
		oslDrawImageAnime(zelda);
		oslDrawImageAnime(zou);
		oslDrawImageAnime(fumee);

		oslSynchronization();
		if (osl_keys->pressed.start)break;

	}


}







void ToucheAnnimation()
{
	oslReadKeys();

	if (osl_keys->held.up){

		oslChangePosition(zelda,ZELDA_HAUT);
		oslAnimationPlay(zelda);

		oslChangePosition(zou,ZOU_HAUT);
		oslAnimationPlay(zou);
		
	}

	if (osl_keys->held.down){
		oslChangePosition(zelda,ZELDA_BAS);
		oslAnimationPlay(zelda);
		
		oslChangePosition(zou,ZOU_BAS);
		oslAnimationPlay(zou);
	}

	if (osl_keys->held.left){
		oslChangePosition(zelda,ZELDA_GAUCHE);
		oslAnimationPlay(zelda);

		oslChangePosition(zou,ZOU_GAUCHE);
		oslAnimationPlay(zou);
		
	}

	if (osl_keys->held.right){
		oslChangePosition(zelda,ZELDA_DROITE);
		oslAnimationPlay(zelda);
		
		oslChangePosition(zou,ZOU_DROITE);
		oslAnimationPlay(zou);
	}

	//si aucune touche alors on remet l'annimation dans lequel il ce trouve a 0 et on arrete l'annimation
	if (!osl_keys->held.value){
		oslAnimationStop(zelda);
		oslResetPosition(zelda);
		oslAnimationStop(zou);
		oslResetPosition(zou);
	}


	
	
}

