Press keys to exit
This commit is contained in:
parent
43913e4bfd
commit
9c17f64eaa
6
main.py
6
main.py
|
@ -13,6 +13,7 @@ pygame.init()
|
||||||
screen = pygame.display.set_mode()
|
screen = pygame.display.set_mode()
|
||||||
pygame.display.set_caption("Equation Plotter")
|
pygame.display.set_caption("Equation Plotter")
|
||||||
pygame.mouse.set_visible(False)
|
pygame.mouse.set_visible(False)
|
||||||
|
MOD_KEYS = pygame.key.get_mods()
|
||||||
|
|
||||||
class Hypotrochoid(Equation):
|
class Hypotrochoid(Equation):
|
||||||
|
|
||||||
|
@ -73,6 +74,11 @@ def main(equ):
|
||||||
mouse_x, mouse_y = pygame.mouse.get_pos()
|
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)):
|
if 5 < math.sqrt(pow(mouse_x_last - mouse_x, 2) + pow(mouse_y_last - mouse_y, 2)):
|
||||||
running = False
|
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()
|
pygame.quit()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
Loading…
Reference in New Issue