- commit
- 0d1d11840fcbe32a17a56e10f1b00afca683024c
- parent
- efb9673eabb8fc5f42322d1895919ed4db198a7a
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2014-10-31 16:15
simple multi-sprite client
Diffstat
| M | laneya/client.py | 17 | +++++++++++------ |
1 files changed, 11 insertions, 6 deletions
diff --git a/laneya/client.py b/laneya/client.py
@@ -14,15 +14,20 @@ screen.border() 14 14 class Client(protocol.ClientProtocolFactory): 15 15 def __init__(self): 16 16 protocol.ClientProtocolFactory.__init__(self)17 -1 self.position_x = 018 -1 self.position_y = 0-1 17 self.sprites = {} 19 18 20 19 def updateReceived(self, action, **kwargs): # TODO 21 20 if action == 'position':22 -1 screen.delch(self.position_y, self.position_x)23 -1 self.position_x = kwargs['x']24 -1 self.position_y = kwargs['y']25 -1 screen.putstr(self.position_y, self.position_x, 'X')-1 21 entity = kwargs['entity'] -1 22 if entity not in self.sprites: -1 23 self.sprites[entity] = {} -1 24 else: -1 25 screen.delch( -1 26 self.sprites[entity]['y'], -1 27 self.sprites[entity]['x']) -1 28 self.sprites[entity]['x'] = kwargs['x'] -1 29 self.sprites[entity]['y'] = kwargs['y'] -1 30 screen.putstr(kwargs['y'], kwargs['x'], entity[0]) 26 31 screen.refresh() 27 32 28 33 def move(self, direction):