diff options
| author | Tom Harley | 2017-12-02 20:22:40 +0000 |
|---|---|---|
| committer | Tom Harley | 2017-12-02 20:22:40 +0000 |
| commit | fae570a82cb8b1747fc1b275224478985f9d76e7 (patch) | |
| tree | 16c37126730659e6bff724c31fc41b2534374001 /client | |
| parent | merged (diff) | |
| download | longpong-fae570a82cb8b1747fc1b275224478985f9d76e7.tar.gz longpong-fae570a82cb8b1747fc1b275224478985f9d76e7.zip | |
added suport for multipball
Diffstat (limited to 'client')
| -rw-r--r-- | client/game.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/client/game.py b/client/game.py index 9540cad..273daa2 100644 --- a/client/game.py +++ b/client/game.py @@ -103,15 +103,18 @@ class Game: touched = {x : False for x in self.ball_list} for msg in msgs: if (msg['command'] == 'bchange'): - touched[msg['ball_id']] = True - ball = self.ball_list[msg['ball_id']] - if 'vel' in msg: - ball.vel = (msg['vel']['x'], msg['vel']['y']) - if 'pos' in msg: - ball.pos = (msg['pos']['x'], msg['pos']['y']) - if 'size' in msg: - ball.size = (msg['size']['x'], msg['size']['y']) + if msg['ball_id'] in ball_list: + ball = self.ball_list[msg['ball_id']] + if 'vel' in msg: + ball.vel = (msg['vel']['x'], msg['vel']['y']) + if 'pos' in msg: + ball.pos = (msg['pos']['x'], msg['pos']['y']) + if 'size' in msg: + ball.size = (msg['size']['x'], msg['size']['y']) + else: + ball_list[msg['ball_id']] = Ball(msg[0]['pos'],msg[0]['vel'],msg[0]['size']) + touched[msg['ball_id']] = True l_deltaT = c_time - msg['time'] ball.move(l_deltaT) |
