-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdifficulty.py
More file actions
145 lines (121 loc) · 4.5 KB
/
Copy pathdifficulty.py
File metadata and controls
145 lines (121 loc) · 4.5 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import pygame
import main
import gridLock
import menu
from settingVars import settingVars
# Colors
white=(253, 245, 230)
black=(15, 15, 15)
gray=(50, 50, 50)
red=(255, 0, 0)
green=(0, 255, 0)
blue=(0, 0, 255)
yellow=(255, 255, 0)
# Game Fonts
#CITATION: I got this from https://www.fontsquirrel.com/
font = "StressGenesis.otf"
#CITATION: I got this from https://qwewy.gitbooks.io/pygame-module-manual/chapter1/framework.html
class Difficulty(main.PygameGame):
# Text Renderer
#CITATION: I got this code from https://nerdparadise.com/programming/pygame/part5
@staticmethod
def text_format(message, textFont, textSize, textColor):
newFont=pygame.font.Font(textFont, textSize)
newText=newFont.render(message, 0, textColor)
return newText
def init(self):
self.bgColor = black
self.select = settingVars.difficulty
self.difficulty = self.text_format("Select Difficulty", font,175,white)
self.difficulty_rect = self.difficulty.get_rect()
self.easy=self.text_format("Easy",font,100,black)
self.easy_rect=self.easy.get_rect()
self.medium=self.text_format("Medium",font,100,white)
self.medium_rect=self.medium.get_rect()
self.CMU=self.text_format("CMU",font,100,white)
self.CMU_rect=self.CMU.get_rect()
self.setMode()
"""
self.back=self.text_format("Back",font,100,white)
self.back_rect=self.back.get_rect()
"""
def keyPressed(self, key, mod):
if key == pygame.K_UP:
self.select = (self.select - 1) % 3
if key == pygame.K_DOWN:
self.select = (self.select + 1) % 3
if key == pygame.K_RETURN and self.select == 0:
home = menu.Menu(2000,1200)
settingVars.difficulty = 0
home.run()
if key == pygame.K_RETURN and self.select == 1:
home = menu.Menu(2000,1200)
settingVars.difficulty = 1
home.run()
if key == pygame.K_RETURN and self.select == 2:
home = menu.Menu(2000,1200)
settingVars.difficulty = 2
home.run()
"""
if key == pygame.K_RETURN and self.select == 3:
home = menu.Menu(2000,1200)
home.run()
"""
self.setMode()
def setMode(self):
if self.select == 0:
self.easy = self.text_format("Easy", font, 100, black)
else:
self.easy = self.text_format("Easy", font, 100, white)
self.easy_rect = self.easy.get_rect()
if self.select == 1:
self.medium = self.text_format("Medium", font, 100, black)
else:
self.medium = self.text_format("Medium", font, 100, white)
self.medium_rect = self.medium.get_rect()
if self.select == 2:
self.CMU = self.text_format("CMU", font, 100, black)
else:
self.CMU = self.text_format("CMU", font, 100, white)
self.CMU_rect = self.CMU.get_rect()
"""
if self.select == 3:
self.back = self.text_format("Back", font, 100, black)
else:
self.back = self.text_format("Back", font, 100, white)
self.back_rect = self.back.get_rect()
"""
def redrawAll(self, screen):
screen.blit(self.difficulty, (self.width/2 -\
(self.difficulty_rect[2]/2), 200))
if self.select == 0:
pygame.draw.rect(screen, white, [self.width/2 - \
self.easy_rect[2]/2 - 10 ,450,self.easy_rect[2] + 10,100], 0)
if self.select == 1:
pygame.draw.rect(screen, white, [self.width/2 - \
self.medium_rect[2]/2 - 10,600,\
self.medium_rect[2]+ 10 ,100], 0)
if self.select == 2:
pygame.draw.rect(screen, white, [self.width/2 - \
self.CMU_rect[2]/2-10,750,self.CMU_rect[2]+10,100], 0)
"""
if self.select == 3:
pygame.draw.rect(screen, white, [self.width/2 - \
self.back_rect[2]/2-10,950,self.back_rect[2]+10,100], 0)
"""
screen.blit(self.easy, (self.width/2 - (self.easy_rect[2]/2), 450))
screen.blit(self.medium, (self.width/2 - \
(self.medium_rect[2]/2), 600))
screen.blit(self.CMU, (self.width/2 - \
(self.CMU_rect[2]/2), 750))
"""
screen.blit(self.back, (self.width/2 - \
(self.back_rect[2]/2), 950))
"""
"""
def main():
difficulty = Difficulty(2000,1200)
difficulty.run()
if __name__=='__main__':
main()
"""