Aide jeux par C

ousous09 Messages postés 1 Date d'inscription mercredi 24 juin 2009 Statut Membre Dernière intervention 28 juin 2009 - 28 juin 2009 à 18:22
draonix Messages postés 43 Date d'inscription mercredi 27 mai 2009 Statut Membre Dernière intervention 7 juin 2011 - 30 juin 2009 à 11:43
voila, quand je compile ca me donne cette erreur
size of indefined or zero
j'ai rien compris

voila mon programme en C

#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <dos.h>
#include<graphics.h>
#include<stdlib.h>
#include<string.h>

typedef struct{ char nom[20];
int scor;
}joueur;


void menu_deroulant(char [][],int x,int *);
void test_graph();
void presontation();




//*************************************************************************


#define maxx getmaxx()
#define maxy getmaxy()

joueur j;

FILE *f;
int x,y;
int c1,l1,c2,l2,b=6,sco=0,niv=50,nivscor=100;
int scor=0,mieurscor;
char stop,ch[20];
void bare();
void msah_bare77();
void msah_bare75();
void balle();
void ston();
void test();
void jeux();
void gameover();
void fichier();
/////////////////////////////////////



void main()
{ clrscr();
char c,menu[5][50]={"Joue une partie","Niveau","Quitter" };
char menu1[5][50]={"Niveau 1","Niveau 2","Niveau 3","Quitter" };
int position,a,d,f;
presontation();
strcpy(ch,"Niveau 3");
do { position=0;
clrscr();

menu_deroulant(menu,3,&position);



switch(position){
case 0:
clrscr();
gotoxy(30,15);printf("Entre vote Nom:");
gets(j.nom);
jeux();
fichier();

break;





case 1: position=0; clrscr();
menu_deroulant(menu1,4,&position);
switch(position){
case 0: strcpy(ch,"Niveau 1"); nivscor=10; niv=200; break;
case 1: strcpy(ch,"Niveau 2");nivscor=50; niv=60;break;
case 2: strcpy(ch,"Niveau 3");position=0;nivscor=100; niv=40; break;
case 3: break;
}

break;

}

} while(position!=2);
}



void jeux(){ int bg,bd;

test_graph();
ston();

x=222;y=163;
c1=300; c2=c1+100;
l1=maxy-12; l2=maxy-3;
bg=8;bd=maxx-240;

settextstyle(3,HORIZ_DIR,1);

moveto(410,50);outtext("Mieur Score"); moveto(540,50);outtext(":");
moveto(410,80);outtext("Nom de joueur");moveto(540,80);outtext(":");
moveto(410,110);outtext("Niveau"); moveto(540,110);outtext(":");
moveto(410,140);outtext("Score"); moveto(540,140);outtext(":");
setcolor(2);
settextstyle(2,HORIZ_DIR,6);
outtextxy(550,110,ch);
itoa(sco,ch,10);
outtextxy(550,50,"0");
outtextxy(550,144,ch);
outtextxy(550,80,j.nom);


do{ bare();
balle();
stop=0;
if(kbhit())stop=getch();
switch(stop){
case 75:if(c1>bg){msah_bare75();c1-=19;c2-=19;}break;
case 77:if(c2=382){
if(b==3)b=4;
if(b==5)b=6;
}

if(y>=445){
if(x<=c2&&x>=c1){
if(b==1)b=2;
if(b==3){b=5;
setcolor(0);
settextstyle(2,HORIZ_DIR,6);
itoa(j.scor,ch,10);
outtextxy(550,144,ch);

j.scor+=nivscor;
setcolor(2);
settextstyle(2,HORIZ_DIR,6);
itoa(j.scor,ch,10);
outtextxy(550,144,ch);
}

if(b==4){b=6;
setcolor(0);
settextstyle(2,HORIZ_DIR,6);
itoa(j.scor,ch,10);
outtextxy(550,144,ch);


j.scor+=nivscor;
setcolor(2);
settextstyle(2,HORIZ_DIR,6);
itoa(j.scor,ch,10);
outtextxy(550,144,ch);
}
}

if(x>=c2&&x<c2+8){ if(b="=4)b=5;" }="" if(x<="c1&&x">=c1-8){
if(b==1)b=6;
if(b==3)b=6;
}

}
if(x<=12){
if(b==6)b=5;
if(b==4)b=3;

}

if(y<=13){
if(b==5)b=3;
if(b==6)b=4;
if(b==2)b=1;
}

}





/////////////////////////////////////

void gameover(){ char stop;

do{

//rectangle
setfillstyle(1,4);
bar(90,150,getmaxx()-300,getmaxy()-200);
setcolor(1);
settextstyle(1,HORIZ_DIR,3);
outtextxy(150,195,"GAME OVER");
delay(500);
setfillstyle(1,0);
bar(90,150,getmaxx()-300,getmaxy()-200);

delay(300);
if(kbhit())stop=getch();
}while(stop!=13&&stop!=27);


}



void ston(){
setcolor(1);
rectangle(1,1,maxx-240,maxy);
setcolor(1);
rectangle(maxx-235,1,maxx,maxy);
}

void balle(){

setcolor(2);
circle(x,y,8);
setfillstyle(SOLID_FILL,2);
floodfill(x,y,2);delay(niv);
setcolor(0);
circle(x,y,10);
setfillstyle(SOLID_FILL,0);
floodfill(x,y,0);

}

void msah_bare77(){
setcolor(0);
rectangle(c1-19,l1,c2-19,l2);
setfillstyle(SOLID_FILL,0);
floodfill(c1,l1,0);

}

void msah_bare75(){
setcolor(0);
rectangle(c1,l1,c2,l2);
setfillstyle(SOLID_FILL,0);
floodfill(c1,l1,0);

}


void bare(){

setcolor(1);
rectangle(c1,l1,c2,l2);
setfillstyle(SOLID_FILL,1);
floodfill(c1,l1,1);
}

void fichier(){
f=fopen("c:\\test.txt","a");
if(f==NULL)exit(0);
else fwrite(&j,sizeof(joueur),1,f);
fclose(f);
}


void menu_deroulant(char v_menu[10][50],int taille,int *pos)
{ _setcursortype(0);
int i,cp,j=0;
char c;
clrscr();
do {
for(i=0,j=0;itaille-1) *pos=0;break;

case 72 :
(*pos)--;
if(*pos<0) *pos=taille-1;break;
}
} while( c!=13);
_setcursortype(2);
} //fin menu_deroulant





void presontation(){ char stop;

test_graph();

setcolor(2);
settextstyle(1,HORIZ_DIR,7);
outtextxy(250,160,"EMSI");
setcolor(7);
settextstyle(0,HORIZ_DIR,1);
outtextxy(180,460,"realise par SAID EL BIDANI 2IIR2");

do{

setcolor(7);
settextstyle(1,HORIZ_DIR,2);
outtextxy(150,360,"Prise entr‚e pour jouer une partie");
delay(600);

setcolor(0);
settextstyle(1,HORIZ_DIR,2);
outtextxy(150,360,"Prise entr‚e pour jouer une partie");

delay(400);
if(kbhit()){stop=getch(); }
}while (stop!=13);

cleardevice();
closegraph();
}



void test_graph(){
int gdriver=DETECT;
int gmode,errorcode;
clrscr();
initgraph(&gdriver,&gmode,"c:\\tc\\bgi");

errorcode=graphresult();
if(errorcode!=grOk)
{
printf("\nerreur d'initialisation du mode graphique.\n");
printf("tapez une touche pour quitter.");
getch();
exit(1);
}
}

</c2+8){></string.h></stdlib.h></graphics.h></dos.h></string.h></stdio.h></conio.h>

1 réponse

draonix Messages postés 43 Date d'inscription mercredi 27 mai 2009 Statut Membre Dernière intervention 7 juin 2011
30 juin 2009 à 11:43
En fait d'après ce que je sais du C/C++ , tu n'as pas trop la possibilité de mettre en place des tableaux de tailles inconnues dans une fonction.
Les fonctions que tu crées ne peuvent accepté que des tableaux dynamiques (malloc en C / vector en C++), ou des tableau de taille fixe style char [5][5].
Sinonca t'affiche cette erreur.
essaye de mettre des entiers dans tes tableaux pour voir si cela marche.
0
Rejoignez-nous