Commit 3d9ce1c2 authored by Erwan's avatar Erwan

Fix de la generation des mines (on obtient bien le nombre d'entrée)

parent 7a8c3fc0
...@@ -111,15 +111,20 @@ bool revelerCase(CelluleDemineur** matriceMines, int line, int column, int nbLig ...@@ -111,15 +111,20 @@ bool revelerCase(CelluleDemineur** matriceMines, int line, int column, int nbLig
} }
void generationMines(int nbMines, int nbLigneMatrice, int nbColonneMatrice, CelluleDemineur** matriceMines){ void generationMines(int nbMines, int nbLigneMatrice, int nbColonneMatrice, CelluleDemineur** matriceMines){
int lineRand = rand()%nbLigneMatrice;
int colRand = rand()%nbColonneMatrice;
for(int i=0; i<nbMines; i++){ for(int i=0; i<nbMines; i++){
int lineRand = rand()%nbLigneMatrice;
int colRand = rand()%nbColonneMatrice;
while(!containsMine(lineRand, colRand, matriceMines)){ while(containsMine(lineRand, colRand, matriceMines)){
matriceMines[lineRand][colRand]->hasMine = true; lineRand = rand()%nbLigneMatrice;
matriceMines[lineRand][colRand]->nearbyMine = -9; colRand = rand()%nbColonneMatrice;
incrementationVoisinMine(lineRand, colRand, matriceMines, nbLigneMatrice, nbColonneMatrice);
} }
matriceMines[lineRand][colRand]->hasMine = true;
matriceMines[lineRand][colRand]->nearbyMine = -9;
incrementationVoisinMine(lineRand, colRand, matriceMines, nbLigneMatrice, nbColonneMatrice);
} }
} }
...@@ -164,7 +169,7 @@ int main(void) ...@@ -164,7 +169,7 @@ int main(void)
srand(time(NULL)); srand(time(NULL));
int nbLigneMatrice = 10, nbColonneMatrice = 10, nbMines = 80; int nbLigneMatrice = 17, nbColonneMatrice = 21, nbMines = 80;
int curCaseX = 0, curCaseY = 0, flaggedMines = 0; int curCaseX = 0, curCaseY = 0, flaggedMines = 0;
bool lose = false, win = false; bool lose = false, win = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment