Commit 9b6666444e07d715b2b9a7c9d6c982354f14b7a9
1 parent
19bcae5c
debut traitement scores
Showing
13 changed files
with
71 additions
and
44 deletions
Show diff stats
projets/Centipede/centipede
No preview for this file type
projets/Centipede/progprinc.c
... | ... | @@ -8,26 +8,23 @@ |
8 | 8 | #define MAX_ELEMENTS 50 |
9 | 9 | |
10 | 10 | typedef struct{ |
11 | - char pseudo; | |
12 | - char scoremax; | |
11 | + char pseudo[MAX_ELEMENTS]; | |
12 | + int scorefait; | |
13 | 13 | }scorejoueur; |
14 | 14 | |
15 | + | |
15 | 16 | typedef struct { |
16 | 17 | int x; |
17 | 18 | int y; |
18 | 19 | }position; |
19 | 20 | |
20 | 21 | |
21 | - | |
22 | - | |
23 | 22 | typedef struct { |
24 | 23 | position contenu[MAX_ELEMENTS]; |
25 | 24 | int nombre; |
26 | - } liste_champi; | |
27 | - | |
28 | - | |
29 | - | |
25 | + } liste_poly; | |
30 | 26 | |
27 | + | |
31 | 28 | void creationgrille(){ |
32 | 29 | int i; |
33 | 30 | for(i = 0 ; i < 20; i++) |
... | ... | @@ -35,10 +32,7 @@ for(i = 0 ; i < 20; i++) |
35 | 32 | rectanglePlein(i*50,0,1,1000,5); //pose de la grille |
36 | 33 | rectanglePlein(0,i*50,1000,1,5); |
37 | 34 | } } |
38 | - | |
39 | - | |
40 | - | |
41 | - | |
35 | + | |
42 | 36 | |
43 | 37 | void affichage(element_t e) |
44 | 38 | { |
... | ... | @@ -49,7 +43,7 @@ void affichage(element_t e) |
49 | 43 | |
50 | 44 | |
51 | 45 | |
52 | -void creerchampignons(int n,liste_champi *muschrooms,int champi){ | |
46 | +void creerchampignons(int n,liste_poly *muschrooms,int champi){ | |
53 | 47 | position poschampi; |
54 | 48 | int i,w; |
55 | 49 | int test=0; |
... | ... | @@ -70,8 +64,6 @@ void creerchampignons(int n,liste_champi *muschrooms,int champi){ |
70 | 64 | } |
71 | 65 | } |
72 | 66 | |
73 | - | |
74 | - | |
75 | 67 | |
76 | 68 | void creationcenti(liste_t *l, int Teted, int Corpsd){ |
77 | 69 | int i; |
... | ... | @@ -93,14 +85,10 @@ void creationcenti(liste_t *l, int Teted, int Corpsd){ |
93 | 85 | posmillepatte.x = 500; |
94 | 86 | posmillepatte.y = 500; |
95 | 87 | enfiler(l,&posmillepatte,sizeof(position)); //affichage de la tete du Centipède |
96 | - pos = enieme(4, l); | |
88 | + pos = enieme(4,l); | |
97 | 89 | afficherLutin(Teted,pos->x,pos->y); |
98 | 90 | } |
99 | 91 | |
100 | - | |
101 | - | |
102 | - | |
103 | - | |
104 | 92 | int main() { |
105 | 93 | SDL_keysym* detail; |
106 | 94 | srand(time(NULL)); |
... | ... | @@ -108,7 +96,12 @@ int main() { |
108 | 96 | unsigned char bas; |
109 | 97 | int largeur = 1000; |
110 | 98 | int hauteur = 1000; |
111 | - char *titre = "Le Centipède"; | |
99 | + char *name; | |
100 | + char *titre = "Le Centipede"; | |
101 | + scorejoueur resultat; | |
102 | + liste_poly testscore; | |
103 | + position *pos; | |
104 | + position posmillepatte; | |
112 | 105 | |
113 | 106 | |
114 | 107 | int champi = chargerLutin("Lutins/millepatte_champi.bmp",0); |
... | ... | @@ -121,29 +114,39 @@ int main() { |
121 | 114 | int Corpsh = chargerLutin("Lutins/millepatte_corps_haut.bmp",0); |
122 | 115 | int Corpsb = chargerLutin("Lutins/millepatte_corps_bas.bmp",0); |
123 | 116 | int gameover = chargerLutin("Lutins/game_over.bmp",0); |
117 | + int level1 = chargerLutin("Lutins/level1.bmp",0); | |
118 | + int level2 = chargerLutin("Lutins/level2.bmp",0); | |
119 | + int level3 = chargerLutin("Lutins/level3.bmp",0); | |
120 | + int levelclr = chargerLutin("Lutins/level_cleared.bmp",0); | |
121 | + int youwin = chargerLutin("Lutins/youwin.bmp",0); | |
124 | 122 | int Tete; |
125 | 123 | int Corps; |
126 | - int abs, ord, obstacle, couleur,level=1,speed=200000,total=0,nombrechampis=3; | |
124 | + int i; | |
125 | + int abs, ord, obstacle, couleur,level=1,speed=5000,total=0,nombrechampis=6, s; | |
127 | 126 | |
128 | - if(champi<0 || Teted<0 || Teteg<0 || Teteh <0 || Teteb<0 || Corpsg<0 || Corpsd<0 || Corpsh<0 || Corpsb<0 || gameover<0){ printf("Image pas là\n"); exit(-1); } | |
129 | - | |
130 | - FILE *fichier = fopen("fichierdesscores.txt",a+); | |
127 | + if(champi<0 || Teted<0 || Teteg<0 || Teteh <0 || Teteb<0 || Corpsg<0 || Corpsd<0 || Corpsh<0 || Corpsb<0 || gameover<0 || level1<0 || level2<0 || level3<0 || levelclr<0 || youwin<0){ printf("Image pas là\n"); exit(-1); } | |
131 | 128 | |
132 | 129 | printf("joueur !! quel est votre pseudo ? :"); |
133 | - scanf("%s",&pseudo); | |
134 | - | |
135 | -while(level<5) { | |
130 | + scanf("%s",&name); | |
131 | + resultat.nom = name; | |
132 | + creerSurface(largeur,hauteur,titre); | |
133 | + majSurface(); | |
134 | + int gomme = creerLutin(0,0,50,50,-1); | |
135 | + | |
136 | +while(level<=3) { | |
136 | 137 | |
137 | - liste_champi muschrooms={.nombre=0}; | |
138 | + queue = 0; | |
139 | + liste_poly muschrooms={.nombre=0}; | |
138 | 140 | liste_t listecenti={NULL,0,0}; |
139 | - int h,w,l,t,compteur=0,allonge; | |
140 | - int s=10; | |
141 | + int w,t,compteur=0,allonge; | |
141 | 142 | |
142 | - tailleLutin(champi,&l,&h); | |
143 | - position *pos; | |
144 | - position posmillepatte; | |
143 | + rectanglePlein(0,0,1000,1000,1); | |
145 | 144 | |
146 | - creerSurface(largeur,hauteur,titre); | |
145 | + if(level==1) { afficherLutin(level1,250,250); majSurface(); sleep(1); } | |
146 | + if(level==2) { afficherLutin(level2,250,250); majSurface(); sleep(1); } | |
147 | + if(level==3) { afficherLutin(level3,250,250); majSurface(); sleep(1); } | |
148 | + | |
149 | + rectanglePlein(0,0,1000,1000,-1); | |
147 | 150 | |
148 | 151 | creationcenti(&listecenti,Teted,Corpsd); |
149 | 152 | |
... | ... | @@ -151,12 +154,14 @@ while(level<5) { |
151 | 154 | |
152 | 155 | majSurface(); |
153 | 156 | |
154 | - int gomme = creerLutin(0,0,50,50,-1); | |
155 | - | |
156 | - majSurface(); | |
157 | - | |
157 | + attendreEvenement(); | |
158 | + | |
159 | + s = 0; | |
160 | + t = 0; | |
158 | 161 | |
159 | 162 | while(1){ |
163 | + for(i=0;i<speed;i++) | |
164 | + { | |
160 | 165 | if(lireTouche(&bas,&touche,(void **)&detail) && bas==1) |
161 | 166 | { |
162 | 167 | if(detail->sym==SDLK_RIGHT) t=0; |
... | ... | @@ -165,8 +170,8 @@ while(level<5) { |
165 | 170 | if(detail->sym==SDLK_DOWN) t=3; |
166 | 171 | } |
167 | 172 | |
168 | - usleep(speed); | |
169 | - | |
173 | + usleep(1); | |
174 | + } | |
170 | 175 | if((t==0 && s!=2) || s==0) { abs=50; ord=0; Tete = Teted; Corps = Corpsd; s=0; } |
171 | 176 | if((t==1 && s!=3) || s==1) { abs=0; ord=(-50); Tete = Teteh; Corps = Corpsh; s=1; } |
172 | 177 | if((t==2 && s!=0) || s==2) { abs=-50; ord=0; Tete = Teteg; Corps = Corpsg; s=2; } |
... | ... | @@ -230,15 +235,36 @@ while(level<5) { |
230 | 235 | } |
231 | 236 | } |
232 | 237 | |
238 | + | |
233 | 239 | total = total+compteur; |
234 | 240 | if(compteur != nombrechampis) break; |
241 | + if(level==3) { afficherLutin(youwin,204,400); majSurface(); sleep(3); } | |
242 | + else { afficherLutin(levelclr,304,454); majSurface(); sleep(3); } | |
235 | 243 | compteur = 0; |
236 | 244 | nombrechampis = nombrechampis+3; |
237 | - speed = speed/1.2; | |
245 | + speed = speed/2.2; | |
238 | 246 | level++; |
239 | 247 | |
240 | 248 | } |
241 | - printf("votre score est de %d\n",total); | |
249 | + printf("votre score est de %d\n",total); | |
250 | + resultat.scorefait = total; | |
251 | + | |
252 | + FILE *fichier = NULL; | |
253 | + fichier = fopen("scores.txt",r+); | |
254 | + | |
255 | + if(fichier==NULL) { printf("\n le fichier n'a pas plus etre ouvert"); fermerSurface(); } | |
256 | + | |
257 | + else{ | |
258 | + | |
259 | + testscore->contenu[testscore->nombre++]=fread; | |
260 | + | |
261 | + | |
262 | + | |
263 | + | |
264 | + | |
265 | + } | |
266 | + | |
267 | + | |
242 | 268 | fermerSurface(); |
243 | 269 | fclose(fichier); |
244 | 270 | return 0; | ... | ... |
projets/Centipede/progprinc.o
No preview for this file type
... | ... | @@ -0,0 +1 @@ |
1 | + | ... | ... |
projets/Liste/libFile.c
... | ... | @@ -13,7 +13,7 @@ element_t nouveau=malloc(taille); |
13 | 13 | memcpy(nouveau,e,taille); |
14 | 14 | if (l->nombre >= l->alloue) |
15 | 15 | { |
16 | - l->contenu = realloc(l->contenu, l->alloue+300); | |
16 | + l->contenu = realloc(l->contenu, (l->alloue+300)*sizeof(element_t)); | |
17 | 17 | l->alloue+=300; |
18 | 18 | } |
19 | 19 | l->contenu[l->nombre++]=nouveau; | ... | ... |
projets/Liste/libFile.o
No preview for this file type
projets/Liste/libListe.a
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
15.3 KB
No preview for this file type
No preview for this file type