diff --git a/liste.c b/liste.c deleted file mode 100644 index 6a9f4a4..0000000 --- a/liste.c +++ /dev/null @@ -1,160 +0,0 @@ -#include -#include "Graphique/libgraph.h" -#include -#include "liste.h" -#define TAILLE_X 700 -#define TAILLE_DESC 40 -#define LARGEUR_MONS 30 -#define HAUTEUR_MONS 30 -#define LARGEUR_VAIS 35 -#define SPEED 1 -#define MISS_SPEED 5 -#define LARGEUR_MISS 5 -#define HAUTEUR_MISS 10 - - - - -l_entite* create_l_entite(int x,int y,int speed,int image) -{ - l_entite* monster_1 =(l_entite*)malloc(sizeof(l_entite)); - (monster_1->ent).image=image; - (monster_1->ent).x =x; - (monster_1->ent).y =y; - (monster_1->ent).speed=speed; - monster_1->next = NULL; - return monster_1; -} - -entite create_entite(entite ent,int x,int y, int speed, int image) -{ - (ent).image=image; - (ent).x =x; - (ent).y =y; - (ent).speed=speed; - return ent; -} - - - -void add_entite (l_entite** head,int x,int y,int speed,int image) -{ - - l_entite* new_monster = create_l_entite( x, y,speed,image); - if (head==NULL) - { - *head=new_monster; - } - else - { - l_entite* current =*head; - while (current->next != NULL) - { current=current->next; - } - current->next=new_monster; - } -} - - -void display_l_entite(l_entite* mons) -{ - l_entite* ptr= mons; - while(ptr != NULL) - { - afficherLutin((ptr->ent).image,(ptr->ent).x,(ptr->ent).y); - ptr=ptr->next; - } -} - -void display_entite(entite ent) - { - afficherLutin((ent).image,(ent).x,(ent).y); - } - - - -void moveMonster(l_entite* monstre) -{ - int max = TAILLE_X - LARGEUR_MONS; - l_entite* currentMonster = monstre; - while (currentMonster != NULL) - { - (currentMonster->ent).x += (currentMonster->ent).speed; - - if ( (currentMonster->ent).x < 0 || (currentMonster->ent).x > max) - { - (currentMonster->ent).speed = -(currentMonster->ent).speed; - (currentMonster->ent).y += TAILLE_DESC ; - } - - currentMonster = currentMonster->next; - } -} - - -void addMissile(l_entite** head, entite vaisseau,int image) -{ - // int MI =chargerLutin("graphique/invader_missile.bmp", COULEUR_NOIR); - l_entite* newMissile = malloc(sizeof(l_entite)); - (newMissile->ent).x = vaisseau.x + (LARGEUR_VAIS/2); - (newMissile->ent).y = (vaisseau).y - 5; - (newMissile->ent).speed = SPEED; - (newMissile->ent).image = image; - newMissile->next = *head; - *head = newMissile; -} - - - - - void moveMissile (l_entite* msl) -{ - l_entite* currentMissile = msl; - while(currentMissile != NULL) - { - (currentMissile->ent).y = (currentMissile->ent).y - MISS_SPEED ; - currentMissile = currentMissile->next; - } -} - - -void remove_entite (l_entite** head, l_entite* to_delete) -{ - - l_entite* courant = *head; - while (courant != NULL) - { - if ((courant->ent).x == (to_delete->ent).x && (courant->ent).y == (to_delete->ent).y) - { - free(to_delete); - } - courant = courant->next; - } -} - - -void detecterCollisions(l_entite* l_missile, l_entite* l_monstre) -{ - l_entite* missile_courant = l_missile; - l_entite* monstre_courant = l_monstre; - - while (missile_courant != NULL) - { - while (monstre_courant != NULL) - { - if ( (monstre_courant->ent).x <= (missile_courant->ent).x && (missile_courant->ent).x <= (monstre_courant->ent).x + LARGEUR_MONS && (missile_courant->ent).y + HAUTEUR_MISS <= (monstre_courant->ent).y + HAUTEUR_MONS ) - { - int B=lutinTexte("boom", COULEUR_BLEU); - afficherLutin(B,300,400); - remove_entite(&l_missile,missile_courant); - remove_entite(&l_monstre,monstre_courant); - - - (missile_courant->ent).image = 0; - (monstre_courant->ent).image = 0; - } - monstre_courant = monstre_courant->next; - } - missile_courant = missile_courant->next; - } -} -- libgit2 0.21.2