From 9b6666444e07d715b2b9a7c9d6c982354f14b7a9 Mon Sep 17 00:00:00 2001 From: Pierre Cwik Date: Fri, 24 Jun 2016 18:08:54 +0200 Subject: [PATCH] debut traitement scores --- projets/Centipede/centipede | Bin 35856 -> 0 bytes projets/Centipede/progprinc.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------- projets/Centipede/progprinc.o | Bin 23720 -> 0 bytes projets/Centipede/scores.txt | 1 + projets/Liste/libFile.c | 2 +- projets/Liste/libFile.o | Bin 5808 -> 0 bytes projets/Liste/libListe.a | Bin 6024 -> 0 bytes projets/Lutins/level1.bmp | Bin 0 -> 750054 bytes projets/Lutins/level2.bmp | Bin 0 -> 750054 bytes projets/Lutins/level3.bmp | Bin 0 -> 750054 bytes projets/Lutins/level_cleared.PNG | Bin 0 -> 15715 bytes projets/Lutins/level_cleared.bmp | Bin 0 -> 109422 bytes projets/Lutins/youwin.bmp | Bin 0 -> 119478 bytes 13 files changed, 71 insertions(+), 44 deletions(-) create mode 100644 projets/Centipede/scores.txt create mode 100644 projets/Lutins/level1.bmp create mode 100644 projets/Lutins/level2.bmp create mode 100644 projets/Lutins/level3.bmp create mode 100644 projets/Lutins/level_cleared.PNG create mode 100644 projets/Lutins/level_cleared.bmp create mode 100644 projets/Lutins/youwin.bmp diff --git a/projets/Centipede/centipede b/projets/Centipede/centipede index fcd5e8f..ebc97cc 100755 Binary files a/projets/Centipede/centipede and b/projets/Centipede/centipede differ diff --git a/projets/Centipede/progprinc.c b/projets/Centipede/progprinc.c index 8c46fb6..2a610f2 100644 --- a/projets/Centipede/progprinc.c +++ b/projets/Centipede/progprinc.c @@ -8,26 +8,23 @@ #define MAX_ELEMENTS 50 typedef struct{ - char pseudo; - char scoremax; + char pseudo[MAX_ELEMENTS]; + int scorefait; }scorejoueur; + typedef struct { int x; int y; }position; - - typedef struct { position contenu[MAX_ELEMENTS]; int nombre; - } liste_champi; - - - + } liste_poly; + void creationgrille(){ int i; for(i = 0 ; i < 20; i++) @@ -35,10 +32,7 @@ for(i = 0 ; i < 20; i++) rectanglePlein(i*50,0,1,1000,5); //pose de la grille rectanglePlein(0,i*50,1000,1,5); } } - - - - + void affichage(element_t e) { @@ -49,7 +43,7 @@ void affichage(element_t e) -void creerchampignons(int n,liste_champi *muschrooms,int champi){ +void creerchampignons(int n,liste_poly *muschrooms,int champi){ position poschampi; int i,w; int test=0; @@ -70,8 +64,6 @@ void creerchampignons(int n,liste_champi *muschrooms,int champi){ } } - - void creationcenti(liste_t *l, int Teted, int Corpsd){ int i; @@ -93,14 +85,10 @@ void creationcenti(liste_t *l, int Teted, int Corpsd){ posmillepatte.x = 500; posmillepatte.y = 500; enfiler(l,&posmillepatte,sizeof(position)); //affichage de la tete du Centipède - pos = enieme(4, l); + pos = enieme(4,l); afficherLutin(Teted,pos->x,pos->y); } - - - - int main() { SDL_keysym* detail; srand(time(NULL)); @@ -108,7 +96,12 @@ int main() { unsigned char bas; int largeur = 1000; int hauteur = 1000; - char *titre = "Le Centipède"; + char *name; + char *titre = "Le Centipede"; + scorejoueur resultat; + liste_poly testscore; + position *pos; + position posmillepatte; int champi = chargerLutin("Lutins/millepatte_champi.bmp",0); @@ -121,29 +114,39 @@ int main() { int Corpsh = chargerLutin("Lutins/millepatte_corps_haut.bmp",0); int Corpsb = chargerLutin("Lutins/millepatte_corps_bas.bmp",0); int gameover = chargerLutin("Lutins/game_over.bmp",0); + int level1 = chargerLutin("Lutins/level1.bmp",0); + int level2 = chargerLutin("Lutins/level2.bmp",0); + int level3 = chargerLutin("Lutins/level3.bmp",0); + int levelclr = chargerLutin("Lutins/level_cleared.bmp",0); + int youwin = chargerLutin("Lutins/youwin.bmp",0); int Tete; int Corps; - int abs, ord, obstacle, couleur,level=1,speed=200000,total=0,nombrechampis=3; + int i; + int abs, ord, obstacle, couleur,level=1,speed=5000,total=0,nombrechampis=6, s; - 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); } - - FILE *fichier = fopen("fichierdesscores.txt",a+); + 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); } printf("joueur !! quel est votre pseudo ? :"); - scanf("%s",&pseudo); - -while(level<5) { + scanf("%s",&name); + resultat.nom = name; + creerSurface(largeur,hauteur,titre); + majSurface(); + int gomme = creerLutin(0,0,50,50,-1); + +while(level<=3) { - liste_champi muschrooms={.nombre=0}; + queue = 0; + liste_poly muschrooms={.nombre=0}; liste_t listecenti={NULL,0,0}; - int h,w,l,t,compteur=0,allonge; - int s=10; + int w,t,compteur=0,allonge; - tailleLutin(champi,&l,&h); - position *pos; - position posmillepatte; + rectanglePlein(0,0,1000,1000,1); - creerSurface(largeur,hauteur,titre); + if(level==1) { afficherLutin(level1,250,250); majSurface(); sleep(1); } + if(level==2) { afficherLutin(level2,250,250); majSurface(); sleep(1); } + if(level==3) { afficherLutin(level3,250,250); majSurface(); sleep(1); } + + rectanglePlein(0,0,1000,1000,-1); creationcenti(&listecenti,Teted,Corpsd); @@ -151,12 +154,14 @@ while(level<5) { majSurface(); - int gomme = creerLutin(0,0,50,50,-1); - - majSurface(); - + attendreEvenement(); + + s = 0; + t = 0; while(1){ + for(i=0;isym==SDLK_RIGHT) t=0; @@ -165,8 +170,8 @@ while(level<5) { if(detail->sym==SDLK_DOWN) t=3; } - usleep(speed); - + usleep(1); + } if((t==0 && s!=2) || s==0) { abs=50; ord=0; Tete = Teted; Corps = Corpsd; s=0; } if((t==1 && s!=3) || s==1) { abs=0; ord=(-50); Tete = Teteh; Corps = Corpsh; s=1; } if((t==2 && s!=0) || s==2) { abs=-50; ord=0; Tete = Teteg; Corps = Corpsg; s=2; } @@ -230,15 +235,36 @@ while(level<5) { } } + total = total+compteur; if(compteur != nombrechampis) break; + if(level==3) { afficherLutin(youwin,204,400); majSurface(); sleep(3); } + else { afficherLutin(levelclr,304,454); majSurface(); sleep(3); } compteur = 0; nombrechampis = nombrechampis+3; - speed = speed/1.2; + speed = speed/2.2; level++; } - printf("votre score est de %d\n",total); + printf("votre score est de %d\n",total); + resultat.scorefait = total; + + FILE *fichier = NULL; + fichier = fopen("scores.txt",r+); + + if(fichier==NULL) { printf("\n le fichier n'a pas plus etre ouvert"); fermerSurface(); } + + else{ + + testscore->contenu[testscore->nombre++]=fread; + + + + + + } + + fermerSurface(); fclose(fichier); return 0; diff --git a/projets/Centipede/progprinc.o b/projets/Centipede/progprinc.o index 09baf7f..83ba189 100644 Binary files a/projets/Centipede/progprinc.o and b/projets/Centipede/progprinc.o differ diff --git a/projets/Centipede/scores.txt b/projets/Centipede/scores.txt new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/projets/Centipede/scores.txt @@ -0,0 +1 @@ + diff --git a/projets/Liste/libFile.c b/projets/Liste/libFile.c index 1d4d6be..6f22558 100644 --- a/projets/Liste/libFile.c +++ b/projets/Liste/libFile.c @@ -13,7 +13,7 @@ element_t nouveau=malloc(taille); memcpy(nouveau,e,taille); if (l->nombre >= l->alloue) { - l->contenu = realloc(l->contenu, l->alloue+300); + l->contenu = realloc(l->contenu, (l->alloue+300)*sizeof(element_t)); l->alloue+=300; } l->contenu[l->nombre++]=nouveau; diff --git a/projets/Liste/libFile.o b/projets/Liste/libFile.o index 1599463..4ee1da0 100644 Binary files a/projets/Liste/libFile.o and b/projets/Liste/libFile.o differ diff --git a/projets/Liste/libListe.a b/projets/Liste/libListe.a index cfcf6c3..55010c7 100644 Binary files a/projets/Liste/libListe.a and b/projets/Liste/libListe.a differ diff --git a/projets/Lutins/level1.bmp b/projets/Lutins/level1.bmp new file mode 100644 index 0000000..ec2f29d Binary files /dev/null and b/projets/Lutins/level1.bmp differ diff --git a/projets/Lutins/level2.bmp b/projets/Lutins/level2.bmp new file mode 100644 index 0000000..5b2e3cc Binary files /dev/null and b/projets/Lutins/level2.bmp differ diff --git a/projets/Lutins/level3.bmp b/projets/Lutins/level3.bmp new file mode 100644 index 0000000..c168bbf Binary files /dev/null and b/projets/Lutins/level3.bmp differ diff --git a/projets/Lutins/level_cleared.PNG b/projets/Lutins/level_cleared.PNG new file mode 100644 index 0000000..d74edc6 Binary files /dev/null and b/projets/Lutins/level_cleared.PNG differ diff --git a/projets/Lutins/level_cleared.bmp b/projets/Lutins/level_cleared.bmp new file mode 100644 index 0000000..b487ef8 Binary files /dev/null and b/projets/Lutins/level_cleared.bmp differ diff --git a/projets/Lutins/youwin.bmp b/projets/Lutins/youwin.bmp new file mode 100644 index 0000000..450e852 Binary files /dev/null and b/projets/Lutins/youwin.bmp differ -- libgit2 0.21.2