Exemple #1
0
    def re_init(self):
        self.score = 0
        self.totalTime = 10
        highscore = open("highscore.txt", "r")
        currentHighScore = highscore.readline()

        self.score = 0
        self.totalTime = 10

        # Start a timer to figure out when the game ends (60 seconds)
        pygame.time.set_timer(TIME_UP, 10000)
        self.startTime = pygame.time.get_ticks()

        # font = pygame.font.Font(os.path.join("assets/fonts", "peanuts.tff"), 28)
        self.fontRegular = pygame.font.Font(
            os.path.join("assets/fonts", "cella.otf"), 28)
        self.fontSmall = pygame.font.Font(
            os.path.join("assets/fonts", "cella.otf"), 20)

        # Render the text with Anti-aliasing
        self.scoreText = self.fontRegular.render("Score: " + str(self.score),
                                                 True, COLOR_BLACK)
        self.scorepos = self.scoreText.get_rect(left=40, top=20)
        self.timerText = self.fontRegular.render(
            "Time Left: " + str(self.time_left()), True, COLOR_BLACK)
        self.timerpos = self.timerText.get_rect(left=40, top=50)
        self.highscoreText = self.font.render(
            "High Score: " + currentHighScore, True, COLOR_BLACK)
        self.highscorepos = self.highscoreText.get_rect(left=self.width - 300,
                                                        top=20)

        # Initialize snoopy and the woodstocks
        self.snoopy = Snoopy(self)
        self.woodstocks = self.createWoodstocks()

        pygame.joystick.init()