-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathWorld.py
More file actions
30 lines (20 loc) · 880 Bytes
/
World.py
File metadata and controls
30 lines (20 loc) · 880 Bytes
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
from pythonfrp import Proxy
from pythonfrp import Globals
from pythonfrp.Types import *
from pythonfrp import Numerics
def updateWorld(self):
for f in world._updaters:
f(self)
class World(Proxy.Proxy):
def __init__(self, update=updateWorld, name="world"):
Proxy.Proxy.__init__(self, name, update, {})
# Create a world labeled 'world' with an updater that calls each signal's custom update
world = World() # Instance of World class
world._updaters = []
def addSignal(name, default, type, update): # Add a signal to a given object, paired with a specified updater.
world.__setattr__(name, default)
world._types[name] = type
world._updaters.append(update)
def resetWorld(continueFn=lambda: None, initFn=lambda: None): # Makes all DirectGUI stuff invisible
Globals.resetFlag = continueFn
Globals.initFn = initFn