From 0eb4038a3d634265dc68b7b12e8aa8acf0a94446 Mon Sep 17 00:00:00 2001 From: Derek Camilo Date: Mon, 2 Dec 2024 02:42:21 -0500 Subject: [PATCH] def win_screen function --- constants.py | 7 +++++-- sudoku.py | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/constants.py b/constants.py index fe46bd08..c49cb6b4 100644 --- a/constants.py +++ b/constants.py @@ -2,12 +2,15 @@ WIDTH = 850 HEIGHT = 1000 -BG_COLOR_1 = (255,255, 255) #White +BG_COLOR_1 = (125, 248, 255) #Light Blue BG_COLOR_2 = (150, 10, 255) #Purple *IF NECCESSARY* +WIN_BG = (125, 255, 125) # Green +LOSE_BG = (250, 52, 52) # Red TEXT = (0, 0, 0) #Black TITLE_TEXT = (255, 10, 200) #Pink BUTTON_COLOR = (255, 10, 200) #Pink -BUTTON_TEXT = (255,255, 255) +BUTTON_COLOR_2 = (255, 255, 255) +BUTTON_TEXT = (125, 248, 255) #Light Blue EASY = 30 MEDIUM = 40 HARD = 50 diff --git a/sudoku.py b/sudoku.py index 67dc0623..8887e94e 100644 --- a/sudoku.py +++ b/sudoku.py @@ -115,7 +115,45 @@ def during_game(screen, difficulty): elif exit_rectangle.collidepoint(event.pos): sys.exit() pygame.display.update() - + +def win_screen(screen): + # Title/Button font init + title_font = pygame.font.Font(None, 100) + button_font = pygame.font.Font(None, 100) + + # Background coloring + screen.fill(WIN_BG) + + # Creating title text + title_surface = title_font.render("YOU WON!!!", 0, TEXT) + title_rectangle = title_surface.get_rect(center=(WIDTH // 2, HEIGHT // 2 - 300)) + screen.blit(title_surface, title_rectangle) + + # Init Buttons + exit_text = button_font.render("EXIT", 0, TEXT) + + # Init Easy/Medium/Hard Button Text Box Background + exit_surface = pygame.Surface((exit_text.get_size()[0] + 40, exit_text.get_size()[1] + 40)) + exit_surface.fill(BG_COLOR_2) + exit_surface.blit(exit_text, (20, 20)) + + # Init Button Rectangle + exit_rectangle = exit_surface.get_rect(center=(WIDTH // 2, HEIGHT // 2)) + + # Draw Buttons + screen.blit(exit_surface, exit_rectangle) + while True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + sys.exit() + if event.type == pygame.MOUSEBUTTONDOWN: + if exit_rectangle.collidepoint(event.pos): + sys.exit() + pygame.display.update() + +def lose_screen(screen): + pass + def main (): @@ -136,6 +174,7 @@ def main (): dif = "HARD" screen.fill(BG_COLOR_1) during_game(screen, dif) + win_screen(screen) #board.print_board() #For debugging ^