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
2f69a3df
Commit
2f69a3df
authored
Oct 31, 2020
by
Erwan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout du timer (incrémentation que lors du jeu)
parent
3d9ce1c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
minesweeper.c
minesweeper.c
+9
-1
No files found.
minesweeper.c
View file @
2f69a3df
...
...
@@ -172,6 +172,7 @@ int main(void)
int
nbLigneMatrice
=
17
,
nbColonneMatrice
=
21
,
nbMines
=
80
;
int
curCaseX
=
0
,
curCaseY
=
0
,
flaggedMines
=
0
;
bool
lose
=
false
,
win
=
false
;
float
timeEllapsed
=
0
;
//CREATION DE LA MATRICE DES MINES
CelluleDemineur
**
matriceMines
=
malloc
(
nbLigneMatrice
*
sizeof
(
CelluleDemineur
*
));
...
...
@@ -186,6 +187,8 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
if
(
!
win
&&
!
lose
)
timeEllapsed
+=
GetFrameTime
();
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)
&&
!
lose
&&
!
win
){
lose
=
revelerCase
(
matriceMines
,
curCaseX
,
curCaseY
,
nbLigneMatrice
,
nbColonneMatrice
);
}
...
...
@@ -239,6 +242,7 @@ int main(void)
lose
=
false
;
win
=
false
;
flaggedMines
=
0
;
timeEllapsed
=
0
;
initGrille
(
nbLigneMatrice
,
nbColonneMatrice
,
matriceMines
);
generationMines
(
nbMines
,
nbLigneMatrice
,
nbColonneMatrice
,
matriceMines
);
}
...
...
@@ -250,6 +254,7 @@ int main(void)
ClearBackground
(
RAYWHITE
);
//AFFICHAGE DE LA GRILLE
for
(
int
i
=
0
;
i
<
nbLigneMatrice
;
i
++
){
for
(
int
j
=
0
;
j
<
nbColonneMatrice
;
j
++
){
DrawPoly
((
Vector2
){
matriceMines
[
i
][
j
]
->
pos
.
x
,
matriceMines
[
i
][
j
]
->
pos
.
y
},
6
,
SIZE_OF_HEX
,
0
,
GRAY
);
...
...
@@ -260,9 +265,12 @@ int main(void)
}
}
//AFFICHAGE DE L'INTERFACE
DrawRectangle
(
0
,
screenHeight
-
75
,
screenWidth
,
75
,
Fade
(
LIGHTGRAY
,
0
.
5
f
));
DrawText
(
TextFormat
(
"MINE FLAGGED: %d/%d"
,
flaggedMines
,
nbMines
),
50
,
screenHeight
-
50
,
fontSizeBig
,
GRAY
);
DrawText
(
TextFormat
(
"Time: %d s"
,
(
int
)
timeEllapsed
),
screenWidth
-
250
,
screenHeight
-
50
,
fontSizeBig
,
GRAY
);
//AFFICHAGE FIN DE PARTIE
if
(
lose
||
win
){
DrawRectangle
(
0
,
screenHeight
*
0
.
55
,
screenWidth
,
screenHeight
/
8
,
Fade
(
GRAY
,
0
.
8
f
));
if
(
lose
){
...
...
@@ -276,7 +284,7 @@ int main(void)
if
(
win
)
DrawText
(
"YOU WIN!"
,
screenWidth
/
2
-
strlen
(
"YOU WIN!"
)
/
2
*
fontSizeBig
,
screenHeight
*
0
.
57
,
fontSizeBig
,
LIME
);
DrawText
(
"PRESS R TO REPLAY"
,
screenWidth
/
2
-
strlen
(
"PRESS R TO REPLAY"
)
/
2
*
fontSizeSmall
,
screenHeight
*
0
.
62
,
fontSizeSmall
,
DARKGRAY
);
}
EndDrawing
();
//----------------------------------------------------------------------------------
}
...
...
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