Loads high score from highscore.txt. Returns 0 if not found.
(self)
| 23 | self.update_scoreboard() |
| 24 | |
| 25 | def load_high_score(self): |
| 26 | """Loads high score from highscore.txt. Returns 0 if not found.""" |
| 27 | try: |
| 28 | with open("highscore.txt", mode="r") as file: |
| 29 | return int(file.read()) |
| 30 | except (FileNotFoundError, ValueError): |
| 31 | return 0 |
| 32 | |
| 33 | def update_scoreboard(self): |
| 34 | """Clears and rewrites the score and high score in the top-left corner.""" |