implemented quitting the program
This commit is contained in:
parent
ff6caa457f
commit
8c544f8fcc
|
@ -1,7 +1,6 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import random
|
import random
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
BLACK = np.array([0, 0, 0], dtype=np.uint8)
|
BLACK = np.array([0, 0, 0], dtype=np.uint8)
|
||||||
|
@ -377,8 +376,10 @@ class Game:
|
||||||
def process_inputs(self):
|
def process_inputs(self):
|
||||||
# proceed events
|
# proceed events
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
self.state = 'quit'
|
||||||
# handle MOUSEBUTTONUP
|
# handle MOUSEBUTTONUP
|
||||||
if event.type == pygame.MOUSEBUTTONUP:
|
elif event.type == pygame.MOUSEBUTTONUP:
|
||||||
pos = pygame.mouse.get_pos()
|
pos = pygame.mouse.get_pos()
|
||||||
|
|
||||||
# select command to edit by the programmer
|
# select command to edit by the programmer
|
||||||
|
@ -439,6 +440,8 @@ class Game:
|
||||||
self.state = self.prg.step()
|
self.state = self.prg.step()
|
||||||
elif self.state == 'reset':
|
elif self.state == 'reset':
|
||||||
self.state = self.reset()
|
self.state = self.reset()
|
||||||
|
elif self.state == 'quit':
|
||||||
|
running = False
|
||||||
else:
|
else:
|
||||||
print("unknown state")
|
print("unknown state")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user