Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Labyrinthe-Perdu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Gambirasio
Labyrinthe-Perdu
Commits
35dd5176
Commit
35dd5176
authored
1 year ago
by
HydroFlo
Browse files
Options
Downloads
Patches
Plain Diff
ajout commentaire
parent
84697c42
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
S1.02/Jeu/src/Labyrinthe.java
+13
-14
13 additions, 14 deletions
S1.02/Jeu/src/Labyrinthe.java
with
13 additions
and
14 deletions
S1.02/Jeu/src/Labyrinthe.java
+
13
−
14
View file @
35dd5176
...
@@ -101,7 +101,7 @@ class Labyrinthe extends Program{
...
@@ -101,7 +101,7 @@ class Labyrinthe extends Program{
return
lab
;
return
lab
;
}
}
String
veriferVoisins
(
Salle
[][]
lab
,
int
i
,
int
j
){
String
veriferVoisins
(
Salle
[][]
lab
,
int
i
,
int
j
){
//renvoie les voisins d'une salle
String
resultat
=
""
;
String
resultat
=
""
;
if
(
i
<
length
(
lab
,
1
)
&&
i
>=
1
&&
lab
[
i
-
1
][
j
]!=
null
){
if
(
i
<
length
(
lab
,
1
)
&&
i
>=
1
&&
lab
[
i
-
1
][
j
]!=
null
){
resultat
=
resultat
+
lab
[
i
-
1
][
j
].
sorties
;
resultat
=
resultat
+
lab
[
i
-
1
][
j
].
sorties
;
...
@@ -115,11 +115,10 @@ class Labyrinthe extends Program{
...
@@ -115,11 +115,10 @@ class Labyrinthe extends Program{
if
(
j
<
length
(
lab
,
2
)&&
j
>=
1
&&
lab
[
i
][
j
-
1
]!=
null
){
if
(
j
<
length
(
lab
,
2
)&&
j
>=
1
&&
lab
[
i
][
j
-
1
]!=
null
){
resultat
=
resultat
+
lab
[
i
][
j
-
1
].
sorties
;
resultat
=
resultat
+
lab
[
i
][
j
-
1
].
sorties
;
}
else
{
resultat
=
resultat
+
"...."
;}
}
else
{
resultat
=
resultat
+
"...."
;}
//println(resultat);
return
(
resultat
);
return
(
resultat
);
}
}
void
choisirSalle
(
Salle
[][]
lab
,
int
i
,
int
j
){
void
choisirSalle
(
Salle
[][]
lab
,
int
i
,
int
j
){
//Choisie la salle à placer
String
resultat
=
""
;
String
resultat
=
""
;
String
check
=
veriferVoisins
(
lab
,
i
,
j
);
String
check
=
veriferVoisins
(
lab
,
i
,
j
);
String
haut
=
substring
(
check
,
0
,
4
);
String
haut
=
substring
(
check
,
0
,
4
);
...
@@ -189,7 +188,7 @@ class Labyrinthe extends Program{
...
@@ -189,7 +188,7 @@ class Labyrinthe extends Program{
}
}
}
}
String
choixAlea
(
String
chaine
){
String
choixAlea
(
String
chaine
){
//Choisie aléatoirement les salles du labyrinthe
for
(
int
a
=
0
;
a
<
4
;
a
++){
for
(
int
a
=
0
;
a
<
4
;
a
++){
if
(
charAt
(
chaine
,
a
)==
'.'
){
if
(
charAt
(
chaine
,
a
)==
'.'
){
chaine
=
substring
(
chaine
,
0
,
a
)+(
int
)(
random
()*
2
)+
substring
(
chaine
,
a
+
1
,
length
(
chaine
));
chaine
=
substring
(
chaine
,
0
,
a
)+(
int
)(
random
()*
2
)+
substring
(
chaine
,
a
+
1
,
length
(
chaine
));
...
@@ -212,14 +211,14 @@ class Labyrinthe extends Program{
...
@@ -212,14 +211,14 @@ class Labyrinthe extends Program{
return
(
lab
);
return
(
lab
);
}
}
void
afficheHelp
(){
void
afficheHelp
(){
//affiche les contrôle du jeu
print
(
readFile
(
"ressources/img/Help"
,
true
));
print
(
readFile
(
"ressources/img/Help"
,
true
));
println
(
"A tout moment dans la partie, appuyer sur \"H\" pour réafficher ce menu"
);
println
(
"A tout moment dans la partie, appuyer sur \"H\" pour réafficher ce menu"
);
println
();
println
();
readString
();
readString
();
}
}
int
[]
changeSalle
(
char
[][]
Lab
,
int
positionL
,
int
positionC
,
int
[]
indiceSalle
){
int
[]
changeSalle
(
char
[][]
Lab
,
int
positionL
,
int
positionC
,
int
[]
indiceSalle
){
//renvoie la salle dans laquelle le joueur doit arriver
if
(
positionC
==
1
){
if
(
positionC
==
1
){
indiceSalle
[
1
]
-=
1
;
indiceSalle
[
1
]
-=
1
;
return
new
int
[]{
9
,
length
(
Lab
,
2
)-
3
};
return
new
int
[]{
9
,
length
(
Lab
,
2
)-
3
};
...
@@ -244,7 +243,7 @@ class Labyrinthe extends Program{
...
@@ -244,7 +243,7 @@ class Labyrinthe extends Program{
afficheHelp
();
afficheHelp
();
}
}
if
(
direction
==
'z'
&&
positionL
-
1
>=
0
&&
Lab
[
positionL
-
1
][
positionC
]
!=
'@'
){
//déplacement haut
if
(
direction
==
'z'
&&
positionL
-
1
>=
0
&&
Lab
[
positionL
-
1
][
positionC
]
!=
'@'
){
//déplacement
vers le
haut
if
(
Lab
[
positionL
-
1
][
positionC
]
==
'.'
){
//déplacement si case vide
if
(
Lab
[
positionL
-
1
][
positionC
]
==
'.'
){
//déplacement si case vide
Lab
[
positionL
][
positionC
]
=
'.'
;
Lab
[
positionL
][
positionC
]
=
'.'
;
Lab
[
positionL
-
1
][
positionC
]
=
'P'
;
Lab
[
positionL
-
1
][
positionC
]
=
'P'
;
...
@@ -268,7 +267,7 @@ class Labyrinthe extends Program{
...
@@ -268,7 +267,7 @@ class Labyrinthe extends Program{
}
}
}
}
if
(
direction
==
's'
&&
positionL
+
1
<
length
(
Lab
,
1
)
&&
Lab
[
positionL
+
1
][
positionC
]
!=
'@'
){
//déplacement bas
if
(
direction
==
's'
&&
positionL
+
1
<
length
(
Lab
,
1
)
&&
Lab
[
positionL
+
1
][
positionC
]
!=
'@'
){
//déplacement
vers le
bas
if
(
Lab
[
positionL
+
1
][
positionC
]
==
'.'
){
//déplacement si case vide
if
(
Lab
[
positionL
+
1
][
positionC
]
==
'.'
){
//déplacement si case vide
Lab
[
positionL
][
positionC
]
=
'.'
;
Lab
[
positionL
][
positionC
]
=
'.'
;
Lab
[
positionL
+
1
][
positionC
]
=
'P'
;
Lab
[
positionL
+
1
][
positionC
]
=
'P'
;
...
@@ -292,7 +291,7 @@ class Labyrinthe extends Program{
...
@@ -292,7 +291,7 @@ class Labyrinthe extends Program{
}
}
}
}
if
(
direction
==
'q'
&&
positionC
-
1
>=
0
&&
Lab
[
positionL
][
positionC
-
1
]
!=
'@'
){
//déplacement gauche
if
(
direction
==
'q'
&&
positionC
-
1
>=
0
&&
Lab
[
positionL
][
positionC
-
1
]
!=
'@'
){
//déplacement
vers la
gauche
if
(
Lab
[
positionL
][
positionC
-
1
]
==
'.'
){
//déplacement si case vide
if
(
Lab
[
positionL
][
positionC
-
1
]
==
'.'
){
//déplacement si case vide
Lab
[
positionL
][
positionC
]
=
'.'
;
Lab
[
positionL
][
positionC
]
=
'.'
;
Lab
[
positionL
][
positionC
-
1
]
=
'P'
;
Lab
[
positionL
][
positionC
-
1
]
=
'P'
;
...
@@ -316,7 +315,7 @@ class Labyrinthe extends Program{
...
@@ -316,7 +315,7 @@ class Labyrinthe extends Program{
}
}
}
}
if
(
direction
==
'd'
&&
positionC
+
1
<
length
(
Lab
,
2
)
&&
Lab
[
positionL
][
positionC
+
1
]
!=
'@'
){
//déplacement droite
if
(
direction
==
'd'
&&
positionC
+
1
<
length
(
Lab
,
2
)
&&
Lab
[
positionL
][
positionC
+
1
]
!=
'@'
){
//déplacement
vers la
droite
if
(
Lab
[
positionL
][
positionC
+
1
]
==
'.'
){
//déplacement si case vide
if
(
Lab
[
positionL
][
positionC
+
1
]
==
'.'
){
//déplacement si case vide
Lab
[
positionL
][
positionC
]
=
'.'
;
Lab
[
positionL
][
positionC
]
=
'.'
;
Lab
[
positionL
][
positionC
+
1
]
=
'P'
;
Lab
[
positionL
][
positionC
+
1
]
=
'P'
;
...
@@ -343,7 +342,7 @@ class Labyrinthe extends Program{
...
@@ -343,7 +342,7 @@ class Labyrinthe extends Program{
return
new
int
[]{
positionL
,
positionC
};
return
new
int
[]{
positionL
,
positionC
};
}
}
void
updateBoss
(
Question
q
,
Joueur
j
){
void
updateBoss
(
Question
q
,
Joueur
j
){
//Ajoute 30 pts au joueur et met fin au jeu s'il bat un boss, sinon lui enlève 10 pv
if
(
questionCorrect
(
q
)){
//En cas de bonne réponse ajoute 30 au score et indique que le boss est vaincu
if
(
questionCorrect
(
q
)){
//En cas de bonne réponse ajoute 30 au score et indique que le boss est vaincu
j
.
aJouee
=
true
;
j
.
aJouee
=
true
;
j
.
bossVaincu
=
true
;
j
.
bossVaincu
=
true
;
...
@@ -353,12 +352,12 @@ class Labyrinthe extends Program{
...
@@ -353,12 +352,12 @@ class Labyrinthe extends Program{
}
}
}
}
void
perteHP
(
Joueur
j
){
void
perteHP
(
Joueur
j
){
//fait perdre 10 pv au joueur et indique qu'il a joué
j
.
vie
-=
10
;
j
.
vie
-=
10
;
j
.
aJouee
=
true
;
j
.
aJouee
=
true
;
}
}
void
addScoreMonstre
(
Joueur
j
){
void
addScoreMonstre
(
Joueur
j
){
//Ajoute 1 au score en cas de victoire contre un monstre et indique qu'il a joué
j
.
score
+=
1
;
j
.
score
+=
1
;
j
.
aJouee
=
true
;
j
.
aJouee
=
true
;
}
}
...
@@ -474,7 +473,7 @@ class Labyrinthe extends Program{
...
@@ -474,7 +473,7 @@ class Labyrinthe extends Program{
}
}
void
afficheScore
(){
void
afficheScore
(){
//Affiche le tableau des scores
String
[][]
file
=
load
(
"ressources/score.csv"
);
String
[][]
file
=
load
(
"ressources/score.csv"
);
print
(
readFile
(
"ressources/img/Score.txt"
,
true
));
print
(
readFile
(
"ressources/img/Score.txt"
,
true
));
for
(
int
i
=
1
;
i
<
length
(
file
,
1
);
i
++){
for
(
int
i
=
1
;
i
<
length
(
file
,
1
);
i
++){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment