MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / Options

Class Options

projects/PONG/main.py:180–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178
179
180class Options:
181 def __init__(self, text, x, y) -> None:
182 self.text = menu_font.render(text, True, (255, 255, 255))
183 self.val = text
184 self.x = x
185 self.y = y
186 self.rect = pygame.Rect(x, y, 224, 74)
187 self.text_rect = self.text.get_rect(center=(self.x + 112, self.y + 37))
188
189 def draw(self):
190 global opponent_speed, ball_speed, start_game
191 pos = pygame.mouse.get_pos()
192 if self.rect.collidepoint(pos):
193 if pygame.mouse.get_pressed()[0] == 1:
194 if self.val == "EASY":
195 game_state.state = "easy_game"
196 elif self.val == "MEDIUM":
197 game_state.state = "med_game"
198 elif self.val == "HARD":
199 game_state.state = "hard_game"
200
201 pygame.draw.rect(WIN, (59, 59, 209), self.rect)
202 WIN.blit(self.text, self.text_rect)
203
204
205class GameState:

Callers 1

main.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected