Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MLOD_ProjectC
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Erwan MERLY
MLOD_ProjectC
Commits
8e9651ba
Commit
8e9651ba
authored
Oct 30, 2020
by
Erwan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplification de la fonction pour afficher les voisins (intégration de afficherCase)
parent
a1040687
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
21 deletions
+12
-21
minesweeper.c
minesweeper.c
+12
-21
No files found.
minesweeper.c
View file @
8e9651ba
...
@@ -74,18 +74,7 @@ void revelerVoisins(int line, int column, CelluleDemineur** matriceMines, int nb
...
@@ -74,18 +74,7 @@ void revelerVoisins(int line, int column, CelluleDemineur** matriceMines, int nb
for
(
int
i
=
0
;
i
<
6
;
i
++
){
for
(
int
i
=
0
;
i
<
6
;
i
++
){
if
(
voisins
[
i
]
!=
NULL
){
if
(
voisins
[
i
]
!=
NULL
){
revelerCase
(
matriceMines
,
voisins
[
i
]
->
line
,
voisins
[
i
]
->
column
,
nbLigneMatrice
,
nbColonneMatrice
);
if
(
voisins
[
i
]
->
nearbyMine
==
0
&&
!
voisins
[
i
]
->
isPressed
){
voisins
[
i
]
->
isPressed
=
true
;
voisins
[
i
]
->
couleurCase
=
LIGHTGRAY
;
revelerVoisins
(
voisins
[
i
]
->
line
,
voisins
[
i
]
->
column
,
matriceMines
,
nbLigneMatrice
,
nbColonneMatrice
);
}
else
if
(
voisins
[
i
]
->
nearbyMine
>
0
&&
!
voisins
[
i
]
->
isPressed
){
voisins
[
i
]
->
isPressed
=
true
;
voisins
[
i
]
->
couleurCase
=
LIGHTGRAY
;
}
else
if
(
voisins
[
i
]
->
nearbyMine
<
0
&&
!
voisins
[
i
]
->
isPressed
){
voisins
[
i
]
->
isPressed
=
true
;
voisins
[
i
]
->
couleurCase
=
MAROON
;
}
}
}
}
}
free
(
voisins
);
free
(
voisins
);
...
@@ -127,15 +116,17 @@ void initGrille(int nbLigneMatrice, int nbColonneMatrice, CelluleDemineur** matr
...
@@ -127,15 +116,17 @@ void initGrille(int nbLigneMatrice, int nbColonneMatrice, CelluleDemineur** matr
}
}
void
revelerCase
(
CelluleDemineur
**
matriceMines
,
int
line
,
int
column
,
int
nbLigneMatrice
,
int
nbColonneMatrice
){
void
revelerCase
(
CelluleDemineur
**
matriceMines
,
int
line
,
int
column
,
int
nbLigneMatrice
,
int
nbColonneMatrice
){
matriceMines
[
line
][
column
]
->
isPressed
=
true
;
if
(
!
matriceMines
[
line
][
column
]
->
isFlaged
&&
!
matriceMines
[
line
][
column
]
->
isPressed
){
matriceMines
[
line
][
column
]
->
isPressed
=
true
;
if
(
matriceMines
[
line
][
column
]
->
nearbyMine
==
0
){
if
(
matriceMines
[
line
][
column
]
->
nearbyMine
==
0
){
matriceMines
[
line
][
column
]
->
couleurCase
=
LIGHTGRAY
;
matriceMines
[
line
][
column
]
->
couleurCase
=
LIGHTGRAY
;
revelerVoisins
(
line
,
column
,
matriceMines
,
nbLigneMatrice
,
nbColonneMatrice
);
revelerVoisins
(
line
,
column
,
matriceMines
,
nbLigneMatrice
,
nbColonneMatrice
);
}
else
if
(
matriceMines
[
line
][
column
]
->
nearbyMine
<
0
){
}
else
if
(
matriceMines
[
line
][
column
]
->
nearbyMine
<
0
){
matriceMines
[
line
][
column
]
->
couleurCase
=
MAROON
;
matriceMines
[
line
][
column
]
->
couleurCase
=
MAROON
;
}
else
{
}
else
{
matriceMines
[
line
][
column
]
->
couleurCase
=
LIGHTGRAY
;
matriceMines
[
line
][
column
]
->
couleurCase
=
LIGHTGRAY
;
}
}
}
}
}
...
@@ -153,7 +144,7 @@ int main(void)
...
@@ -153,7 +144,7 @@ int main(void)
srand
(
time
(
NULL
));
srand
(
time
(
NULL
));
//CREER MATRICE DES MINES
//CREER MATRICE DES MINES
int
nbLigneMatrice
=
5
,
nbColonneMatrice
=
5
,
nbMines
=
2
;
int
nbLigneMatrice
=
16
,
nbColonneMatrice
=
21
,
nbMines
=
60
;
CelluleDemineur
**
matriceMines
=
malloc
(
nbLigneMatrice
*
sizeof
(
CelluleDemineur
*
));
CelluleDemineur
**
matriceMines
=
malloc
(
nbLigneMatrice
*
sizeof
(
CelluleDemineur
*
));
for
(
int
i
=
0
;
i
<
nbColonneMatrice
;
i
++
)
for
(
int
i
=
0
;
i
<
nbColonneMatrice
;
i
++
)
matriceMines
[
i
]
=
malloc
(
nbColonneMatrice
*
sizeof
(
CelluleDemineur
));
matriceMines
[
i
]
=
malloc
(
nbColonneMatrice
*
sizeof
(
CelluleDemineur
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment