Commit cab189eaf8d50c1c6380e2c6a290bc7f62e12c03

Authored by mahmoudrabia
1 parent 8e3dd927

rep

Showing 1 changed file with 0 additions and 160 deletions   Show diff stats
liste.c deleted
... ... @@ -1,160 +0,0 @@
1   -#include <stdio.h>
2   -#include "Graphique/libgraph.h"
3   -#include <stdlib.h>
4   -#include "liste.h"
5   -#define TAILLE_X 700
6   -#define TAILLE_DESC 40
7   -#define LARGEUR_MONS 30
8   -#define HAUTEUR_MONS 30
9   -#define LARGEUR_VAIS 35
10   -#define SPEED 1
11   -#define MISS_SPEED 5
12   -#define LARGEUR_MISS 5
13   -#define HAUTEUR_MISS 10
14   -
15   -
16   -
17   -
18   -l_entite* create_l_entite(int x,int y,int speed,int image)
19   -{
20   - l_entite* monster_1 =(l_entite*)malloc(sizeof(l_entite));
21   - (monster_1->ent).image=image;
22   - (monster_1->ent).x =x;
23   - (monster_1->ent).y =y;
24   - (monster_1->ent).speed=speed;
25   - monster_1->next = NULL;
26   - return monster_1;
27   -}
28   -
29   -entite create_entite(entite ent,int x,int y, int speed, int image)
30   -{
31   - (ent).image=image;
32   - (ent).x =x;
33   - (ent).y =y;
34   - (ent).speed=speed;
35   - return ent;
36   -}
37   -
38   -
39   -
40   -void add_entite (l_entite** head,int x,int y,int speed,int image)
41   -{
42   -
43   - l_entite* new_monster = create_l_entite( x, y,speed,image);
44   - if (head==NULL)
45   - {
46   - *head=new_monster;
47   - }
48   - else
49   - {
50   - l_entite* current =*head;
51   - while (current->next != NULL)
52   - { current=current->next;
53   - }
54   - current->next=new_monster;
55   - }
56   -}
57   -
58   -
59   -void display_l_entite(l_entite* mons)
60   -{
61   - l_entite* ptr= mons;
62   - while(ptr != NULL)
63   - {
64   - afficherLutin((ptr->ent).image,(ptr->ent).x,(ptr->ent).y);
65   - ptr=ptr->next;
66   - }
67   -}
68   -
69   -void display_entite(entite ent)
70   - {
71   - afficherLutin((ent).image,(ent).x,(ent).y);
72   - }
73   -
74   -
75   -
76   -void moveMonster(l_entite* monstre)
77   -{
78   - int max = TAILLE_X - LARGEUR_MONS;
79   - l_entite* currentMonster = monstre;
80   - while (currentMonster != NULL)
81   - {
82   - (currentMonster->ent).x += (currentMonster->ent).speed;
83   -
84   - if ( (currentMonster->ent).x < 0 || (currentMonster->ent).x > max)
85   - {
86   - (currentMonster->ent).speed = -(currentMonster->ent).speed;
87   - (currentMonster->ent).y += TAILLE_DESC ;
88   - }
89   -
90   - currentMonster = currentMonster->next;
91   - }
92   -}
93   -
94   -
95   -void addMissile(l_entite** head, entite vaisseau,int image)
96   -{
97   - // int MI =chargerLutin("graphique/invader_missile.bmp", COULEUR_NOIR);
98   - l_entite* newMissile = malloc(sizeof(l_entite));
99   - (newMissile->ent).x = vaisseau.x + (LARGEUR_VAIS/2);
100   - (newMissile->ent).y = (vaisseau).y - 5;
101   - (newMissile->ent).speed = SPEED;
102   - (newMissile->ent).image = image;
103   - newMissile->next = *head;
104   - *head = newMissile;
105   -}
106   -
107   -
108   -
109   -
110   - void moveMissile (l_entite* msl)
111   -{
112   - l_entite* currentMissile = msl;
113   - while(currentMissile != NULL)
114   - {
115   - (currentMissile->ent).y = (currentMissile->ent).y - MISS_SPEED ;
116   - currentMissile = currentMissile->next;
117   - }
118   -}
119   -
120   -
121   -void remove_entite (l_entite** head, l_entite* to_delete)
122   -{
123   -
124   - l_entite* courant = *head;
125   - while (courant != NULL)
126   - {
127   - if ((courant->ent).x == (to_delete->ent).x && (courant->ent).y == (to_delete->ent).y)
128   - {
129   - free(to_delete);
130   - }
131   - courant = courant->next;
132   - }
133   -}
134   -
135   -
136   -void detecterCollisions(l_entite* l_missile, l_entite* l_monstre)
137   -{
138   - l_entite* missile_courant = l_missile;
139   - l_entite* monstre_courant = l_monstre;
140   -
141   - while (missile_courant != NULL)
142   - {
143   - while (monstre_courant != NULL)
144   - {
145   - 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 )
146   - {
147   - int B=lutinTexte("boom", COULEUR_BLEU);
148   - afficherLutin(B,300,400);
149   - remove_entite(&l_missile,missile_courant);
150   - remove_entite(&l_monstre,monstre_courant);
151   -
152   -
153   - (missile_courant->ent).image = 0;
154   - (monstre_courant->ent).image = 0;
155   - }
156   - monstre_courant = monstre_courant->next;
157   - }
158   - missile_courant = missile_courant->next;
159   - }
160   -}