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
fb46b69a
Commit
fb46b69a
authored
Oct 31, 2020
by
Erwan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code: Non adaptable aux différentes résolutions
Readme: Ajout de la descripton du jeu
parent
8badac28
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
54 deletions
+66
-54
README.md
README.md
+13
-0
minesweeper.c
minesweeper.c
+53
-54
No files found.
README.md
View file @
fb46b69a
...
...
@@ -10,7 +10,20 @@ Implémentation d'un démineur via la bibliothèque Raylib
**Lancer le projet :**
**Commandes et objectifs :**
A l'aide de la souris et de ses 3 boutons :
-
Gauche: Révéler la case sélectionnée
-
Droite: Marquer la case comme possédant une mine
(peremt de ne pas la déclencher et est nécessaire pour gagner)
-
Milieu: Révèle toutes les cases autour
Le but du jeu est de marquer toutes les cases possédant des mines le plus rapidement possible.
Les chiffres sur les cases indiquent le nombre de mines autour.
Une case à 0 révèle toutes les cases autout.
**Description fichiers :**
*minesweeper.c*
:
Contient le main du projet et la description des fonctions qui font fonctionner le jeu.
***Bilan sur le projet :**
*
-
Grande difficulté de faire un affichage adaptable à toutes les résolutions car il prend beaucoup de paramètre dans mon cas
(les tailles de la grille en plus de la taille de la fenetre)
\ No newline at end of file
minesweeper.c
View file @
fb46b69a
...
...
@@ -144,9 +144,9 @@ void initGrille(int nbLigneMatrice, int nbColonneMatrice, CelluleDemineur** matr
matriceMines
[
i
][
j
]
->
couleurCase
=
DARKGRAY
;
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
};
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
};
matriceMines
[
i
][
j
]
->
pos
=
(
Vector2
){(
1
.
5
*
j
+
1
)
*
SIZE_OF_HEX
+
screenWidth
/
nbColonneMatrice
,
(
1
.
5
*
i
+
1
)
*
SIZE_OF_HEX
+
screenHeight
/
nbLigneMatrice
};
}
}
}
...
...
@@ -162,7 +162,6 @@ int main(void)
//--------------------------------------------------------------------------------------
const
int
screenWidth
=
1280
;
const
int
screenHeight
=
800
;
int
fontSizeSmall
=
screenWidth
*
screenHeight
/
35000
;
InitWindow
(
screenWidth
,
screenHeight
,
"HexaSweeper - Erwan MERLY"
);
SetTargetFPS
(
60
);
...
...
@@ -186,29 +185,40 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
if
(
!
win
&&
!
lose
)
timeEllapsed
+=
GetFrameTime
();
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)
&&
!
lose
&&
!
win
){
lose
=
revelerCase
(
matriceMines
,
curCaseX
,
curCaseY
,
nbLigneMatrice
,
nbColonneMatrice
);
}
if
(
IsMouseButtonPressed
(
MOUSE_RIGHT_BUTTON
)
&&
!
lose
&&
!
win
){
if
(
!
matriceMines
[
curCaseX
][
curCaseY
]
->
isPressed
){
matriceMines
[
curCaseX
][
curCaseY
]
->
ifFlagged
=
!
matriceMines
[
curCaseX
][
curCaseY
]
->
ifFlagged
;
if
(
matriceMines
[
curCaseX
][
curCaseY
]
->
ifFlagged
){
matriceMines
[
curCaseX
][
curCaseY
]
->
couleurCase
=
GREEN
;
flaggedMines
++
;
}
else
{
matriceMines
[
curCaseX
][
curCaseY
]
->
couleurCase
=
DARKGRAY
;
flaggedMines
--
;
if
(
!
win
&&
!
lose
){
timeEllapsed
+=
GetFrameTime
();
if
(
IsMouseButtonPressed
(
MOUSE_LEFT_BUTTON
)){
lose
=
revelerCase
(
matriceMines
,
curCaseX
,
curCaseY
,
nbLigneMatrice
,
nbColonneMatrice
);
}
if
(
IsMouseButtonPressed
(
MOUSE_RIGHT_BUTTON
)){
if
(
!
matriceMines
[
curCaseX
][
curCaseY
]
->
isPressed
){
matriceMines
[
curCaseX
][
curCaseY
]
->
ifFlagged
=
!
matriceMines
[
curCaseX
][
curCaseY
]
->
ifFlagged
;
if
(
matriceMines
[
curCaseX
][
curCaseY
]
->
ifFlagged
){
matriceMines
[
curCaseX
][
curCaseY
]
->
couleurCase
=
GREEN
;
flaggedMines
++
;
}
else
{
matriceMines
[
curCaseX
][
curCaseY
]
->
couleurCase
=
DARKGRAY
;
flaggedMines
--
;
}
}
}
}
if
(
IsMouseButtonPressed
(
MOUSE_MIDDLE_BUTTON
)
&&
!
lose
&&
!
win
){
lose
=
revelerCase
(
matriceMines
,
curCaseX
,
curCaseY
,
nbLigneMatrice
,
nbColonneMatrice
);
lose
=
revelerVoisins
(
curCaseX
,
curCaseY
,
matriceMines
,
nbLigneMatrice
,
nbColonneMatrice
);
if
(
IsMouseButtonPressed
(
MOUSE_MIDDLE_BUTTON
)){
lose
=
revelerCase
(
matriceMines
,
curCaseX
,
curCaseY
,
nbLigneMatrice
,
nbColonneMatrice
);
lose
=
revelerVoisins
(
curCaseX
,
curCaseY
,
matriceMines
,
nbLigneMatrice
,
nbColonneMatrice
);
}
}
else
{
if
(
IsKeyPressed
(
'R'
)){
lose
=
false
;
win
=
false
;
flaggedMines
=
0
;
timeEllapsed
=
0
;
initGrille
(
nbLigneMatrice
,
nbColonneMatrice
,
matriceMines
);
generationMines
(
nbMines
,
nbLigneMatrice
,
nbColonneMatrice
,
matriceMines
);
}
}
Vector2
mPos
=
GetMousePosition
();
...
...
@@ -236,17 +246,6 @@ int main(void)
if
(
trueFlagged
==
nbMines
)
win
=
true
;
}
if
(
win
||
lose
){
if
(
IsKeyPressed
(
'R'
)){
lose
=
false
;
win
=
false
;
flaggedMines
=
0
;
timeEllapsed
=
0
;
initGrille
(
nbLigneMatrice
,
nbColonneMatrice
,
matriceMines
);
generationMines
(
nbMines
,
nbLigneMatrice
,
nbColonneMatrice
,
matriceMines
);
}
}
// Draw
//----------------------------------------------------------------------------------
BeginDrawing
();
...
...
@@ -265,39 +264,39 @@ 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
,
35
,
GRAY
);
DrawText
(
TextFormat
(
"Time: %d s"
,
(
int
)
timeEllapsed
),
screenWidth
-
250
,
screenHeight
-
50
,
35
,
GRAY
);
DrawRectangle
(
0
,
725
,
1280
,
75
,
Fade
(
LIGHTGRAY
,
0
.
5
f
));
DrawText
(
TextFormat
(
"MINE FLAGGED: %d/%d"
,
flaggedMines
,
nbMines
),
50
,
7
50
,
35
,
GRAY
);
DrawText
(
TextFormat
(
"Time: %d s"
,
(
int
)
timeEllapsed
),
1030
,
7
50
,
35
,
GRAY
);
//AFFICHAGE CONTROLES ET REGLES
DrawText
(
"CONTROLS"
,
screenWidth
-
27
5
,
50
,
35
,
DARKGRAY
);
DrawText
(
"LEFT CLICK - REVEAL TILE"
,
screenWidth
-
35
0
,
100
,
18
,
LIGHTGRAY
);
DrawText
(
"RIGHT CLICK - FLAG TILE"
,
screenWidth
-
35
0
,
130
,
18
,
LIGHTGRAY
);
DrawText
(
"MIDDLE CLICK - REVEAL NEIGHBOURS"
,
screenWidth
-
35
0
,
160
,
18
,
LIGHTGRAY
);
DrawText
(
"CONTROLS"
,
100
5
,
50
,
35
,
DARKGRAY
);
DrawText
(
"LEFT CLICK - REVEAL TILE"
,
93
0
,
100
,
18
,
LIGHTGRAY
);
DrawText
(
"RIGHT CLICK - FLAG TILE"
,
93
0
,
130
,
18
,
LIGHTGRAY
);
DrawText
(
"MIDDLE CLICK - REVEAL NEIGHBOURS"
,
93
0
,
160
,
18
,
LIGHTGRAY
);
DrawText
(
"RULES"
,
screenWidth
-
27
5
,
210
,
35
,
DARKGRAY
);
DrawText
(
"NUMBER INDICATE MINES AROUND"
,
screenWidth
-
35
0
,
260
,
18
,
LIGHTGRAY
);
DrawText
(
"FLAG ALL THE MINES TO WIN"
,
screenWidth
-
35
0
,
290
,
18
,
LIGHTGRAY
);
DrawText
(
"RULES"
,
100
5
,
210
,
35
,
DARKGRAY
);
DrawText
(
"NUMBER INDICATE MINES AROUND"
,
93
0
,
260
,
18
,
LIGHTGRAY
);
DrawText
(
"FLAG ALL THE MINES TO WIN"
,
93
0
,
290
,
18
,
LIGHTGRAY
);
DrawText
(
"TILES"
,
screenWidth
-
27
5
,
340
,
35
,
DARKGRAY
);
DrawText
(
"DARK GRAY - NON REVEALED"
,
screenWidth
-
35
0
,
390
,
18
,
LIGHTGRAY
);
DrawText
(
"LIGHT GRAY - REVEALED"
,
screenWidth
-
35
0
,
420
,
18
,
LIGHTGRAY
);
DrawText
(
"GREEN - FLAGGED"
,
screenWidth
-
35
0
,
450
,
18
,
LIGHTGRAY
);
DrawText
(
"RED - MINE"
,
screenWidth
-
35
0
,
480
,
18
,
LIGHTGRAY
);
DrawText
(
"TILES"
,
100
5
,
340
,
35
,
DARKGRAY
);
DrawText
(
"DARK GRAY - NON REVEALED"
,
93
0
,
390
,
18
,
LIGHTGRAY
);
DrawText
(
"LIGHT GRAY - REVEALED"
,
93
0
,
420
,
18
,
LIGHTGRAY
);
DrawText
(
"GREEN - FLAGGED"
,
93
0
,
450
,
18
,
LIGHTGRAY
);
DrawText
(
"RED - MINE"
,
93
0
,
480
,
18
,
LIGHTGRAY
);
//AFFICHAGE FIN DE PARTIE
if
(
lose
||
win
){
DrawRectangle
(
0
,
screenHeight
*
0
.
55
,
screenWidth
,
screenHeight
/
8
,
Fade
(
GRAY
,
0
.
8
f
));
DrawRectangle
(
0
,
440
,
1280
,
100
,
Fade
(
GRAY
,
0
.
8
f
));
if
(
lose
){
DrawText
(
"GAME OVER"
,
screenWidth
/
2
-
strlen
(
"GAME OVER"
)
/
2
*
35
,
screenHeight
*
0
.
58
,
35
,
MAROON
);
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
);
}
}
}
if
(
win
)
DrawText
(
"YOU WIN!"
,
screenWidth
/
2
-
strlen
(
"YOU WIN!"
)
/
2
*
35
,
screenHeight
*
0
.
57
,
35
,
LIME
);
DrawText
(
"PRESS R TO REPLAY"
,
screenWidth
/
2
-
strlen
(
"PRESS R TO REPLAY"
)
/
2
*
30
,
screenHeight
*
0
.
62
,
30
,
DARKGRAY
);
if
(
win
)
DrawText
(
"YOU WIN!"
,
500
,
465
,
35
,
LIME
);
DrawText
(
"PRESS R TO REPLAY"
,
500
,
495
,
30
,
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