Press keys to exit

This commit is contained in:
Kyler Olsen 2024-04-03 09:14:13 -06:00
parent 43913e4bfd
commit 9c17f64eaa
1 changed files with 6 additions and 0 deletions

View File

@ -13,6 +13,7 @@ pygame.init()
screen = pygame.display.set_mode()
pygame.display.set_caption("Equation Plotter")
pygame.mouse.set_visible(False)
MOD_KEYS = pygame.key.get_mods()
class Hypotrochoid(Equation):
@ -73,6 +74,11 @@ def main(equ):
mouse_x, mouse_y = pygame.mouse.get_pos()
if 5 < math.sqrt(pow(mouse_x_last - mouse_x, 2) + pow(mouse_y_last - mouse_y, 2)):
running = False
keys = pygame.key.get_pressed()
if any(keys[i] for i in range(len(keys))):
running = False
if pygame.key.get_mods() != MOD_KEYS:
running = False
pygame.quit()
sys.exit()