diff options
| author | Tom Harley | 2017-12-02 20:45:10 +0000 |
|---|---|---|
| committer | Tom Harley | 2017-12-02 20:45:10 +0000 |
| commit | 56b608337ab782c58e56a874d615afa716cf996f (patch) | |
| tree | 71ff3c1ad6871b9335d28e856fe893bb82dae101 | |
| parent | Merge branch 'master' of https://github.com/magnostherobot/longpong (diff) | |
| download | longpong-56b608337ab782c58e56a874d615afa716cf996f.tar.gz longpong-56b608337ab782c58e56a874d615afa716cf996f.zip | |
maybe more balls?
| -rw-r--r-- | client/game.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/client/game.py b/client/game.py index 632264a..866e434 100644 --- a/client/game.py +++ b/client/game.py @@ -84,6 +84,7 @@ class Game: def loop(self): self.running = True + was_n_down = False c_time = time.time() while self.running: self.client.listen() @@ -103,7 +104,7 @@ class Game: touched = {x : False for x in self.ball_list} for msg in msgs: if (msg['command'] == 'bchange'): - if msg['ball_id'] in ball_list: + if msg['ball_id'] in self.ball_list: ball = self.ball_list[msg['ball_id']] if 'vel' in msg: ball.vel = (msg['vel']['x'], msg['vel']['y']) @@ -118,6 +119,29 @@ class Game: l_deltaT = c_time - msg['time'] ball.move(l_deltaT) + if self.event.has_key(sdl2.SDLK_n): + if not was_n_down: + t = 0 + for x in range(0, 10**10): + if x not in ball_list: + t = x + msg = { + 'ball_id': x, + 'vel': { + 'x': 1, + 'y': 1 + }, + 'pos': { + 'x': self.renderer.get_rightmost_edge(), + 'y': 0.5 + }, + 'time': c_time + } + self.client.send_ballchange(msg) + was_n_down = True + else: + was_n_down = False + balls_to_remove = [] for i, ball in self.ball_list.items(): if not touched[i]: |
