-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_events_.py
53 lines (42 loc) · 1.64 KB
/
_events_.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import pygame as pyg
import co
class EventListener():
def __init__(self):
self.quit = None
self.mousedown = None
self.mouseup = None
self.movemove = None
self.sound = None
pass
def set_quit_callback(self, callback):
self.quit = callback
def set_mousedown_callback(self, callback):
self.mousedown = callback
def set_mouseup_callback(self, callback):
self.mouseup = callback
def set_mousemove_callback(self, callback):
self.mousemove = callback
def set_sound_callback(self, callback):
self.sound = callback
def listen(self):
for event in pyg.event.get():
if event.type == pyg.QUIT:
self.quit()
elif event.type == pyg.MOUSEBUTTONDOWN:
self.mousedown(x=event.pos[0], y=event.pos[1], button=event.button)
elif event.type == pyg.MOUSEBUTTONUP:
self.mouseup(x=event.pos[0], y=event.pos[1], button=event.button)
elif event.type == pyg.MOUSEMOTION:
self.mousemove(x=event.pos[0], y=event.pos[1], dx=event.rel[0], dy=event.rel[1])
else:
if event.type == co.DISINTEGRATION_TYPE:
self.sound("disintegration")
elif event.type == co.FISSION_TYPE:
self.sound("fission")
elif event.type == co.ABSORB_TYPE:
self.sound("absorb")
elif event.type == co.WALL_TYPE:
self.sound("wall")
class Event():
def __init__(self):
pass