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
2ea5ad0c
Commit
2ea5ad0c
authored
Nov 01, 2020
by
Erwan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Permet de ne plus activer une tuile si la souris est hors du champ de mines
Ajout de commentaire et remise en page du code
parent
fb46b69a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
121 additions
and
114 deletions
+121
-114
minesweeper.c
minesweeper.c
+121
-114
No files found.
minesweeper.c
View file @
2ea5ad0c
...
...
@@ -2,53 +2,90 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#define SIZE_OF_HEX 25
struct
celluleDemineur
{
int
line
,
column
;
bool
hasMine
;
int
nearbyMine
;
Vector2
pos
;
bool
isMine
;
bool
isPressed
;
bool
i
f
Flagged
;
bool
i
s
Flagged
;
bool
isNeareast
;
Color
couleurCase
;
Vector2
pos
;
};
typedef
struct
celluleDemineur
*
CelluleDemineur
;
bool
containsMine
(
int
line
,
int
col
,
CelluleDemineur
**
matriceMines
);
void
initGrille
(
int
nbLineMatrice
,
int
nbColumnMatrice
,
CelluleDemineur
**
matriceMines
);
void
generationMines
(
int
nbMines
,
int
nbLineMatrice
,
int
nbColumnMatrice
,
CelluleDemineur
**
matriceMines
);
CelluleDemineur
*
recupererVoisins
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLi
gneMatrice
,
int
nbColonne
Matrice
);
CelluleDemineur
*
recupererVoisins
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLi
neMatrice
,
int
nbColumn
Matrice
);
void
incrementationVoisinMine
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLi
gneMatrice
,
int
nbColonne
Matrice
);
void
incrementationVoisinMine
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLi
neMatrice
,
int
nbColumn
Matrice
);
bool
reveler
Voisins
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLigneMatrice
,
int
nbColonne
Matrice
);
bool
reveler
Case
(
CelluleDemineur
**
matriceMines
,
int
line
,
int
column
,
int
nbLineMatrice
,
int
nbColumn
Matrice
);
bool
reveler
Case
(
CelluleDemineur
**
matriceMines
,
int
line
,
int
column
,
int
nbLigneMatrice
,
int
nbColonne
Matrice
);
bool
reveler
Voisins
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLineMatrice
,
int
nbColumn
Matrice
);
void
generationMines
(
int
nbMines
,
int
nbLigneMatrice
,
int
nbColonneMatrice
,
CelluleDemineur
**
matriceMines
);
float
distanceEntrePoints
(
Vector2
a
,
Vector2
b
);
void
initGrille
(
int
nbLigneMatrice
,
int
nbColonneMatrice
,
CelluleDemineur
**
matriceMines
);
float
getDistanceBetweenPoints
(
Vector2
a
,
Vector2
b
);
void
initGrille
(
int
nbLineMatrice
,
int
nbColumnMatrice
,
CelluleDemineur
**
matriceMines
){
int
screenHeight
=
GetScreenHeight
(),
screenWidth
=
GetScreenWidth
();
for
(
int
i
=
0
;
i
<
nbLineMatrice
;
i
++
){
for
(
int
j
=
0
;
j
<
nbColumnMatrice
;
j
++
){
matriceMines
[
i
][
j
]
=
malloc
(
sizeof
(
struct
celluleDemineur
));
matriceMines
[
i
][
j
]
->
isMine
=
false
;
matriceMines
[
i
][
j
]
->
isPressed
=
false
;
matriceMines
[
i
][
j
]
->
isFlagged
=
false
;
matriceMines
[
i
][
j
]
->
isNeareast
=
false
;
matriceMines
[
i
][
j
]
->
nearbyMine
=
0
;
matriceMines
[
i
][
j
]
->
line
=
i
;
matriceMines
[
i
][
j
]
->
column
=
j
;
matriceMines
[
i
][
j
]
->
couleurCase
=
DARKGRAY
;
bool
containsMine
(
int
line
,
int
col
,
CelluleDemineur
**
matriceMines
){
return
(
matriceMines
[
line
][
col
]
->
hasMine
==
true
);
//GERE LE DECALLAGE ENTRE LES LIGNES PAIRES ET IMPAIRES
if
(
i
%
2
==
0
){
matriceMines
[
i
][
j
]
->
pos
=
(
Vector2
){(
1
.
5
*
j
+
1
.
75
)
*
SIZE_OF_HEX
+
screenWidth
/
nbColumnMatrice
,
(
1
.
5
*
i
+
1
)
*
SIZE_OF_HEX
+
screenHeight
/
nbLineMatrice
};
}
else
{
matriceMines
[
i
][
j
]
->
pos
=
(
Vector2
){(
1
.
5
*
j
+
1
)
*
SIZE_OF_HEX
+
screenWidth
/
nbColumnMatrice
,
(
1
.
5
*
i
+
1
)
*
SIZE_OF_HEX
+
screenHeight
/
nbLineMatrice
};
}
}
}
}
CelluleDemineur
*
recupererVoisins
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLigneMatrice
,
int
nbColonneMatrice
){
void
generationMines
(
int
nbMines
,
int
nbLineMatrice
,
int
nbColumnMatrice
,
CelluleDemineur
**
matriceMines
){
int
lineRand
=
rand
()
%
nbLineMatrice
;
int
colRand
=
rand
()
%
nbColumnMatrice
;
for
(
int
i
=
0
;
i
<
nbMines
;
i
++
){
while
(
matriceMines
[
lineRand
][
colRand
]
->
isMine
){
lineRand
=
rand
()
%
nbLineMatrice
;
colRand
=
rand
()
%
nbColumnMatrice
;
}
matriceMines
[
lineRand
][
colRand
]
->
isMine
=
true
;
matriceMines
[
lineRand
][
colRand
]
->
nearbyMine
=
-
9
;
incrementationVoisinMine
(
lineRand
,
colRand
,
matriceMines
,
nbLineMatrice
,
nbColumnMatrice
);
}
}
CelluleDemineur
*
recupererVoisins
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLineMatrice
,
int
nbColumnMatrice
){
CelluleDemineur
*
tabVoisins
=
calloc
(
6
,
sizeof
(
struct
celluleDemineur
));
for
(
int
i
=
0
;
i
<
6
;
i
++
){
tabVoisins
[
i
]
=
NULL
;
}
//VERIFIE SI LES CASES SONT VALIDES
bool
linePrev
=
(
line
-
1
>=
0
),
colPrev
=
(
column
-
1
>=
0
);
bool
lineNext
=
(
line
+
1
<
nbLi
gneMatrice
),
colNext
=
(
column
+
1
<
nbColonne
Matrice
);
bool
lineNext
=
(
line
+
1
<
nbLi
neMatrice
),
colNext
=
(
column
+
1
<
nbColumn
Matrice
);
if
(
colPrev
){
tabVoisins
[
0
]
=
matriceMines
[
line
][
column
-
1
];}
if
(
colNext
){
tabVoisins
[
1
]
=
matriceMines
[
line
][
column
+
1
];}
...
...
@@ -67,8 +104,8 @@ CelluleDemineur* recupererVoisins(int line, int column, CelluleDemineur** matric
return
tabVoisins
;
}
void
incrementationVoisinMine
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLi
gneMatrice
,
int
nbColonne
Matrice
){
CelluleDemineur
*
voisins
=
recupererVoisins
(
line
,
column
,
matriceMines
,
nbLi
gneMatrice
,
nbColonne
Matrice
);
void
incrementationVoisinMine
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLi
neMatrice
,
int
nbColumn
Matrice
){
CelluleDemineur
*
voisins
=
recupererVoisins
(
line
,
column
,
matriceMines
,
nbLi
neMatrice
,
nbColumn
Matrice
);
for
(
int
i
=
0
;
i
<
6
;
i
++
){
if
(
voisins
[
i
]
!=
NULL
){
...
...
@@ -78,29 +115,15 @@ void incrementationVoisinMine(int line, int column, CelluleDemineur** matriceMin
free
(
voisins
);
}
bool
revelerVoisins
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLigneMatrice
,
int
nbColonneMatrice
){
CelluleDemineur
*
voisins
=
recupererVoisins
(
line
,
column
,
matriceMines
,
nbLigneMatrice
,
nbColonneMatrice
);
bool
res
=
false
,
resTemp
;
for
(
int
i
=
0
;
i
<
6
;
i
++
){
if
(
voisins
[
i
]
!=
NULL
){
resTemp
=
revelerCase
(
matriceMines
,
voisins
[
i
]
->
line
,
voisins
[
i
]
->
column
,
nbLigneMatrice
,
nbColonneMatrice
);
if
(
resTemp
)
res
=
true
;
}
}
free
(
voisins
);
return
res
;
}
bool
revelerCase
(
CelluleDemineur
**
matriceMines
,
int
line
,
int
column
,
int
nbLigneMatrice
,
int
nbColonneMatrice
){
bool
revelerCase
(
CelluleDemineur
**
matriceMines
,
int
line
,
int
column
,
int
nbLineMatrice
,
int
nbColumnMatrice
){
bool
res
=
false
;
if
(
!
matriceMines
[
line
][
column
]
->
i
f
Flagged
&&
!
matriceMines
[
line
][
column
]
->
isPressed
){
if
(
!
matriceMines
[
line
][
column
]
->
i
s
Flagged
&&
!
matriceMines
[
line
][
column
]
->
isPressed
){
matriceMines
[
line
][
column
]
->
isPressed
=
true
;
if
(
matriceMines
[
line
][
column
]
->
nearbyMine
==
0
){
matriceMines
[
line
][
column
]
->
couleurCase
=
LIGHTGRAY
;
res
=
revelerVoisins
(
line
,
column
,
matriceMines
,
nbLi
gneMatrice
,
nbColonne
Matrice
);
}
else
if
(
containsMine
(
line
,
column
,
matriceMines
)
){
res
=
revelerVoisins
(
line
,
column
,
matriceMines
,
nbLi
neMatrice
,
nbColumn
Matrice
);
}
else
if
(
matriceMines
[
line
][
column
]
->
isMine
){
matriceMines
[
line
][
column
]
->
couleurCase
=
MAROON
;
res
=
true
;
}
else
{
...
...
@@ -110,52 +133,25 @@ bool revelerCase(CelluleDemineur** matriceMines, int line, int column, int nbLig
return
res
;
}
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
++
){
while
(
containsMine
(
lineRand
,
colRand
,
matriceMines
)){
lineRand
=
rand
()
%
nbLigneMatrice
;
colRand
=
rand
()
%
nbColonneMatrice
;
}
matriceMines
[
lineRand
][
colRand
]
->
hasMine
=
true
;
matriceMines
[
lineRand
][
colRand
]
->
nearbyMine
=
-
9
;
incrementationVoisinMine
(
lineRand
,
colRand
,
matriceMines
,
nbLigneMatrice
,
nbColonneMatrice
);
}
}
void
initGrille
(
int
nbLigneMatrice
,
int
nbColonneMatrice
,
CelluleDemineur
**
matriceMines
){
int
screenHeight
=
GetScreenHeight
(),
screenWidth
=
GetScreenWidth
();
for
(
int
i
=
0
;
i
<
nbLigneMatrice
;
i
++
){
for
(
int
j
=
0
;
j
<
nbColonneMatrice
;
j
++
){
matriceMines
[
i
][
j
]
=
malloc
(
sizeof
(
struct
celluleDemineur
));
matriceMines
[
i
][
j
]
->
hasMine
=
false
;
matriceMines
[
i
][
j
]
->
isPressed
=
false
;
matriceMines
[
i
][
j
]
->
ifFlagged
=
false
;
matriceMines
[
i
][
j
]
->
isNeareast
=
false
;
matriceMines
[
i
][
j
]
->
nearbyMine
=
0
;
matriceMines
[
i
][
j
]
->
line
=
i
;
matriceMines
[
i
][
j
]
->
column
=
j
;
matriceMines
[
i
][
j
]
->
couleurCase
=
DARKGRAY
;
bool
revelerVoisins
(
int
line
,
int
column
,
CelluleDemineur
**
matriceMines
,
int
nbLineMatrice
,
int
nbColumnMatrice
){
CelluleDemineur
*
voisins
=
recupererVoisins
(
line
,
column
,
matriceMines
,
nbLineMatrice
,
nbColumnMatrice
);
bool
res
=
false
,
resTemp
;
if
(
i
%
2
==
0
){
matriceMines
[
i
][
j
]
->
pos
=
(
Vector2
){(
1
.
5
*
j
+
1
.
75
)
*
SIZE_OF_HEX
+
screenWidth
/
nbColonneMatrice
,
(
1
.
5
*
i
+
1
)
*
SIZE_OF_HEX
+
screenHeight
/
nbLigneMatrice
};
}
else
{
matriceMines
[
i
][
j
]
->
pos
=
(
Vector2
){(
1
.
5
*
j
+
1
)
*
SIZE_OF_HEX
+
screenWidth
/
nbColonneMatrice
,
(
1
.
5
*
i
+
1
)
*
SIZE_OF_HEX
+
screenHeight
/
nbLigneMatrice
};
}
for
(
int
i
=
0
;
i
<
6
;
i
++
){
if
(
voisins
[
i
]
!=
NULL
){
resTemp
=
revelerCase
(
matriceMines
,
voisins
[
i
]
->
line
,
voisins
[
i
]
->
column
,
nbLineMatrice
,
nbColumnMatrice
);
if
(
resTemp
)
res
=
true
;
}
}
free
(
voisins
);
return
res
;
}
float
getDistanceBetween
Points
(
Vector2
a
,
Vector2
b
)
{
float
distanceEntre
Points
(
Vector2
a
,
Vector2
b
)
{
return
(
a
.
x
-
b
.
x
)
*
(
a
.
x
-
b
.
x
)
+
(
a
.
y
-
b
.
y
)
*
(
a
.
y
-
b
.
y
);
}
int
main
(
void
)
{
// Initialization
...
...
@@ -167,17 +163,17 @@ int main(void)
srand
(
time
(
NULL
));
int
nbLi
gneMatrice
=
17
,
nbColonne
Matrice
=
21
,
nbMines
=
80
;
int
nbLi
neMatrice
=
17
,
nbColumn
Matrice
=
21
,
nbMines
=
80
;
int
curCaseX
=
0
,
curCaseY
=
0
,
flaggedMines
=
0
;
bool
lose
=
false
,
win
=
false
;
bool
lose
=
false
,
win
=
false
,
onTile
=
false
;
float
timeEllapsed
=
0
;
//CREATION DE LA MATRICE DES MINES
CelluleDemineur
**
matriceMines
=
malloc
(
nbLi
g
neMatrice
*
sizeof
(
CelluleDemineur
*
));
for
(
int
i
=
0
;
i
<
nbLi
g
neMatrice
;
i
++
)
matriceMines
[
i
]
=
calloc
(
nbLi
gneMatrice
*
nbColonne
Matrice
,
sizeof
(
CelluleDemineur
));
initGrille
(
nbLi
gneMatrice
,
nbColonne
Matrice
,
matriceMines
);
generationMines
(
nbMines
,
nbLi
gneMatrice
,
nbColonne
Matrice
,
matriceMines
);
CelluleDemineur
**
matriceMines
=
malloc
(
nbLineMatrice
*
sizeof
(
CelluleDemineur
*
));
for
(
int
i
=
0
;
i
<
nbLineMatrice
;
i
++
)
matriceMines
[
i
]
=
calloc
(
nbLi
neMatrice
*
nbColumn
Matrice
,
sizeof
(
CelluleDemineur
));
initGrille
(
nbLi
neMatrice
,
nbColumn
Matrice
,
matriceMines
);
generationMines
(
nbMines
,
nbLi
neMatrice
,
nbColumn
Matrice
,
matriceMines
);
//--------------------------------------------------------------------------------------
// Main game loop
...
...
@@ -185,17 +181,36 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
onTile
=
false
;
if
(
!
win
&&
!
lose
){
timeEllapsed
+=
GetFrameTime
();
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
lose
=
revelerCase
(
matriceMines
,
curCaseX
,
curCaseY
,
nbLigneMatrice
,
nbColonneMatrice
);
//RECUPERE LA TUILE SUR LAQUELLE SE TROUVE LA SOURIS
Vector2
mPos
=
GetMousePosition
();
for
(
int
i
=
0
;
i
<
nbLineMatrice
;
i
++
){
for
(
int
j
=
0
;
j
<
nbColumnMatrice
;
j
++
){
float
distanceCur
=
distanceEntrePoints
(
mPos
,
matriceMines
[
i
][
j
]
->
pos
);
if
(
distanceCur
<
SIZE_OF_HEX
*
SIZE_OF_HEX
/
2
){
matriceMines
[
i
][
j
]
->
isNeareast
=
true
;
curCaseX
=
matriceMines
[
i
][
j
]
->
line
;
curCaseY
=
matriceMines
[
i
][
j
]
->
column
;
onTile
=
true
;
}
else
{
matriceMines
[
i
][
j
]
->
isNeareast
=
false
;
}
}
}
if
(
IsMouseButtonPressed
(
MOUSE_RIGHT_BUTTON
)){
//GESTION DES INPUTS
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)
&&
onTile
){
lose
=
revelerCase
(
matriceMines
,
curCaseX
,
curCaseY
,
nbLineMatrice
,
nbColumnMatrice
);
}
if
(
IsMouseButtonPressed
(
MOUSE_RIGHT_BUTTON
)
&&
onTile
){
if
(
!
matriceMines
[
curCaseX
][
curCaseY
]
->
isPressed
){
matriceMines
[
curCaseX
][
curCaseY
]
->
i
fFlagged
=
!
matriceMines
[
curCaseX
][
curCaseY
]
->
if
Flagged
;
if
(
matriceMines
[
curCaseX
][
curCaseY
]
->
i
f
Flagged
){
matriceMines
[
curCaseX
][
curCaseY
]
->
i
sFlagged
=
!
matriceMines
[
curCaseX
][
curCaseY
]
->
is
Flagged
;
if
(
matriceMines
[
curCaseX
][
curCaseY
]
->
i
s
Flagged
){
matriceMines
[
curCaseX
][
curCaseY
]
->
couleurCase
=
GREEN
;
flaggedMines
++
;
}
...
...
@@ -206,40 +221,29 @@ int main(void)
}
}
if
(
IsMouseButtonPressed
(
MOUSE_MIDDLE_BUTTON
)){
lose
=
revelerCase
(
matriceMines
,
curCaseX
,
curCaseY
,
nbLi
gneMatrice
,
nbColonne
Matrice
);
lose
=
revelerVoisins
(
curCaseX
,
curCaseY
,
matriceMines
,
nbLi
gneMatrice
,
nbColonne
Matrice
);
if
(
IsMouseButtonPressed
(
MOUSE_MIDDLE_BUTTON
)
&&
onTile
){
lose
=
revelerCase
(
matriceMines
,
curCaseX
,
curCaseY
,
nbLi
neMatrice
,
nbColumn
Matrice
);
lose
=
revelerVoisins
(
curCaseX
,
curCaseY
,
matriceMines
,
nbLi
neMatrice
,
nbColumn
Matrice
);
}
}
else
{
//REGENERE LA GRILLE LORS DE LA VICTOIRE OU DE LA DEFAITE
if
(
IsKeyPressed
(
'R'
)){
lose
=
false
;
win
=
false
;
flaggedMines
=
0
;
timeEllapsed
=
0
;
initGrille
(
nbLigneMatrice
,
nbColonneMatrice
,
matriceMines
);
generationMines
(
nbMines
,
nbLigneMatrice
,
nbColonneMatrice
,
matriceMines
);
}
}
Vector2
mPos
=
GetMousePosition
();
for
(
int
i
=
0
;
i
<
nbLigneMatrice
;
i
++
){
for
(
int
j
=
0
;
j
<
nbColonneMatrice
;
j
++
){
float
distanceCur
=
getDistanceBetweenPoints
(
mPos
,
matriceMines
[
i
][
j
]
->
pos
);
if
(
distanceCur
<
SIZE_OF_HEX
*
SIZE_OF_HEX
/
2
){
matriceMines
[
i
][
j
]
->
isNeareast
=
true
;
curCaseX
=
matriceMines
[
i
][
j
]
->
line
;
curCaseY
=
matriceMines
[
i
][
j
]
->
column
;
}
else
{
matriceMines
[
i
][
j
]
->
isNeareast
=
false
;
}
initGrille
(
nbLineMatrice
,
nbColumnMatrice
,
matriceMines
);
generationMines
(
nbMines
,
nbLineMatrice
,
nbColumnMatrice
,
matriceMines
);
}
}
//TEST LA CONDITION DE VICTOIRE
if
(
flaggedMines
==
nbMines
){
int
trueFlagged
=
0
;
for
(
int
i
=
0
;
i
<
nbLi
g
neMatrice
;
i
++
){
for
(
int
j
=
0
;
j
<
nbCol
onne
Matrice
;
j
++
){
if
(
matriceMines
[
i
][
j
]
->
hasMine
&&
matriceMines
[
i
][
j
]
->
if
Flagged
)
trueFlagged
++
;
for
(
int
i
=
0
;
i
<
nbLineMatrice
;
i
++
){
for
(
int
j
=
0
;
j
<
nbCol
umn
Matrice
;
j
++
){
if
(
matriceMines
[
i
][
j
]
->
isMine
&&
matriceMines
[
i
][
j
]
->
is
Flagged
)
trueFlagged
++
;
}
}
...
...
@@ -253,8 +257,8 @@ int main(void)
ClearBackground
(
RAYWHITE
);
//AFFICHAGE DE LA GRILLE
for
(
int
i
=
0
;
i
<
nbLi
g
neMatrice
;
i
++
){
for
(
int
j
=
0
;
j
<
nbCol
onne
Matrice
;
j
++
){
for
(
int
i
=
0
;
i
<
nbLineMatrice
;
i
++
){
for
(
int
j
=
0
;
j
<
nbCol
umn
Matrice
;
j
++
){
DrawPoly
((
Vector2
){
matriceMines
[
i
][
j
]
->
pos
.
x
,
matriceMines
[
i
][
j
]
->
pos
.
y
},
6
,
SIZE_OF_HEX
,
0
,
GRAY
);
DrawPoly
((
Vector2
){
matriceMines
[
i
][
j
]
->
pos
.
x
,
matriceMines
[
i
][
j
]
->
pos
.
y
},
6
,
SIZE_OF_HEX
-
3
,
0
,
Fade
(
matriceMines
[
i
][
j
]
->
couleurCase
,
matriceMines
[
i
][
j
]
->
isNeareast
?
0
.
5
f
:
1
.
0
f
));
...
...
@@ -283,15 +287,18 @@ int main(void)
DrawText
(
"LIGHT GRAY - REVEALED"
,
930
,
420
,
18
,
LIGHTGRAY
);
DrawText
(
"GREEN - FLAGGED"
,
930
,
450
,
18
,
LIGHTGRAY
);
DrawText
(
"RED - MINE"
,
930
,
480
,
18
,
LIGHTGRAY
);
DrawText
(
"ORANGE - CORRECT FLAG"
,
930
,
510
,
18
,
LIGHTGRAY
);
//AFFICHAGE FIN DE PARTIE
if
(
lose
||
win
){
DrawRectangle
(
0
,
440
,
1280
,
100
,
Fade
(
GRAY
,
0
.
8
f
));
if
(
lose
){
DrawText
(
"GAME OVER"
,
500
,
465
,
35
,
MAROON
);
for
(
int
i
=
0
;
i
<
nbLigneMatrice
;
i
++
){
for
(
int
j
=
0
;
j
<
nbColonneMatrice
;
j
++
){
if
(
containsMine
(
i
,
j
,
matriceMines
))
revelerCase
(
matriceMines
,
i
,
j
,
nbLigneMatrice
,
nbColonneMatrice
);
for
(
int
i
=
0
;
i
<
nbLineMatrice
;
i
++
){
for
(
int
j
=
0
;
j
<
nbColumnMatrice
;
j
++
){
//REVELE L'EMPLACEMENT DES MINES NON DECOUVERTES
if
(
matriceMines
[
i
][
j
]
->
isMine
)
revelerCase
(
matriceMines
,
i
,
j
,
nbLineMatrice
,
nbColumnMatrice
);
if
(
matriceMines
[
i
][
j
]
->
isMine
&&
matriceMines
[
i
][
j
]
->
isFlagged
)
matriceMines
[
i
][
j
]
->
couleurCase
=
ORANGE
;
}
}
}
...
...
@@ -307,7 +314,7 @@ int main(void)
//--------------------------------------------------------------------------------------
CloseWindow
();
// Close window and OpenGL context
for
(
int
i
=
0
;
i
<
nbLi
g
neMatrice
;
i
++
)
for
(
int
i
=
0
;
i
<
nbLineMatrice
;
i
++
)
free
(
matriceMines
[
i
]);
free
(
matriceMines
);
//--------------------------------------------------------------------------------------
...
...
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