-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventHandler.py
35 lines (29 loc) · 1.06 KB
/
EventHandler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pygame as pg
window = pg.display.set_mode((1000, 500))
class EventHandler:
def __init__(self):
self.live = True
self.quit_event = pg.event.Event(pg.QUIT)
self.font = pg.font.SysFont('latohairline', 25)
self.window = 'MainWindow'
self.pressed_button = 'Hand'
def hand(self):
keys = pg.key.get_pressed()
if keys[pg.K_q]:
self.live = False
return
if keys[pg.K_ESCAPE]:
self.window = 'MainWindow'
for event in pg.event.get():
if event.type == pg.QUIT:
self.live = False
return
if self.window == 'MainWindow':
if event.type == pg.MOUSEBUTTONUP:
if event.button == 1:
x, y = event.pos
if 450 <= x <= 550 and 180 <= y <= 230:
self.window = 'DrawWindow'
if 450 <= x <= 550 and 260 <= y <= 310:
self.live = False
return