Leaderboard implemted +-
This commit is contained in:
@@ -51,8 +51,8 @@ This isn't just about coding; it's about building something I love from the grou
|
|||||||
1. [ ] **Themes and Visual Effects**:
|
1. [ ] **Themes and Visual Effects**:
|
||||||
- [ ] Add background or block skins for variety.
|
- [ ] Add background or block skins for variety.
|
||||||
- [ ] Implement line clear animations.
|
- [ ] Implement line clear animations.
|
||||||
2. [ ] **Customizable Controls**:
|
2. [x] **Customizable Controls**:
|
||||||
- [ ] Allow players to remap movement, rotation, and drop keys.
|
- [x] Allow players to remap movement, rotation, and drop keys.
|
||||||
3. [ ] **Detailed Stats**:
|
3. [ ] **Detailed Stats**:
|
||||||
- [ ] Track and display total lines cleared, playtime, and other statistics.
|
- [ ] Track and display total lines cleared, playtime, and other statistics.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -120,7 +120,7 @@ class Game:
|
|||||||
draw_text(self.screen, f'Score: {settings.game_score}', get_font(20), self.width - 150, 100, (255, 255, 255))
|
draw_text(self.screen, f'Score: {settings.game_score}', get_font(20), self.width - 150, 100, (255, 255, 255))
|
||||||
|
|
||||||
# Render surfaces
|
# Render surfaces
|
||||||
self.screen.blit(self.grid_surface, (0, 0))
|
self.screen.blit(self.grid_surface, (settings.width // 2 - 150, 50))
|
||||||
self.screen.blit(self.next_surface, (self.width - 150, 200))
|
self.screen.blit(self.next_surface, (self.width - 150, 200))
|
||||||
self.screen.blit(self.hold_surface, (self.width - 150, 400))
|
self.screen.blit(self.hold_surface, (self.width - 150, 400))
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ class StartMenu:
|
|||||||
draw_text(self.screen, f"Score: {item}", get_font(30), setting.width // 5, setting.height // 3 - 50 + position, (255, 255, 255))
|
draw_text(self.screen, f"Score: {item}", get_font(30), setting.width // 5, setting.height // 3 - 50 + position, (255, 255, 255))
|
||||||
position += 50
|
position += 50
|
||||||
|
|
||||||
|
self.score = load_score("gamescore.json")
|
||||||
|
|
||||||
self.play.update(self.screen)
|
self.play.update(self.screen)
|
||||||
self.options.update(self.screen)
|
self.options.update(self.screen)
|
||||||
self.quit.update(self.screen)
|
self.quit.update(self.screen)
|
||||||
|
|||||||
+14
-2
@@ -37,8 +37,20 @@ def load_score(filename):
|
|||||||
|
|
||||||
def add_score(filename, score):
|
def add_score(filename, score):
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
with open(os.path.join(os.getcwd(), filename), "w") as file:
|
with open(filename, "r") as file:
|
||||||
json.dump(score, file)
|
data = json.load(file)
|
||||||
|
|
||||||
|
# If the stored data doesn't have a "score" key for some reason, ensure it does.
|
||||||
|
if "score" not in data:
|
||||||
|
data["score"] = []
|
||||||
|
|
||||||
|
# Append the new score.
|
||||||
|
# You can also handle multiple scores by extending the list, e.g. `data["score"].extend(new_score)`.
|
||||||
|
data["score"].append(score)
|
||||||
|
|
||||||
|
# Write the updated data back to the file.
|
||||||
|
with open(filename, "w") as file:
|
||||||
|
json.dump(data, file, indent=2)
|
||||||
|
|
||||||
# For keybinds (control.py)
|
# For keybinds (control.py)
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -1 +1,7 @@
|
|||||||
7300
|
{
|
||||||
|
"score": [
|
||||||
|
2300,
|
||||||
|
100,
|
||||||
|
6000
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user