-
Notifications
You must be signed in to change notification settings - Fork 0
/
mode_select.py
69 lines (66 loc) · 2.78 KB
/
mode_select.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from variables import *
def mode():
num_lvls = -1
num_guesses = 0
num_lvls_words = ['Choose the number of levels:', 'Press the number on the keyboard corresponding to ', 'the number of levels you want up to 8']
num_guesses_words = ['Choose the number of guesses per level:', 'Press the number on the keyboard corresponding to', 'the number of guesses you want up to 6']
SCREEN.fill(DARK_GREY)
# Asks for and gets number of levels for game
while num_lvls == -1:
for j in range(len(num_lvls_words)):
SCREEN.blit(instruction_font.render(num_lvls_words[j], True, WHITE),
(40, 355 + 45 * (j - 1)))
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit()
if event.key == pygame.K_1:
num_lvls = 0
if event.key == pygame.K_2:
num_lvls = 1
if event.key == pygame.K_3:
num_lvls = 2
if event.key == pygame.K_4:
num_lvls = 3
if event.key == pygame.K_5:
num_lvls = 4
if event.key == pygame.K_6:
num_lvls = 5
if event.key == pygame.K_7:
num_lvls = 6
if event.key == pygame.K_8:
num_lvls = 7
SCREEN.fill(DARK_GREY)
# Asks for and gets number of guesses per level
while num_guesses == 0:
for j in range(len(num_guesses_words)):
SCREEN.blit(instruction_font.render(num_guesses_words[j], True, WHITE),
(40, 355 + 45 * (j - 1)))
pygame.display.update()
# Handle keyboard events
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit()
if event.key == pygame.K_1:
num_guesses = 1
if event.key == pygame.K_2:
num_guesses = 2
if event.key == pygame.K_3:
num_guesses = 3
if event.key == pygame.K_4:
num_guesses = 4
if event.key == pygame.K_5:
num_guesses = 5
if event.key == pygame.K_6:
num_guesses = 6
return num_lvls, num_guesses