Skip to content

Commit

Permalink
figured out outlines
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekCamilo committed Dec 2, 2024
1 parent 0eb4038 commit c0309a5
Showing 1 changed file with 121 additions and 23 deletions.
144 changes: 121 additions & 23 deletions sudoku.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

def game_start(screen):
#Title/Button font init
start_title_font = pygame.font.Font(None, 100)
subtitle_font = pygame.font.Font(None, 75)
start_title_font = pygame.font.Font(None, 120)
subtitle_font = pygame.font.Font(None, 90)
button_font = pygame.font.Font(None, 70)

#Background coloring
Expand All @@ -19,15 +19,25 @@ def game_start(screen):
#Creating title text
main_title_surface = start_title_font.render("Welcome to Sudoku", 0, TITLE_TEXT)
main_title_rectangle = main_title_surface.get_rect(center = (WIDTH // 2, HEIGHT // 2 - 300))
#Create outline
main_title_outline = start_title_font.render("Welcome to Sudoku", 0, TEXT)
for i in range (-3, 4):
for j in range(-3, 4):
screen.blit(main_title_outline, main_title_surface.get_rect(center = (WIDTH //2 + i, HEIGHT // 2 - 300 + j)))
screen.blit(main_title_surface, main_title_rectangle)
#Creating Subtitle
subtitle_surface = subtitle_font.render("Select Game Mode:", 0, TITLE_TEXT)
subtitle_rectangle = subtitle_surface.get_rect(center = (WIDTH // 2 , HEIGHT // 2 - 50))
subtitle_outline = subtitle_font.render("Select Game Mode:", 0, TEXT)
for i in range(-3, 4):
for j in range(-3, 4):
screen.blit(subtitle_outline, subtitle_surface.get_rect(center=(WIDTH // 2 + i, HEIGHT // 2 - 50 + j)))
screen.blit(subtitle_surface, subtitle_rectangle)

#Init Buttons
easy_text = button_font.render("Easy", 0, BUTTON_TEXT)
medium_text = button_font.render("Medium", 0, BUTTON_TEXT)
hard_text = button_font.render("Hard", 0, BUTTON_TEXT)
easy_text = button_font.render("Easy", 0, TEXT)
medium_text = button_font.render("Medium", 0, TEXT)
hard_text = button_font.render("Hard", 0, TEXT)

#Init Easy/Medium/Hard Button Text Box Background
easy_surface = pygame.Surface((easy_text.get_size()[0] + 20, easy_text.get_size()[1] + 20))
Expand All @@ -46,7 +56,23 @@ def game_start(screen):
medium_rectangle = medium_surface.get_rect(center = (WIDTH // 2 , HEIGHT // 2 + 150))
hard_rectangle = hard_surface.get_rect(center = (WIDTH // 2 - 200, HEIGHT // 2 + 150))

#Init Button Outlines
easy_ot_surface = pygame.Surface((easy_text.get_size()[0] + 30, easy_text.get_size()[1] + 30))
easy_ot_surface.fill(TEXT)
medium_ot_surface = pygame.Surface((medium_text.get_size()[0] + 30, medium_text.get_size()[1] + 30))
medium_ot_surface.fill(TEXT)
hard_ot_surface = pygame.Surface((hard_text.get_size()[0] + 30, hard_text.get_size()[1] + 30))
hard_ot_surface.fill(TEXT)

easy_ot_rectangle = easy_ot_surface.get_rect(center=(WIDTH // 2 + 200, HEIGHT // 2 + 150))
medium_ot_rectangle = medium_ot_surface.get_rect(center=(WIDTH // 2, HEIGHT // 2 + 150))
hard_ot_rectangle = hard_ot_surface.get_rect(center=(WIDTH // 2 - 200, HEIGHT // 2 + 150))


#Draw Buttons
screen.blit(easy_ot_surface, easy_ot_rectangle)
screen.blit(medium_ot_surface, medium_ot_rectangle)
screen.blit(hard_ot_surface, hard_ot_rectangle)
screen.blit(easy_surface, easy_rectangle)
screen.blit(medium_surface, medium_rectangle)
screen.blit(hard_surface, hard_rectangle)
Expand Down Expand Up @@ -118,41 +144,112 @@ def during_game(screen, difficulty):

def win_screen(screen):
# Title/Button font init
title_font = pygame.font.Font(None, 100)
title_font = pygame.font.Font(None, 150)
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))
title_rectangle = title_surface.get_rect(center=(WIDTH // 2, HEIGHT // 2 - 250))
screen.blit(title_surface, title_rectangle)

# Init Buttons
# Init Exit Button
exit_text = button_font.render("EXIT", 0, TEXT)

# Init Easy/Medium/Hard Button Text Box Background
# Init Exit 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))
exit_rectangle = exit_surface.get_rect(center=(WIDTH // 2, HEIGHT // 2 - 100))

# Init Restart Button
restart_text = button_font.render("RESTART", 0, TEXT)

# Init Restart Button Text Box Background
restart_surface = pygame.Surface((restart_text.get_size()[0] + 40, restart_text.get_size()[1] + 40))
restart_surface.fill(BG_COLOR_2)
restart_surface.blit(restart_text, (20, 20))

# Init Button Rectangle
restart_rectangle = restart_surface.get_rect(center=(WIDTH // 2, HEIGHT // 2 + 100))

#Init Restart Button Outline
restart_ot_surface = pygame.Surface((restart_text.get_size()[0] + 50, restart_text.get_size()[1] + 50))
restart_ot_surface.fill(TEXT)
restart_ot_rectangle = restart_ot_surface.get_rect(center=(WIDTH // 2, HEIGHT // 2 + 100))

#Init Exit Button Outline
exit_ot_surface = pygame.Surface((exit_text.get_size()[0] + 50, exit_text.get_size()[1] + 50))
exit_ot_surface.fill(TEXT)
exit_ot_rectangle = exit_ot_surface.get_rect(center=(WIDTH // 2, HEIGHT // 2 - 100))

# Draw Buttons
screen.blit(restart_ot_surface, restart_ot_rectangle)
screen.blit(exit_ot_surface, exit_ot_rectangle)
screen.blit(restart_surface, restart_rectangle)
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()
elif restart_rectangle.collidepoint(event.pos):
return
pygame.display.update()

def lose_screen(screen):
pass
# Title/Button font init
title_font = pygame.font.Font(None, 150)
button_font = pygame.font.Font(None, 100)

# Background coloring
screen.fill(LOSE_BG)

# Creating title text
title_surface = title_font.render("YOU LOST :<(", 0, TEXT)
title_rectangle = title_surface.get_rect(center=(WIDTH // 2, HEIGHT // 2 - 250))
screen.blit(title_surface, title_rectangle)

# Init Restart Button
restart_text = button_font.render("RESTART", 0, TEXT)

# Init Restart Button Text Box Background
restart_surface = pygame.Surface((restart_text.get_size()[0] + 40, restart_text.get_size()[1] + 40))
restart_surface.fill(BG_COLOR_1)
restart_surface.blit(restart_text, (20, 20))

# Init Button Rectangle
restart_rectangle = restart_surface.get_rect(center=(WIDTH // 2 + 150, HEIGHT // 2))

# Init Exit Button
exit_text = button_font.render("EXIT", 0, TEXT)

# Init Exit 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_1)
exit_surface.blit(exit_text, (20, 20))

# Init Button Rectangle
exit_rectangle = exit_surface.get_rect(center=(WIDTH // 2 - 150, HEIGHT // 2))

# Draw Buttons
screen.blit(restart_surface, restart_rectangle)
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 restart_rectangle.collidepoint(event.pos):
return
pygame.display.update()



Expand All @@ -163,18 +260,19 @@ def main ():
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Prog 1 Sudoku")

difficulty = game_start(screen)
board = SudokuGenerator(9, difficulty)
if difficulty == 30:
dif = "EASY"
elif difficulty == 40:
dif = "MEDIUM"
elif difficulty == 50:
dif = "HARD"
screen.fill(BG_COLOR_1)
during_game(screen, dif)
win_screen(screen)
while True:
difficulty = game_start(screen)
board = SudokuGenerator(9, difficulty)
if difficulty == 30:
dif = "EASY"
elif difficulty == 40:
dif = "MEDIUM"
elif difficulty == 50:
dif = "HARD"
screen.fill(BG_COLOR_1)
during_game(screen, dif)
lose_screen(screen)
win_screen(screen)

#board.print_board()
#For debugging ^
Expand Down

0 comments on commit c0309a5

Please sign in to comment.