Commit 70c810ab authored by DUFAIX Clement's avatar DUFAIX Clement
Browse files

add qt

parent 41a13d2f
......@@ -2,7 +2,9 @@ import sys
from abc import abstractmethod
import numpy as np
import PyQt5
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class Game:
......@@ -13,11 +15,13 @@ class Game:
def __init__(self, joueur1, joueur2):
self.joueur1 = joueur1
self.joueur2 = joueur2
self.window = Window(self)
self.gameManager()
def gameManager(self):
while(not self.isEndGame(self.actualPlayer)):
self.window.drawTheScene()
if self.actualPlayer == 1:
self.joueur1.takeDecision(self)
self.actualPlayer = 2
......@@ -95,5 +99,94 @@ class Agent(Player):
print("\nAu tour du joueur "+str(game.actualPlayer)+", l'IA joue")
pass #TODO IA
class Window(QMainWindow):
index=0
def __init__(self, game):
super().__init__()
self.game = game
# set the title
self.setWindowTitle("Mutorere")
# setting geometry
self.setGeometry(100, 100, 600, 500)
self.drawTheScene()
# creating a label widget
def drawTheScene(self):
#self.paintEvent()
# show all the widgets
self.update()
self.show()
def paintEvent(self, event):
self.index = 0
self.painter = QPainter(self)#1
self.painter.setPen(QPen(Qt.black, 4, Qt.SolidLine))
self.painter.drawText(250,50,"1")
self.painter.setBrush(QBrush(self.chooseColor(), Qt.SolidPattern))
self.painter.drawEllipse(250, 50, 70, 70)
self.painter.setPen(QPen(Qt.black, 4, Qt.SolidLine))
self.painter.drawText(350,100,"2")
self.painter.setBrush(QBrush(self.chooseColor(), Qt.SolidPattern))
self.painter.drawEllipse(350, 100, 70, 70)
self.painter.setPen(QPen(Qt.black, 4, Qt.SolidLine))
self.painter.drawText(400,200,"3")
self.painter.setBrush(QBrush(self.chooseColor(), Qt.SolidPattern))
self.painter.drawEllipse(400, 200, 70, 70)
self.painter.setPen(QPen(Qt.black, 4, Qt.SolidLine))
self.painter.drawText(350,300,"4")
self.painter.setBrush(QBrush(self.chooseColor(), Qt.SolidPattern))
self.painter.drawEllipse(350, 300, 70, 70)
self.painter.setPen(QPen(Qt.black, 4, Qt.SolidLine))
self.painter.drawText(250,350,"5")
self.painter.setBrush(QBrush(self.chooseColor(), Qt.SolidPattern))
self.painter.drawEllipse(250, 350, 70, 70)
self.painter.setPen(QPen(Qt.black, 4, Qt.SolidLine))
self.painter.drawText(150,300,"6")
self.painter.setBrush(QBrush(self.chooseColor(), Qt.SolidPattern))
self.painter.drawEllipse(150, 300, 70, 70)
self.painter.setPen(QPen(Qt.black, 4, Qt.SolidLine))
self.painter.drawText(100,200,"7")
self.painter.setBrush(QBrush(self.chooseColor(), Qt.SolidPattern))
self.painter.drawEllipse(100, 200, 70, 70)
self.painter.setPen(QPen(Qt.black, 4, Qt.SolidLine))
self.painter.drawText(150,100,"8")
self.painter.setBrush(QBrush(self.chooseColor(), Qt.SolidPattern))
self.painter.drawEllipse(150, 100, 70, 70)
self.painter.setPen(QPen(Qt.black, 4, Qt.SolidLine))
self.painter.drawText(250,200,"9")
self.painter.setBrush(QBrush(self.chooseColor(), Qt.SolidPattern))
self.painter.drawEllipse(250, 200, 70, 70)
self.painter.end()
#self.painter.drawEllipse(180, 50, 100, 100)
def chooseColor(self):
self.index+=1
if(self.game.boardGame[self.index-1]==0):
return Qt.white
if(self.game.boardGame[self.index-1]==1):
return Qt.green
if(self.game.boardGame[self.index-1]==2):
return Qt.red
if __name__ == "__main__":
app = QApplication(sys.argv)
Game(RealPlayer(),RealPlayer())
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment