From 3ea3bcaee6ec49a80c977a4aef0be98522d53f6a Mon Sep 17 00:00:00 2001 From: Libor Date: Sun, 15 Jun 2025 08:39:55 +0200 Subject: [PATCH] splash screen placeholder --- main.py | 7 ++++--- ui.py | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index a54f176..0d193d1 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ from enums import GameType from game import SingleGame, CoopGame -from ui import show_menu +from ui import show_menu, show_splash from config import SCREEN_WIDTH, SCREEN_HEIGHT pygame.init() @@ -13,13 +13,14 @@ def main(): """Main function of this game""" screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) - pygame.display.set_caption("Moje Střilečka") + show_splash(screen) + while True: choice = show_menu(screen) - print("Choice", choice) + #print("Choice", choice) if choice == GameType.SINGLE: game = SingleGame(screen=screen) diff --git a/ui.py b/ui.py index 44d7c32..e0149c0 100644 --- a/ui.py +++ b/ui.py @@ -35,3 +35,27 @@ def show_menu(screen): if event.key == pygame.K_ESCAPE: return "quit" + +def show_splash(screen): + """Init splash screen""" + + font = pygame.font.Font(None, 36) + + # todo timer, aby se po par sekundach samo ukoncilo + while True: + screen.fill((0, 0, 0)) + + text = font.render("Our fancy game name", True, (255, 0, 0)) + screen.blit(text, (50, 200)) + + text = font.render("press escape to continue", True, (255, 255, 255)) + screen.blit(text, (50, 300)) + + pygame.display.flip() + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + return + + if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: + return