J
'ai un projet à faire en borlandc en mode BGI, Je suis encore une debutante
et je bloque là dessus depuis une semaine.
Je vous donne à quoi j'ai pu me resoudre à faire jusqu'à maintenant:
#include <dos.h>
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
/*declaration des parametres*/
/*les fonctions utilis,es sont:*/
void graphique();
int choix_niveau();
void dimension(int choix,int *x ,int *y,int *nb);
void bombe(int nb, int *tab, int x, int y);
void remplissage(int tab[100][100],int x, int y);
void ecran(int x ,int y);
void initmouse();
/*void graphique();*/
void graphique()
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Erreur graphique: %s\n", grapherrormsg(errorcode));
printf("Appuyer sur une touche pour continuer:");
getch();
exit(1);
}
}
/*Menu*/
void choix_niveau ( int *niveau)
{
int rep=0;
char str[8];
clrscr();
setbkcolor(8);
settextstyle(GOTHIC_FONT,0,3);
cleardevice();
setbkcolor(8);
setfillstyle(3,12);
bar(80,40,getmaxx()-80,getmaxy()-40);
settextstyle(3,0,5);
outtextxy(100,60,"1* Facile");
outtextxy(100,120,"2* Moyen");
outtextxy(100,180,"3* Difficile");
outtextxy(100,240,"4* Personnalis,");
while(!((rep==1)||(rep==2)||(rep==3)||(rep==4)))
{
outtextxy(100,300,"Niveau :");
scanf("%d",&rep);
settextstyle(3,0,6);
itoa(rep,str,10);
outtextxy(180,360,str);
getch();
}
*niveau=rep;
}
void dimension(int choix,int *x ,int *y,int *nb)
{
char str[8];
if(choix==1)
{
*x=16;
*y=8;
*nb=10;
}
else if(choix==2)
{
*x=18;
*y=16;
*nb=40;
}
else if(choix==3)
{
*x=25;
*y=20;
*nb=99;
}
else if(choix==4)
{
cleardevice();
setbkcolor(8);
setfillstyle(2,13);
bar(80,40,getmaxx()-80,getmaxy()-40);
settextstyle(TRIPLEX_FONT, 0 , 6);
setcolor(7);
outtextxy(90,60,"entrez le nombre de colonnes");
scanf("%d",&(*x));
itoa(*x,str,10);
outtextxy(90,120,str);
outtextxy(90,180,"entrez le nombre de lignes ");
scanf("%d",&(*y));
itoa(*y,str,10);
outtextxy(90,240,str);
do
{
outtextxy(90,300,"entrez le nombre de bombes");
scanf("%d",&(*nb));
itoa(*nb,str,10);
outtextxy(90,360,str);
if(*nb>((*x)*(*y)))
{
gotoxy(90,360);
clreol();
}
}
while(*nb>((*x)*(*y)));
}
}
/*mettre les bombes*/
void bombe(int nb, int tab[100][100], int x, int y)
{
int i,j,p,q,compteur,valid;
printf("\n bombe ok");
srand(time(NULL));
for(compteur=1;compteur<=nb;compteur++)
{
valid=0;
do
{
p=1+(rand()%x);
q=1+(rand()%y);
if(tab[p][q] != 9)
{
tab[p][q]=9;
valid=1;
}
}
while(valid==0);
}
getch();
}
/*nombre de bombes */
int nbrebombe ( int tab[100][100] , int i, int j)
{
int n=0;
if (tab[i+1][j]==9) n++;
if (tab[i-1][j]==9) n++;
if (tab[i][j-1]==9) n++;
if (tab[i][j+1]==9) n++;
if (tab[i+1][j+1]==9) n++;
if (tab[i+1][j-1]==9) n++;
if (tab[i-1][j+1]==9) n++;
if (tab[i-1][j-1]==9) n++;
return (n);
}
/*remplissage tableau*/
void remplissage(int mat[100][100],int x, int y)
{
int p,q;
printf("remplissage ok");
for(p=0;p<=x;p++)
for(q=0;q<=y;q++)
if(mat[p][q]!=9) mat[p][q]=nbrebombe(mat,p,q);
}
void ecran(int x ,int y)
{
int i,j,maxx,maxy;
printf("ecran ok");
cleardevice();
setbkcolor(3);
setfillstyle(SOLID_FILL,8);
maxx=getmaxx();
maxy=getmaxy();
bar(100,60,maxx-100,maxy-60);
for(i=100;i<=maxx-100;i=i+((maxx-200)/x))
line(i,60,i,maxy-60);
for(j=60;j<=maxy-60;j=j+((maxy-120)/y))
line(100,j,maxx-100,j);
}
void dessinegrille(int tab[100][100],int x ,int y )
{
char str[8];
int i,j,err;
for(i=100;i<getmaxx()-100;i=i+((getmaxx()-200)/x))
for(j=60;j<getmaxy()-60;j=j+((getmaxy()-120)/y))
{
moveto(i+2,j+2);
itoa(tab[i][j], str ,10);
setcolor(10);
settextstyle(2,0,3);
outtextxy(i+2,j+2,str);
}
}
void initmouse()
{
_AX=0;
_AX=01;
_AX=04;
}
int main()
{
int grille[100][100];
int a,b,c,choice,level,abscisse,ordonee,nbr;
graphique();
choix_niveau(&level);
choice=level;
initmouse();
dimension(choice,&abscisse,&ordonee,&nbr);
bombe(nbr,grille,abscisse,ordonee);
cleardevice();
remplissage(grille,abscisse,ordonee);
cleardevice();
ecran(abscisse,ordonee);
getch();
dessinegrille(grille,abscisse,ordonee);
getch();
return 0 ;
}










Merci d'avance nimporte quelle aide me sera précieuse 






