def gameOver(self, event: QPaintEvent, painter: QPainter): info = "" if self.score > self.highscore: self.lives += 1 self.highscore = self.score info = "\n\nNew high score! 1 life replenished." font_size = 10 if not is_mac else 12 painter.setPen(QColor(0, 34, 3)) painter.setFont(QFont("Decorative", font_size)) if self.lives > 0: msg = "GAME OVER{}\n\nPress space to play again".format(info) else: self.setCursor(Qt.CursorShape.PointingHandCursor) msg = ("GAME OVER\n\nYou're out of lives for today,\n" "but tomorrow is another day :)\n\n" "Tip: Get more lives by\nkeeping up with your reviews!\n\n" "Pro-Tip: Pledge your support on Patreon\n" "and get access to other secret\n" "features and add-ons :)" "\n\nClick here to go to\n" "patreon.com/glutanimate") painter.drawText(event.rect(), Qt.AlignmentFlag.AlignCenter, msg)
def drawSnake(self, painter: QPainter): painter.setPen(Qt.PenStyle.NoPen) painter.setBrush(QColor("#ffffff")) for i in self.snakeArray: painter.drawRect(i[0], i[1], 12, 12)
def scoreText(self, event: QPaintEvent, painter: QPainter): painter.setPen(QColor("#ffffff")) painter.setFont(QFont("Decorative", 10)) painter.drawText(4, 17, "LIVES: " + str(self.lives)) painter.drawText(120, 17, "SCORE: " + str(self.score)) painter.drawText(230, 17, "BEST: " + str(self.highscore))
def scoreBoard(self, painter: QPainter): painter.setPen(Qt.PenStyle.NoPen) painter.setBrush(QColor("#3e7a78")) painter.drawRect(0, 0, 300, 24)