#include #include #include "../Graphique/libgraph.h" #include "../ListeC/Liste.h" #include "Missile.h" #define ErreurHitbox 2 int CheckCollisionEntiteEntite(struct entite enti1,int L1,int H1,struct entite enti2 ,int L2, int H2) { //CheckX int gauche1 = enti1.posx+ErreurHitbox; int droite1 = enti1.posx+L1-ErreurHitbox; int gauche2 = enti2.posx+ErreurHitbox; int droite2 = enti2.posx+L2-ErreurHitbox; int CheckX=0; if(gauche1 >= gauche2 && gauche1 <= droite2) { CheckX=1; } else if(droite1 >= gauche2 && droite1 <= droite2) { CheckX=1; } //CheckY int haut1 = enti1.posy+ErreurHitbox; int bas1 = enti1.posy+H1-ErreurHitbox; int haut2 = enti2.posy+ErreurHitbox; int bas2 = enti2.posy+H2-ErreurHitbox; int CheckY=0; if(haut1 <= bas2 && haut1 >= haut2) { CheckY=1; } else if(bas1 <= bas2 && bas1 >= haut2) { CheckY=1; } if(CheckX+CheckY==2){return 1;} else return 0; } int CheckCollisionListeEntite(struct liste_entite *Liste1,int L1,int H1,struct entite enti2, int L2, int H2) { struct liste_entite *pL1=Liste1; while (pL1 != NULL) { if(CheckCollisionEntiteEntite(pL1->enti,L1,H1,enti2,L2,H2) == 1) { return 1; } pL1=pL1->suivant; } return 0; } int CheckCollisionListeListe(struct liste_entite *Liste1,int L1,int H1,struct liste_entite *Liste2,int L2, int H2) { struct liste_entite *pL2=Liste2; while (pL2 != NULL) { if(CheckCollisionListeEntite(Liste1,L1,H1,pL2->enti,L2,H2) == 1) { return 1; } else pL2=pL2->suivant; } return 0; } void Tirer(struct entite joueur, struct liste_entite **pl) { ajout_tete(pl,creer_entite(joueur.posx+18,joueur.posy-5,0)); } void DeplacementTire(int tire,struct liste_entite *l) { struct liste_entite *ml=l; while(ml != NULL) { ml->enti.posy-=5; afficherLutin(tire,ml->enti.posx,ml->enti.posy); ml=ml->suivant; } }