def draw(self): if self.buttons[0].selected: #PvP self.buttons[0].selected = False self.window.player1.isComputer = False self.window.player1.name = "Player 1" self.window.player2.isComputer = False self.window.player2.name = "Player 2" self.window.setupScreenP1.resetBottomText() self.window.setupScreenP2.resetBottomText() self.window.currentScreen = self.window.setupScreenP1 elif self.buttons[1].selected: #PvPC self.window.player1.isComputer = False self.window.player1.name = "Player" self.window.player2.isComputer = True self.window.player2.name = "Computer" self.window.setupScreenP1.resetBottomText() self.window.currentScreen = self.window.setupScreenP1 self.buttons[1].selected = False elif self.buttons[2].selected: #PCvPC self.window.player1.isComputer = True self.window.player1.name = "Computer 1" self.window.player2.isComputer = True self.window.player2.name = "Computer 2" self.window.currentScreen = self.window.setupScreenP1 self.buttons[2].selected = False else: for button in self.buttons: Utils.drawButton(button) pyglet.text.Label('Stratego-Ascension', font_name='Arial', font_size=30, x=self.width/2, y= self.height-200, anchor_x='center', anchor_y='center').draw()
def draw(self): if self.player.isComputer: self.player.setuppieces(self.bottomArea,self.topArea) self.isDone = True if self.isDone: fields = self.topArea + self.bottomArea if self is self.window.setupScreenP2: for y in range(6,10): for x in range(0,10): self.window.playScreen.playFields[y][x].piece = self.topArea[9-y][9-x].piece self.window.currentScreen = self.window.playScreen else: for y in range(0,4): for x in range (0,10): self.window.playScreen.playFields[y][x].piece = self.topArea[y][x].piece self.window.currentScreen = self.window.setupScreenP2 else: self.header.draw() self.footer.draw() for area in [self.bottomArea, self.topArea]: for y in range(0, len(area)): for field in area[y]: if (field is self.firstSelected): glColor3f(1, 0, 1) else: glColor3f(1, 1, 1) Utils.drawField(field) for field in self.barriers: glColor3f(1, 0, 0) Utils.drawField(field) glColor3f(1, 1, 1) if self.buttons[0].selected: self.buttons[0].selected = False if not self.checkIfDone(): self.footer.text = "You have to place all your pieces before you can continue" # Reset footer text to original after x seconds if hasattr(self, 'textResetTimer') and self.textResetTimer.isAlive(): self.textResetTimer.cancel() self.textResetTimer.join() self.textResetTimer = threading.Timer(3, self.resetBottomText) self.textResetTimer.start() else: self.isDone = True if self.buttons[1].selected: self.autofill() self.buttons[1].selected = False for button in self.buttons: Utils.drawButton(button)
def draw(self): if self.buttons[0].selected: self.buttons[0].selected = False self.window.resetWindows() for y in self.window.player1.pieces: for piece in y: if piece is not None: piece.hidden = False for y in self.window.player2.pieces: for piece in y: if piece is not None: piece.hidden = False self.window.currentScreen = self.window.setupScreenP1 if self.buttons[1].selected: self.window.resetWindows() self.window.currentScreen = self.window.startScreen self.buttons[1].selected = False for y in self.window.player1.pieces: for piece in y: if piece is not None: piece.hidden = False for y in self.window.player2.pieces: for piece in y: if piece is not None: piece.hidden = False if self.buttons[2].selected: sys.exit() for button in self.buttons: Utils.drawButton(button) pyglet.text.Label( self.victoryPlayer.name + " has won!", font_name="Arial", font_size=30, x=self.width / 2, y=self.height - 200, anchor_x="center", anchor_y="center", ).draw()