-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.py
More file actions
94 lines (82 loc) · 3.77 KB
/
Menu.py
File metadata and controls
94 lines (82 loc) · 3.77 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
import pygame
from Display import *
from StateHandler import *
from GameState import *
class Menu:
def __init__(self):
self.big_font = pygame.font.Font("Resources/Quinquefive-Ea6d4.ttf", 64)
self.small_font = pygame.font.Font(
"Resources/Quinquefive-Ea6d4.ttf", 48)
self.diff_font = pygame.font.Font(
"Resources/Quinquefive-Ea6d4.ttf", 32)
self.title = self.big_font.render('SPEED TYPER', False, (0, 0, 0))
self.start_text = self.small_font.render('START', False, (0, 0, 0))
self.difficulty_text = self.small_font.render(
'DIFFICULTY', False, (0, 0, 0))
self.difficulties = ['EASY', 'MEDIUM', 'HARD']
self.selected_difficulty = self.diff_font.render(
'EASY', False, (0, 0, 0))
self.quit_text = self.small_font.render('QUIT', False, (0, 0, 0))
self.selected = 0
self.diff_select = 0
def draw(self):
Display.SCREEN.blit(
self.title, [Display.WINDOW_SIZE[0]/10, Display.WINDOW_SIZE[1]*0.1])
Display.SCREEN.blit(
self.start_text, [Display.WINDOW_SIZE[0]/10, Display.WINDOW_SIZE[1]*0.4])
Display.SCREEN.blit(self.difficulty_text, [
Display.WINDOW_SIZE[0]/10, Display.WINDOW_SIZE[1]*0.6])
Display.SCREEN.blit(self.quit_text, [
Display.WINDOW_SIZE[0]/10, Display.WINDOW_SIZE[1]*0.8])
Display.SCREEN.blit(self.selected_difficulty, [
Display.WINDOW_SIZE[0]*0.75, Display.WINDOW_SIZE[1]*0.6])
def loop(self, event):
if event.type == pygame.KEYDOWN:
if event.scancode == 79:
if self.selected == 1:
self.diff_select += 1
if self.diff_select > len(self.difficulties) - 1:
self.diff_select = 0
if event.scancode == 82:
self.selected -= 1
if self.selected < 0:
self.selected = 2
if event.scancode == 80:
if self.selected == 1:
self.diff_select -= 1
if self.diff_select < 0:
self.diff_select = len(self.difficulties) - 1
if event.scancode == 81:
self.selected += 1
if self.selected > 2:
self.selected = 0
if event.scancode == 40:
if self.selected == 0:
StateHandler.STATE = GameState.STATE_GAME
if self.diff_select == 0:
StateHandler.DIFFICULTY = GameState.DIFFICULTY_EASY
elif self.diff_select == 1:
StateHandler.DIFFICULTY = GameState.DIFFICULTY_MEDIUM
else:
StateHandler.DIFFICULTY = GameState.DIFFICULTY_HARD
if self.selected == 2:
StateHandler.STATE = GameState.STATE_DONE
if self.selected == 0:
self.start_text = self.small_font.render(
'START', False, (100, 100, 100))
else:
self.start_text = self.small_font.render('START', False, (0, 0, 0))
if self.selected == 1:
self.difficulty_text = self.small_font.render(
'DIFFICULTY', False, (100, 100, 100))
else:
self.difficulty_text = self.small_font.render(
'DIFFICULTY', False, (0, 0, 0))
if self.selected == 2:
self.quit_text = self.small_font.render(
'QUIT', False, (100, 100, 100))
else:
self.quit_text = self.small_font.render(
'QUIT', False, (0, 0, 0))
self.selected_difficulty = self.diff_font.render(
self.difficulties[self.diff_select], False, (0, 0, 0))