From 19bcae5c5a38ddb92dbbc3e83d901f5cc18d4f36 Mon Sep 17 00:00:00 2001 From: Pierre Cwik Date: Thu, 23 Jun 2016 12:05:41 +0200 Subject: [PATCH] commence tt juste a gerer les pseudos --- projets/Centipede/centipede | Bin 34824 -> 0 bytes projets/Centipede/progprinc.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------ projets/Centipede/progprinc.o | Bin 22112 -> 0 bytes 3 files changed, 120 insertions(+), 90 deletions(-) diff --git a/projets/Centipede/centipede b/projets/Centipede/centipede index ba965fa..fcd5e8f 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 3a83093..8c46fb6 100644 --- a/projets/Centipede/progprinc.c +++ b/projets/Centipede/progprinc.c @@ -7,15 +7,38 @@ #include #define MAX_ELEMENTS 50 +typedef struct{ + char pseudo; + char scoremax; +}scorejoueur; + typedef struct { int x; int y; }position; + + + typedef struct { position contenu[MAX_ELEMENTS]; int nombre; } liste_champi; + + + + +void creationgrille(){ +int i; +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) { @@ -24,6 +47,60 @@ void affichage(element_t e) } + + +void creerchampignons(int n,liste_champi *muschrooms,int champi){ + position poschampi; + int i,w; + int test=0; + for(w=0;wcontenu[i].x == poschampi.x && muschrooms->contenu[i].y == poschampi.y ) test=1; + } + if((poschampi.y > 570 || poschampi.y < 430) && test==0) + { + muschrooms->contenu[muschrooms->nombre++]=poschampi; + afficherLutin(champi,(muschrooms->contenu[w].x)+1,(muschrooms->contenu[w].y)+6); + } + else w--; + test = 0; + } +} + + + + +void creationcenti(liste_t *l, int Teted, int Corpsd){ + int i; + position *pos; + position posmillepatte; + for(i=0; i<4; i++) + { + posmillepatte.x = (300 + 50*i); + posmillepatte.y = 500; + enfiler(l,&posmillepatte,sizeof(position)); + } + //affichage des corpsd du centipede + for(i=0; i<4; i++) + { + pos = enieme(i,l); + afficherLutin(Corpsd,pos->x,pos->y); + } + + posmillepatte.x = 500; + posmillepatte.y = 500; + enfiler(l,&posmillepatte,sizeof(position)); //affichage de la tete du Centipède + pos = enieme(4, l); + afficherLutin(Teted,pos->x,pos->y); +} + + + + + int main() { SDL_keysym* detail; srand(time(NULL)); @@ -31,10 +108,6 @@ int main() { unsigned char bas; int largeur = 1000; int hauteur = 1000; - liste_champi muschrooms={.nombre=0}; - liste_t listecenti={NULL,0,0}; - int h,w,l,i,t, allonge; - int s=0; char *titre = "Le Centipède"; @@ -50,97 +123,39 @@ int main() { int gameover = chargerLutin("Lutins/game_over.bmp",0); int Tete; int Corps; - int abs, ord, obstacle, couleur; + int abs, ord, obstacle, couleur,level=1,speed=200000,total=0,nombrechampis=3; 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+); + + printf("joueur !! quel est votre pseudo ? :"); + scanf("%s",&pseudo); + +while(level<5) { + + liste_champi muschrooms={.nombre=0}; + liste_t listecenti={NULL,0,0}; + int h,w,l,t,compteur=0,allonge; + int s=10; + tailleLutin(champi,&l,&h); position *pos; - position poschampi; position posmillepatte; creerSurface(largeur,hauteur,titre); - int x = 300; - int y = 500; - - for(i=0; i<4; i++) - { - posmillepatte.x = (x + 50*i); - posmillepatte.y = y; - enfiler(&listecenti,&posmillepatte,sizeof(position)); - } - //affichage des corpsd du centipede - for(i=0; i<4; i++) - { - pos = enieme(i,&listecenti); - afficherLutin(Corpsd,pos->x,pos->y); - } - - posmillepatte.x = (x+200); - posmillepatte.y = y; - enfiler(&listecenti,&posmillepatte,sizeof(position)); //affichage de la tete du Centipède - pos = enieme(4, &listecenti); - afficherLutin(Teted,pos->x,pos->y); + creationcenti(&listecenti,Teted,Corpsd); -/* for(i = 0 ; i < 20; i++) - { - rectanglePlein(i*50,0,1,1000,5); //pose de la grille - rectanglePlein(0,i*50,1000,1,5); - } */ + creerchampignons(nombrechampis,&muschrooms,champi); + majSurface(); - for(w=0;w<20;w++) - { - poschampi.x = (rand()%20)*50; //fixe coordonnées des champignons - poschampi.y = (rand()%20)*50; - if(poschampi.y > 570 || poschampi.y < 430) - { - muschrooms.contenu[muschrooms.nombre++]=poschampi; - afficherLutin(champi,(muschrooms.contenu[w].x)+1,(muschrooms.contenu[w].y)+6); - } - else w--; - } - - printf("%d %d \n",l,h); - //affiche les champis - for(w=0;w<20;w++) - { - printf("les coordonnées de mes champis : %d %d \n", (muschrooms.contenu[w].x),(muschrooms.contenu[w].y)); - } - - majSurface(); - - int gomme = creerLutin(0,0,50,50,-1); - -/* afficherLutin(Corpsd,0,0) - int couleurcd = couleurPixel(25,25); - majSurface(); - afficherLutin(gomme,0,0); - majSurface(); - - afficherLutin(Corpsg,0,0) - int couleurcg = couleurPixel(25,25); - majSurface(); - afficherLutin(gomme,0,0); - majSurface(); - - afficherLutin(Corpsh,0,0) - int couleurch = couleurPixel(25,25); - majSurface(); - afficherLutin(gomme,0,0); - majSurface(); - - afficherLutin(Corpsb,0,0) - int couleurcb = couleurPixel(25,25); - majSurface(); - afficherLutin(gomme,0,0); - majSurface(); */ + int gomme = creerLutin(0,0,50,50,-1); - majSurface(); + majSurface(); - while(1){ if(lireTouche(&bas,&touche,(void **)&detail) && bas==1) { @@ -150,7 +165,7 @@ int main() { if(detail->sym==SDLK_DOWN) t=3; } - usleep(200000); + usleep(speed); 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; } @@ -165,31 +180,32 @@ int main() { afficherLutin(gameover,250,433); majSurface(); sleep(5); - fermerSurface(); + break; } majSurface(); couleur = couleurPixel(posmillepatte.x+25,posmillepatte.y+25); - printf("la couleur est %d\n",couleur); if(couleur!=1) obstacle = 1; else obstacle = 0; allonge = 0; if(obstacle==1){ - for(w=0;w<20;w++) + for(w=0;wx,pos->y); afficherLutin(Corps,(pos->x),pos->y); enfiler(&listecenti,&posmillepatte,sizeof(posmillepatte)); afficherLutin(Tete,posmillepatte.x,posmillepatte.y); + compteur++; } else { afficherLutin(gameover,250,433); majSurface(); sleep(5); - fermerSurface(); + break; } } @@ -204,13 +220,27 @@ int main() { defiler(&listecenti); } majSurface(); + + if(compteur==nombrechampis) break; - if(touche=='a') - { - fermerSurface(); //condition d'arret - return 0; - } + if(touche=='a') + { + fermerSurface(); //condition d'arret + return 0; + } + } + + total = total+compteur; + if(compteur != nombrechampis) break; + compteur = 0; + nombrechampis = nombrechampis+3; + speed = speed/1.2; + level++; + } + printf("votre score est de %d\n",total); + fermerSurface(); + fclose(fichier); return 0; } diff --git a/projets/Centipede/progprinc.o b/projets/Centipede/progprinc.o index 34b568c..09baf7f 100644 Binary files a/projets/Centipede/progprinc.o and b/projets/Centipede/progprinc.o differ -- libgit2 0.21.2