Description
The current Snake game does not save or display a high score between
sessions. Once the game is closed, the player's best score is lost.
Adding a persistent high score tracker would improve the gameplay
experience significantly.
Current Behavior
- Score resets to 0 every time the game is launched
- No record of previous best scores is maintained
Proposed Feature
- Save the highest score to a local file (e.g.,
highscore.txt)
- Display the high score on the game screen alongside the current score
- Update the file whenever a new high score is achieved
- Show a "New High Score!" message when the record is broken
Example Implementation
def load_high_score():
try:
with open("highscore.txt", "r") as f:
return int(f.read())
except FileNotFoundError:
return 0
def save_high_score(score):
with open("highscore.txt", "w") as f:
f.write(str(score))
Benefits
- Encourages replayability
- Minimal code change with high impact
- Follows standard game design practices
Description
The current Snake game does not save or display a high score between
sessions. Once the game is closed, the player's best score is lost.
Adding a persistent high score tracker would improve the gameplay
experience significantly.
Current Behavior
Proposed Feature
highscore.txt)Example Implementation
Benefits