Browse Source

Local mode (empty queue) bugs fixed

master
kaqu 1 year ago
parent
commit
e693bf07b8
  1. 8
      game_objects/pong_game.py
  2. 7
      game_objects/pong_viewer.py
  3. 2
      pp.sh

8
game_objects/pong_game.py

@ -214,11 +214,13 @@ class PongGame:
else: # Player #1: +1
player1.score = player1.score + 1
ball.reinit(-(10 + (random() - 0.5) * 4), (random() - 0.5) * 10)
self.playsound = pgc.PLAYERMISSSOUND
player1.clear_UDP_queue() # Dry up queues ...
self.playsound = pgc.PLAYERMISSSOUND
if pgv.bIsLocal == False:
player1.clear_UDP_queue() # Dry up queues ...
else: # All other non-play states
player1.clear_UDP_queue() # Dry up queues ...
if pgv.bIsLocal == False:
player1.clear_UDP_queue() # Dry up queues ...
else: # This is a remote player or a viewer ...
if self.state == pgc.STATE_EXIT: # If we're on exit, terminate!

7
game_objects/pong_viewer.py

@ -104,9 +104,10 @@ class pongWindow(QMainWindow):
self.timer = QTimer() # Start processing 'loop'
self.timer.setInterval(25) # 25ms
self.timer.setTimerType(Qt.PreciseTimer)
self.timer.timeout.connect(self.on_timer)
while self.viewserver.receive_data() == 1: # Client side: Empty receive queue (to sync. faster!)
pass
self.timer.timeout.connect(self.on_timer)
if pgv.bIsLocal == False:
while self.viewserver.receive_data() == 1: # Client side: Empty receive queue (to sync. faster!)
pass
self.timer.start()
def paintEvent(self, event):

2
pp.sh

@ -1,2 +1,2 @@
# simple local game
./pandemic_pong.py --sizeable
./pandemic_pong.py --fullscreen

Loading…
Cancel
Save