summaryrefslogtreecommitdiff
path: root/src/sliceitoff/game/game.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sliceitoff/game/game.py')
-rw-r--r--src/sliceitoff/game/game.py33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/sliceitoff/game/game.py b/src/sliceitoff/game/game.py
index fd796e9..0b67d2f 100644
--- a/src/sliceitoff/game/game.py
+++ b/src/sliceitoff/game/game.py
@@ -9,11 +9,12 @@ import pygame
from display import Display
from images import Images, Fonts
from stats import Stats
-from screens import welcome_screen
+from screens import welcome_screen, hiscores_screen
+from hiscores import HiScores
from .level import Level
from .show import Show
-from .hiscore import HiScore
+from .initials import Initials
class Game:
def __init__(self):
@@ -25,12 +26,21 @@ class Game:
Fonts.load_fonts( Path(__file__).parent.parent.resolve() )
+ self.hiscores = HiScores()
+
def welcome(self):
ws = Show(welcome_screen())
dt = 0
while ws.step(dt):
dt = self.clock.tick()
- self.display.update( [ws.sprites] )
+ self.display.update( [ws] )
+
+ def show_highscores(self):
+ his = Show(hiscores_screen(str(self.hiscores)))
+ dt = 0
+ while his.step(dt):
+ dt = self.clock.tick()
+ self.display.update( [his] )
def newgame(self):
Stats.new_game()
@@ -43,18 +53,21 @@ class Game:
if Stats.lives:
Stats.level_up()
- def hiscore(self):
- hs = HiScore()
- dt = 0
- while hs.step():
+ def initials(self):
+ initials = Initials()
+ dt = 0
+ while initials.step():
dt = self.clock.tick()
- # hs.update(dt = dt)
- self.display.update([hs])
+ self.display.update([initials])
+ return initials.name
def run(self):
self.welcome()
self.newgame()
- self.hiscore()
+ if self.hiscores.high_enough(Stats.score):
+ self.hiscores.add( Stats.score, self.initials())
+ self.show_highscores()
+
def __del__(self):
pygame.quit()