|
|
|
@ -141,25 +141,36 @@ class B4lancePong(object):
@@ -141,25 +141,36 @@ class B4lancePong(object):
|
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
|
|
|
sock.connect(self.__balanceserver) |
|
|
|
|
print('connected!') |
|
|
|
|
balance_util_p1 = blup.balance_util.BalanceUtil(sock, 0) |
|
|
|
|
balance_util_p2 = blup.balance_util.BalanceUtil(sock, 1) |
|
|
|
|
while not balance_util_p1.get_player_ready(): |
|
|
|
|
time.sleep(0.1) |
|
|
|
|
bplayers = [ |
|
|
|
|
blup.balance_util.BalanceUtil(sock, 0), |
|
|
|
|
blup.balance_util.BalanceUtil(sock, 1) |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
self.__players = [] |
|
|
|
|
self.__players.append(BalanceBoardPlayer(self.__playground, self.__playground.leftPaddle, balance_util_p1)) |
|
|
|
|
while not (bplayers[0].get_player_ready() or |
|
|
|
|
bplayers[1].get_player_ready()): |
|
|
|
|
time.sleep(0.1) |
|
|
|
|
|
|
|
|
|
for i in range(5): |
|
|
|
|
frame = mk_logo_frame(self.__dimension, onePlayer) |
|
|
|
|
self.__out.sendFrame(frame) |
|
|
|
|
|
|
|
|
|
print('waiting for second player...') |
|
|
|
|
if balance_util_p2.get_player_ready(): |
|
|
|
|
self.__players.append(BalanceBoardPlayer(self.__playground, self.__playground.rightPaddle, |
|
|
|
|
balance_util_p2)) |
|
|
|
|
if (bplayers[0].get_player_ready() and |
|
|
|
|
bplayers[1].get_player_ready()): |
|
|
|
|
break |
|
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
|
|
self.__players = [] |
|
|
|
|
for i in [0, 1]: |
|
|
|
|
paddle = self.__playground.leftPaddle if i == 0 else \ |
|
|
|
|
self.__playground.rightPaddle |
|
|
|
|
if bplayers[i].get_player_ready(): |
|
|
|
|
player = BalanceBoardPlayer(self.__playground, paddle, |
|
|
|
|
bplayers[i]) |
|
|
|
|
else: |
|
|
|
|
player = pong.PongBot(self.__playground, paddle, 3) |
|
|
|
|
self.__players.append(player) |
|
|
|
|
|
|
|
|
|
frame = mk_logo_frame(self.__dimension, logo) |
|
|
|
|
self.__out.sendFrame(frame) |
|
|
|
|
time.sleep(2) |
|
|
|
@ -173,10 +184,6 @@ class B4lancePong(object):
@@ -173,10 +184,6 @@ class B4lancePong(object):
|
|
|
|
|
self.__out.sendFrame(frame) |
|
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
|
|
if len(self.__players) == 1: |
|
|
|
|
bot = pong.PongBot(self.__playground, self.__playground.rightPaddle, 3) |
|
|
|
|
self.__players.append(bot) |
|
|
|
|
|
|
|
|
|
while max(scoreLeft, scoreRight) < __MAX_SCORE__: |
|
|
|
|
winner = self.__playground.play() |
|
|
|
|
if winner is self.__players[0].ownPaddle: |
|
|
|
|