implemented quitting the program

master
Simon Pirkelmann 2021-09-06 00:05:52 +02:00
parent ff6caa457f
commit 8c544f8fcc
1 changed files with 5 additions and 2 deletions

View File

@ -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