Browse Source

use the balance_util functions to determine if the player(s) are ready

feature/balanceutils
informaniac 7 years ago
parent
commit
026f05c958
  1. 8
      games/balancep0ng.py

8
games/balancep0ng.py

@ -144,8 +144,7 @@ class B4lancePong(object):
print('connected!') print('connected!')
balance_util_p1 = blup.balance_util.BalanceUtil(sock, 0) balance_util_p1 = blup.balance_util.BalanceUtil(sock, 0)
balance_util_p2 = blup.balance_util.BalanceUtil(sock, 1) balance_util_p2 = blup.balance_util.BalanceUtil(sock, 1)
while not balance_util_p1.get_player1_ready():
while get_balance_from_sock(sock, 0) == -128:
print('waiting for player...') print('waiting for player...')
time.sleep(1) time.sleep(1)
@ -160,8 +159,9 @@ class B4lancePong(object):
self.__out.sendFrame(frame) self.__out.sendFrame(frame)
print('waiting for second player...') print('waiting for second player...')
if get_balance_from_sock(sock, 1) > -128: if balance_util_p2.get_player2_ready:
self.__players.append(BalanceBoardPlayer(self.__playground, self.__playground.rightPaddle, sock, 1)) self.__players.append(BalanceBoardPlayer(self.__playground, self.__playground.rightPaddle,
balance_util_p2))
break break
time.sleep(1) time.sleep(1)

Loading…
Cancel
Save