
#include <oslib/oslib.h>



OSL_PARTICLES *Particule,*Particule2,*Particule3 ,*Particule4;
OSL_IMAGE *cible;


void Toucheparticle();



void particule04()
{


	Particule = oslLoadParticles("media/particule.png");
	oslInitParticles(Particule,20,20,2,1);

	Particule2 = oslLoadParticles("media/etoile.png");
	oslInitParticles(Particule2,50,30,4,25);
	
	Particule3 = oslLoadParticles("media/paillette.png");
	oslInitParticles(Particule3,50,30,4,10);

	Particule4 = oslLoadParticles("media/coeur.png");
	oslInitParticles(Particule4,50,30,4,10);

	cible = oslLoadImageFile("media/cible.png", OSL_IN_RAM, OSL_PF_5551);
	cible->x = 240;
	cible->y = 272/2;
	

	while (!osl_quit)
	{
		//Debut du dessin
		oslStartDrawing();
		oslCls();
		
		//gestion des touche
		Toucheparticle();

		
		oslDrawImage(cible);

		oslUpdateParticles(Particule);
		oslRenderParticles(Particule);

		oslUpdateParticles(Particule2);
		oslRenderParticles(Particule2);

		oslUpdateParticles(Particule3);
		oslRenderParticles(Particule3);

		oslUpdateParticles(Particule4);
		oslRenderParticles(Particule4);

		oslPrintColorShadow(0, 0,JAUNE,"Fleche + un des 4 bouttons", 0);
		oslPrintColorShadow(0, 10,JAUNE,"Analogique + cercle ", 0);




		oslSynchronization();

		if (osl_keys->pressed.start)break;

	}

}





void Toucheparticle()
{
	int i;
	oslReadKeys();

		for (i=120;i<=120;i+=120)
	{

		if (osl_keys->analogX > i) { 
			oslMoveXParticles( Particule, 1 );

		} else if (osl_keys->analogX < -i) {
			oslMoveXParticles( Particule, -1 );

		} else if (osl_keys->analogY > i) { 
			oslMoveYParticles( Particule, 1 );

		} else if (osl_keys->analogY < -i) {
			oslMoveYParticles( Particule, -1 );

		}

	}



	if (osl_keys->held.up){
		cible->y -=3;
	}
	if (osl_keys->held.down){
		cible->y +=3;
	}
	if (osl_keys->held.left){
		cible->x -=3;
	}
	if (osl_keys->held.right){
		cible->x +=3;
	}

	if (osl_keys->held.cross){
		oslNewParticles(Particule, cible->x +(cible->stretchX/2), cible->y +(cible->stretchY/2) );
	}

	if (osl_keys->held.circle){
		oslNewParticles(Particule2, cible->x+(cible->stretchX/2), cible->y +(cible->stretchY/2));
	}
	if (osl_keys->held.square){
		oslNewParticles(Particule3, cible->x+(cible->stretchX/2), cible->y +(cible->stretchY/2));
	}
	
	if (osl_keys->held.triangle){
		oslNewParticles(Particule4, cible->x+(cible->stretchX/2), cible->y+(cible->stretchY/2) );
	}

	
	
}
