From 8c544f8fcc6227773ac783fd0a20618cbe8d7ffc Mon Sep 17 00:00:00 2001 From: Simon Pirkelmann Date: Mon, 6 Sep 2021 00:05:52 +0200 Subject: [PATCH] implemented quitting the program --- gauss-turing/webserver/gauss_turing.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gauss-turing/webserver/gauss_turing.py b/gauss-turing/webserver/gauss_turing.py index 98f9043..74d26f9 100644 --- a/gauss-turing/webserver/gauss_turing.py +++ b/gauss-turing/webserver/gauss_turing.py @@ -1,7 +1,6 @@ import numpy as np import random import pygame - import os BLACK = np.array([0, 0, 0], dtype=np.uint8) @@ -377,8 +376,10 @@ class Game: def process_inputs(self): # proceed events for event in pygame.event.get(): + if event.type == pygame.QUIT: + self.state = 'quit' # handle MOUSEBUTTONUP - if event.type == pygame.MOUSEBUTTONUP: + elif event.type == pygame.MOUSEBUTTONUP: pos = pygame.mouse.get_pos() # select command to edit by the programmer @@ -439,6 +440,8 @@ class Game: self.state = self.prg.step() elif self.state == 'reset': self.state = self.reset() + elif self.state == 'quit': + running = False else: print("unknown state") return