-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathglobalvalues.py
93 lines (84 loc) · 1.94 KB
/
globalvalues.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
'''
globalvalues.py
Stores values and locks that can be accessed from almost anywhere
Acquiring the lock of a class is recommended before writing to its attributes
'''
import threading,pygame
pygame.init()
"""
Provides everything required by RenderThread, as well as initializing the display
"""
class Renderable:
def __init__(self):
self.lock=threading.RLock()
self.screen = pygame.display.get_surface()
if not self.screen:
self.screen = pygame.display.set_mode((800,600))
def draw(self,events):
print "Please implement a draw method"
"""
Class containing all Configurable options that could be checked
"""
class Options:
lock=threading.RLock()
menuWrap=False
backgrounds=True
limitFramerate=60
showFramerate=False
writeLog=False
theme=None
musicVolume=1
sfxVolume=1
"""
Objects critical to events processing
"""
class Events:
done = threading.Semaphore(2)
events = pygame.event.get()
trigger = threading.Condition()
#processing = threading.Semaphore(2)
"""
Objects that should be accessible from anywhere
"""
class GlobalObjects:
playercharacters = None
unlockedWorlds=1
currentWorld = 1
lock = threading.RLock()
clock = pygame.time.Clock()
renderingThread = None
eventsThread = None
escInUse = False
"""
The menu objects, so that they don't have to be regenerated every time the
active menu changes
"""
class Menus:
main = None
options = None
levels = None
"""
Bitmasks used to determine what the current input is
"""
class Input:
left = 1
right = 2
up = 4
down = 8
"""
Bitmasks used to determine what collisions are currently happening
"""
class Collison:
#set this bit to 0 if no collision
collides=1
top=2
bottom=4
right=8
left=16
class Sound:
called = threading.Condition()
lock = threading.RLock()
backgroundmusic = 1
jump = 2
solved = 4
killed = 8