Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Théo BOUTEMY
siam
Commits
04d6a904
Commit
04d6a904
authored
May 06, 2021
by
Pauline LEYRIT
Browse files
oui
parent
b3b46e72
Changes
2
Hide whitespace changes
Inline
Side-by-side
Monappli.py
View file @
04d6a904
...
...
@@ -14,11 +14,10 @@ from table_de_jeu import Plateau
class
MonAppli
(
QtWidgets
.
QMainWindow
):
def
__init__
(
self
):
super
().
__init__
()
self
.
ui
=
Ui_Siam
()
self
.
ui
.
setupUi
(
self
)
self
.
ui
=
uic
.
loadUi
(
'C:/Users/33651/siam1/siam.ui'
,
self
)
self
.
painter
=
QtGui
.
QPainter
()
self
.
ui
.
plateau
.
paintEvent
=
self
.
drawPlateau
# "dessine_moi" se traduit par paintEvent
self
.
ui
.
plateau
.
paintEvent
=
self
.
paintEvent
# "dessine_moi" se traduit par paintEvent
#self.resize(9,9)
self
.
ui
.
bouton_pousser
.
clicked
.
connect
(
self
.
pousser
)
self
.
ui
.
bouton_entrer
.
clicked
.
connect
(
self
.
entrer
)
...
...
@@ -30,11 +29,11 @@ class MonAppli(QtWidgets.QMainWindow):
self
.
jeux
=
Plateau
(
xmax
=
self
.
ui
.
plateau
.
width
(),
ymax
=
self
.
ui
.
plateau
.
height
(),
nb_montagne
=
3
,
joueur1
=
'Theo'
,
joueur2
=
'Pauline'
)
pixmap
=
QtGui
.
QPixmap
(
"plateau
.jpg
"
)
pixmap
=
QtGui
.
QPixmap
(
"plateau
9x7.PNG
"
)
pal
=
QtGui
.
QPalette
()
pal
.
setBrush
(
QtGui
.
QPalette
.
Background
,
QtGui
.
QBrush
(
pixmap
))
self
.
ui
.
plateau
.
lower
()
self
.
ui
.
plateau
.
stackUnder
(
self
)
#
self.ui.plateau.lower()
#
self.ui.plateau.stackUnder(self)
self
.
ui
.
plateau
.
setAutoFillBackground
(
True
)
self
.
ui
.
plateau
.
setPalette
(
pal
)
...
...
@@ -69,16 +68,41 @@ class MonAppli(QtWidgets.QMainWindow):
self
.
ui
.
plateau
.
update
()
self
.
plateau
.
jouer
()
def
mousePressEvent
(
self
,
e
):
largeur_case
=
self
.
ui
.
plateau
.
width
()
//
9
hauteur_case
=
self
.
ui
.
plateau
.
height
()
//
7
# Les coordonnées du point cliqué sont e.x() et e.y()
# Transformation des coordonnées écran en coordonnées dans
# le plateau de jeu
j
=
e
.
x
()
//
largeur_case
-
4
i
=
e
.
y
()
//
hauteur_case
-
2
# Vérification
print
(
'Vous avez cliqué sur la case : '
,
(
i
,
j
))
if
e
.
button
()
==
QtGui
.
LeftButton
:
e
.
accept
()
self
.
expanded
^=
True
self
.
toggled
.
emit
(
self
)
self
.
update
()
else
:
return
QtGui
.
mousePressEvent
(
self
,
e
)
# On réaffiche
self
.
repaint
()
def
paintEvent
(
self
,
e
):
p
=
QtGui
.
QPainter
(
self
.
ui
.
plateau
)
p
.
setBrush
(
QtGui
.
QBrush
(
QtCore
.
Qt
.
SolidPattern
))
# Dessin de la grille
largeur_case
=
self
.
ui
.
plateau
.
width
()
//
9
hauteur_case
=
self
.
ui
.
plateau
.
height
()
//
7
for
i
in
range
(
10
):
p
.
drawLine
(
0
,
i
*
hauteur_case
,
self
.
width
(),
i
*
hauteur_case
)
for
i
in
range
(
8
):
p
.
drawLine
(
i
*
largeur_case
,
0
,
i
*
largeur_case
,
self
.
height
())
def
drawPlateau
(
self
,
*
args
):
# on informe le peintre qu'on veut dessiner dans le widget conteneur
self
.
painter
.
begin
(
self
.
ui
.
plateau
)
# variable intermédiraire pour alléger le code
qp
=
self
.
painter
...
...
@@ -94,8 +118,18 @@ class MonAppli(QtWidgets.QMainWindow):
# on informe le peintre qu'on a fini
self
.
painter
.
end
()
# TO DO
# Chargement de votre fenetre ui.
# Dessin des pions
# On parcourt la représentation du jeu et on affiche
# for i in range(3):
# for j in range(3):
# if jeu[i][j] !=0:
# if jeu[i][j] == 1:
# p.setBrush(QtGui.QColor(255, 0, 0))
# else:
# p.setBrush(QtGui.QColor(255, 255, 0))
# p.drawEllipse(j * largeur_case, i * hauteur_case,
# largeur_case, hauteur_case)
if
__name__
==
"__main__"
:
...
...
joueur.py
View file @
04d6a904
...
...
@@ -28,7 +28,7 @@ class Joueur(metaclass = ABCMeta):
while
not
bool
:
n
=
input
(
'quelle piece voulez-vous bouger: 0? 1? 2? 3? 4?'
)
coup
=
input
(
'quel coup souhaitez-vous faire: entrer? sortir? orientation? position? pousser?'
)
coup
=
input
(
'quel coup souhaitez-vous faire: entrer? sortir? orientation? position? pousser?
entrer en poussant
'
)
if
coup
not
in
[
'entrer'
,
'sortir'
,
'orientation'
,
'position'
,
'pousser'
,
'entrer en poussant'
]:
print
(
'coup non reconnu'
)
...
...
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