-
Notifications
You must be signed in to change notification settings - Fork 1
/
menus.py
56 lines (43 loc) · 1.35 KB
/
menus.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import pygame as pg
import config
import killyourlungs
PADDING = 24
HEADER_SIZE = 40
MENU_LINE_OFFSET = 24
def get_entries(menu_type):
entries = {
'exit': ['NO', 'YES'],
'ingame-exit': ['CONTINUE', 'GIVE UP'],
'titlescreen': ['START', 'HIGHSCORES', 'CREDITS']
}
return entries.get(menu_type)
def get_title(menu_type):
titles = {
'exit': 'EXIT GAME?',
'ingame-exit': 'PAUSE',
'pause': 'SMOKE BREAK'
}
return titles.get(menu_type)
def get_funcs(menu_type):
funcs = {
'exit': ['back', killyourlungs.quit_game],
'ingame-exit': ['back', killyourlungs.quit_game],
'titlescreen': ['start', 'scores', 'credits'],
'pause': ['back']
}
return funcs.get(menu_type)
def get_surf(menu_type):
x, y = PADDING * 2, PADDING * 2
y += HEADER_SIZE
if menu_type != 'pause':
y += MENU_LINE_OFFSET * len(get_entries(menu_type)) - MENU_LINE_OFFSET / 2
lines = get_entries(menu_type)
lines.append(get_title(menu_type))
x += 16 * len(max(lines, key=len))
else:
x += 208
y += 162 # ashtray size
return pg.Surface((x, y))
def make_outline(surface, fill_color, outline_color=config.TEXT_COLOR, border=4):
surface.fill(outline_color)
surface.fill(fill_color, surface.get_rect().inflate(-border, -border))