#include #include #include #include #include "../Graphique/libgraph.h" #include "../ListeC/Liste.h" #include "../Monstre/Monstre.h" #include "../Interactif/Interactif.h" #include "init.h" #define TailleX 500 #define TailleY 500 #define Sol 475 int CheckCollision(struct entite enti1,int L1,int H1,struct entite enti2 ,int L2, int H2) { //CheckX int gauche1 = enti1.posx-L1; int droite1 = enti1.posx+L1; int gauche2 = enti2.posx-L2; int droite2 = enti2.posx+L2; int CheckX=0; if(gauche1 >= gauche2 && gauche1 <= droite2) { CheckX=1; } else if(droite1 >= gauche2 && droite1 <= droite2) { CheckX=1; } //CheckY int haut1 = enti1.posy-H1; int bas1 = enti1.posy+H1; int haut2 = enti2.posy-H2; int bas2 = enti2.posy+H2; int CheckY=0; if(haut1 >= bas2 && haut1 <= haut2) { CheckY=1; } else if(bas1 >= bas2 && bas1 <= haut2) { CheckY=1; } if(CheckX+CheckY==2){return 1;} return 0; } int main() { creerSurface(TailleX,TailleY,Nom); initialiser(); char texte[15]="SCORE : "; int Score = lutinTexte(texte,COULEUR_ROUGE); creer_liste(enemies); creer_liste(tires); Ligne_Monstre(&enemies,5); int SensVague=1; int *psens=&SensVague; printf("%d",hitboxcanonL); printf("%d",hitboxsbireL); printf("%d",hitboxmissileL); while(input!='m') { rectanglePlein(0,0,TailleX,TailleY,COULEUR_NOIR); rectanglePlein(0,Sol,TailleX,2,COULEUR_VERT); afficherLutin(canon,joueur.posx,joueur.posy); DeplacementLutin(sbire,enemies,psens,1); input = touche(); action(&joueur,input,&tires); DeplacementTire(missile,bouillie,&tires); /* Test struct entite missile1 = &tires->enti; struct liste_entite *p; p = enemies; while (p != NULL) { int ok = CheckCollision(missile1,hitboxmissileL,hitboxmissileH,p->enti,hitboxsbireL,hitboxsbireH); printf("%d \n",ok); p=p->suivant; } */ afficherLutin(Score,0,Sol); majSurface(); SDL_Delay(20); } return 0; }