forked from TheAwesomePossum/PythonCS0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Events.py
71 lines (60 loc) · 1.88 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
'''
Author: Graham Montgomery
Western State Colorado University
This file will handle all events
'''
import sys
import Globals as g
import Engine
pygame = g.pygame
'''
QUIT none
ACTIVEEVENT gain, state
KEYDOWN unicode, key, mod
KEYUP key, mod
MOUSEMOTION pos, rel, buttons
MOUSEBUTTONUP pos, button
MOUSEBUTTONDOWN pos, button
JOYAXISMOTION joy, axis, value
JOYBALLMOTION joy, ball, rel
JOYHATMOTION joy, hat, value
JOYBUTTONUP joy, button
JOYBUTTONDOWN joy, button
VIDEORESIZE size, w, h
VIDEOEXPOSE none
USEREVENT
'''
def eraseEvents():
pygame.event.set_blocked(pygame.ACTIVEEVENT)
pygame.event.set_blocked(pygame.KEYDOWN)
pygame.event.set_blocked(pygame.KEYUP)
pygame.event.set_blocked(pygame.MOUSEMOTION)
pygame.event.set_blocked(pygame.MOUSEBUTTONUP)
pygame.event.set_blocked(pygame.MOUSEBUTTONDOWN)
pygame.event.set_blocked(pygame.JOYAXISMOTION)
pygame.event.set_blocked(pygame.JOYBALLMOTION)
pygame.event.set_blocked(pygame.JOYHATMOTION)
pygame.event.set_blocked(pygame.JOYBUTTONUP)
pygame.event.set_blocked(pygame.JOYBUTTONDOWN)
pygame.event.set_blocked(pygame.VIDEORESIZE)
pygame.event.set_blocked(pygame.VIDEOEXPOSE)
pygame.event.set_blocked(pygame.USEREVENT)
eraseEvents()
EventList = {}
def noHandle(evt):
pass
def updateEvents():
#print("here")
for evt in pygame.event.get():
if evt.type is pygame.QUIT:
#Engine.stop()
if g.multithreading:
Engine.stop()
pygame.quit()
sys.exit()
#print(pygame.event.event_name(evt.type))
EventList[pygame.event.event_name(evt.type)](evt)
def addMouseClickedEvent(handle):
pygame.event.set_allowed(pygame.MOUSEBUTTONDOWN)
EventList[pygame.event.event_name(pygame.MOUSEBUTTONDOWN)] = handle
print(EventList)