forked from OpenBMB/ChatDev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.py
39 lines (39 loc) · 1.08 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
'''
Game Menu
'''
import pygame
# Initialize the game
pygame.init()
# Set up the game window
window_width = 800
window_height = 600
window = pygame.display.set_mode((window_width, window_height))
pygame.display.set_caption("Greedy Snake Game")
# Define colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
# Define game variables
menu_font = pygame.font.Font(None, 36)
# Define the menu function
def menu():
running = True
while running:
# Handle events
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
running = False
# Clear the window
window.fill(BLACK)
# Draw the menu text
text = menu_font.render("Press Enter to Start", True, WHITE)
text_rect = text.get_rect(center=(window_width // 2, window_height // 2))
window.blit(text, text_rect)
# Update the display
pygame.display.update()
# Run the menu function
menu()
# Quit the game
pygame.quit()