-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiMenuPygame.py
More file actions
102 lines (76 loc) · 3.58 KB
/
multiMenuPygame.py
File metadata and controls
102 lines (76 loc) · 3.58 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import pygame, sys
from button import Button
pygame.init()
RES = (1000,800)
SCREEN = pygame.display.set_mode(RES)
pygame.display.set_caption("New Scales App")
def get_font(size): # Returns Press-Start-2P in the desired size
return pygame.font.Font("assets/font.ttf", size)
def play():
while True:
PLAY_MOUSE_POS = pygame.mouse.get_pos()
SCREEN.fill("black")
PLAY_TEXT = get_font(45).render("This is the PLAY screen.", True, "White")
PLAY_RECT = PLAY_TEXT.get_rect(center=(640, 260))
SCREEN.blit(PLAY_TEXT, PLAY_RECT)
PLAY_BACK = Button(image=None, pos=(640, 460),
text_input="BACK", font=get_font(75), base_color="White", hovering_color="Green")
PLAY_BACK.changeColor(PLAY_MOUSE_POS)
PLAY_BACK.update(SCREEN)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if PLAY_BACK.checkForInput(PLAY_MOUSE_POS):
main_menu()
pygame.display.update()
def options():
while True:
OPTIONS_MOUSE_POS = pygame.mouse.get_pos()
SCREEN.fill("white")
OPTIONS_TEXT = get_font(45).render("This is the OPTIONS screen.", True, "Black")
OPTIONS_RECT = OPTIONS_TEXT.get_rect(center=(640, 260))
SCREEN.blit(OPTIONS_TEXT, OPTIONS_RECT)
OPTIONS_BACK = Button(image=None, pos=(640, 460),
text_input="BACK", font=get_font(75), base_color="Black", hovering_color="Green")
OPTIONS_BACK.changeColor(OPTIONS_MOUSE_POS)
OPTIONS_BACK.update(SCREEN)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if OPTIONS_BACK.checkForInput(OPTIONS_MOUSE_POS):
main_menu()
pygame.display.update()
def main_menu():
while True:
SCREEN.blit(BG, (0, 0))
MENU_MOUSE_POS = pygame.mouse.get_pos()
MENU_TEXT = get_font(100).render("MAIN MENU", True, "#b68f40")
MENU_RECT = MENU_TEXT.get_rect(center=(640, 100))
PLAY_BUTTON = Button(image=pygame.image.load("assets/Play Rect.png"), pos=(640, 250),
text_input="PLAY", font=get_font(75), base_color="#11ff22", hovering_color="White")
OPTIONS_BUTTON = Button(image=pygame.image.load("assets/Options Rect.png"), pos=(640, 400),
text_input="OPTIONS", font=get_font(75), base_color="#11ff22", hovering_color="White")
QUIT_BUTTON = Button(image=pygame.image.load("assets/Quit Rect.png"), pos=(640, 550),
text_input="QUIT", font=get_font(75), base_color="#11ff22", hovering_color="White")
SCREEN.blit(MENU_TEXT, MENU_RECT)
for button in [PLAY_BUTTON, OPTIONS_BUTTON, QUIT_BUTTON]:
button.changeColor(MENU_MOUSE_POS)
button.update(SCREEN)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if PLAY_BUTTON.checkForInput(MENU_MOUSE_POS):
play()
if OPTIONS_BUTTON.checkForInput(MENU_MOUSE_POS):
options()
if QUIT_BUTTON.checkForInput(MENU_MOUSE_POS):
pygame.quit()
sys.exit()
pygame.display.update()
main_menu()