Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Fardale
Prog2
Commits
40553e57
Commit
40553e57
authored
Mar 27, 2015
by
Fardale
Browse files
ça plante je push pas
parent
7160c234
Changes
3
Hide whitespace changes
Inline
Side-by-side
boum.scala
View file @
40553e57
...
...
@@ -32,7 +32,7 @@ class Demineur extends Jeu[MonBouton] {
// private var champ = ofDim[Int](tailleX,tailleY)
// Matrice des boutons associés aux cases (il me semble plus pertinent de l'inclure dans le jeu).
protected
var
boutons
=
ofDim
[
MonBouton
](
tailleX
,
tailleY
)
override
protected
var
boutons
=
ofDim
[
MonBouton
](
tailleX
,
tailleY
)
// Réinitialise les paramètres ci-dessus en cas de changement de difficulté.
def
reparametrage
(
x
:
Int
,
y
:
Int
,
n
:
Int
)
=
{
...
...
@@ -144,30 +144,10 @@ class Demineur extends Jeu[MonBouton] {
if
(
premierCoup
){
premierCoup
=
false
}
if
(
x
>
0
)
{
if
(
boutons
(
x
-
1
)(
y
).
estLibre
&&
!
boutons
(
x
-
1
)(
y
).
mines
){
clique_action
(
x
-
1
,
y
)}
if
(
y
>
0
){
if
(
boutons
(
x
-
1
)(
y
-
1
).
estLibre
&&
!
boutons
(
x
-
1
)(
y
-
1
).
mines
){
clique_action
(
x
-
1
,
y
-
1
)}
}
if
(
y
<
tailleY
-
1
){
if
(
boutons
(
x
-
1
)(
y
+
1
).
estLibre
&&
!
boutons
(
x
-
1
)(
y
+
1
).
mines
){
clique_action
(
x
-
1
,
y
+
1
)}
}
}
if
(
x
<
tailleX
-
1
)
{
if
(
boutons
(
x
+
1
)(
y
).
estLibre
&&
!
boutons
(
x
+
1
)(
y
).
mines
){
clique_action
(
x
+
1
,
y
)}
if
(
y
>
0
){
if
(
boutons
(
x
+
1
)(
y
-
1
).
estLibre
&&
!
boutons
(
x
+
1
)(
y
-
1
).
mines
){
clique_action
(
x
+
1
,
y
-
1
)}
}
if
(
y
<
tailleY
-
1
){
if
(
boutons
(
x
+
1
)(
y
+
1
).
estLibre
&&
!
boutons
(
x
+
1
)(
y
+
1
).
mines
){
clique_action
(
x
+
1
,
y
+
1
)}
}
}
if
(
y
>
0
){
if
(
boutons
(
x
)(
y
-
1
).
estLibre
&&
!
boutons
(
x
)(
y
-
1
).
mines
){
clique_action
(
x
,
y
-
1
)}
}
if
(
y
<
tailleY
-
1
){
if
(
boutons
(
x
)(
y
+
1
).
estLibre
&&
!
boutons
(
x
)(
y
+
1
).
mines
){
clique_action
(
x
,
y
+
1
)}
}
var
voisin
=
voisinEtendu
(
x
,
y
)
for
(
plop
<-
voisin
)
{
var
(
vx
,
vy
)
=
plop
if
(
boutons
(
vx
)(
vy
).
estLibre
&&
!
boutons
(
vx
)(
vy
).
mines
){
clique_action
(
vx
,
vy
)}}
}
}
...
...
boutons.scala
View file @
40553e57
...
...
@@ -29,3 +29,5 @@ class MonBouton(protected var x : Int, protected var y : Int) extends Button {
libre
=
true
drapeau
=
false
}
jeu.scala
View file @
40553e57
...
...
@@ -21,5 +21,33 @@ abstract class Jeu[T<:Button] {
}
def
victoire
()
:
Boolean
def
voisinDirect
(
x
:
Int
,
y
:
Int
){
var
voisin
=
List
[(
Int
,
Int
)]()
if
(
x
>
0
){
voisin
=
(
x
-
1
,
y
)
::
voisin
}
if
(
x
<
tailleX
){
voisin
=
(
x
+
1
,
y
)
::
voisin
}
if
(
x
>
0
){
voisin
=
(
x
,
y
-
1
)
::
voisin
}
if
(
x
<
tailleY
){
voisin
=
(
x
,
y
+
1
)
::
voisin
}
voisin
}
def
voisinEtendu
(
x
:
Int
,
y
:
Int
){
var
voisin
=
List
[(
Int
,
Int
)]()
if
(
x
>
0
){
voisin
=
(
x
-
1
,
y
)
::
voisin
if
(
y
>
0
){
voisin
==
(
x
-
1
,
y
-
1
)
::
voisin
}
if
(
y
<
tailleY
){
voisin
==
(
x
-
1
,
y
+
1
)
::
voisin
}
}
if
(
x
<
tailleX
){
voisin
=
(
x
+
1
,
y
)
::
voisin
if
(
y
>
0
){
voisin
==
(
x
+
1
,
y
-
1
)
::
voisin
}
if
(
y
<
tailleY
){
voisin
==
(
x
+
1
,
y
+
1
)
::
voisin
}
}
if
(
y
>
0
){
voisin
=
(
x
,
y
-
1
)
::
voisin
}
if
(
y
<
tailleY
){
voisin
=
(
x
,
y
+
1
)
::
voisin
}
voisin
}
}
Write
Preview
Supports
Markdown
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