-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGameObjectFactory.py
30 lines (25 loc) · 1004 Bytes
/
GameObjectFactory.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
from OtherPlayer import OtherPlayer
from OtherMissile import OtherMissile
class GameObjectFactory():
@classmethod
def clone_object(cls, data):
"""Factory method for create various children of GameObject when server sends a clone.
Arguments:
data - the dictionary passed from MazeServer to MazeClient with a BroadcastNewObject() call.
"""
if data['class'] == 'Player':
OtherPlayer(
nickname = data['nickname'],
position = data['position'],
direction = data['direction'],
color = data['color'],
object_hash = data['object_hash']
)
elif data['class'] == 'Missile':
OtherMissile(
nickname = data['nickname'],
position = data['position'],
direction = data['direction'],
color = data['color'],
object_hash = data['object_hash']
)