-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_menu.py
27 lines (22 loc) · 884 Bytes
/
game_menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pygame
from game import play_game
def display_text(screen, font, text, x, y):
text_surface = font.render(text, True, (0, 0, 0))
screen.blit(text_surface, (x, y))
def game_menu(screen, font, username, user_id):
running = True
while running:
screen.fill((255, 255, 255))
display_text(screen, font, f"Welcome, {username}", 100, 50)
display_text(screen, font, "1. Find the Letter", 100, 150)
display_text(screen, font, "2. Exit", 100, 200)
pygame.display.flip()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_1:
play_game(username, screen, font)
elif event.key == pygame.K_2:
running = False
return True