From da2bb3d8e7dcd7f7f0a0c2d2e214b422350d1993 Mon Sep 17 00:00:00 2001 From: Viljami Ilola <+@hix.fi> Date: Thu, 28 Mar 2024 10:00:00 +0200 Subject: hiscore name - game.game --- src/sliceitoff/game/game.py | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/sliceitoff/game/game.py (limited to 'src/sliceitoff/game/game.py') diff --git a/src/sliceitoff/game/game.py b/src/sliceitoff/game/game.py new file mode 100644 index 0000000..fd796e9 --- /dev/null +++ b/src/sliceitoff/game/game.py @@ -0,0 +1,61 @@ +""" Slice It Off! - Game where you slice the area where enemies reside to + the minimum +""" + +from pathlib import Path + +import pygame + +from display import Display +from images import Images, Fonts +from stats import Stats +from screens import welcome_screen + +from .level import Level +from .show import Show +from .hiscore import HiScore + +class Game: + def __init__(self): + pygame.init() + self.clock = pygame.time.Clock() + self.display = Display() + + pygame.mouse.set_visible(False) + + Fonts.load_fonts( Path(__file__).parent.parent.resolve() ) + + def welcome(self): + ws = Show(welcome_screen()) + dt = 0 + while ws.step(dt): + dt = self.clock.tick() + self.display.update( [ws.sprites] ) + + def newgame(self): + Stats.new_game() + + while Stats.lives: + level = Level(display = self.display) + dt = 0 + while level.step(dt): + dt = self.clock.tick() + if Stats.lives: + Stats.level_up() + + def hiscore(self): + hs = HiScore() + dt = 0 + while hs.step(): + dt = self.clock.tick() + # hs.update(dt = dt) + self.display.update([hs]) + + def run(self): + self.welcome() + self.newgame() + self.hiscore() + + def __del__(self): + pygame.quit() + -- cgit v1.2.3