Browse Source

remove --players argument

balancep0ng-improve-player-joining
Fr3deric 5 years ago
parent
commit
ac6ad5403c
  1. 29
      games/balancep0ng.py

29
games/balancep0ng.py

@ -116,7 +116,7 @@ class BalanceBoardPlayer(object): @@ -116,7 +116,7 @@ class BalanceBoardPlayer(object):
class B4lancePong(object):
def __init__(self, out, balanceserver=None, color=True, numplayers=None):
def __init__(self, out, balanceserver=None, color=True):
self.__playground = None
self.__out = out
self.__color = color
@ -124,7 +124,6 @@ class B4lancePong(object): @@ -124,7 +124,6 @@ class B4lancePong(object):
self.__balanceserver = ('localhost', 4711)
else:
self.__balanceserver = balanceserver
self.__numplayers = numplayers
if color:
self.__dimension = blup.frame.FrameDimension(22, 16, 256, 3)
@ -150,19 +149,16 @@ class B4lancePong(object): @@ -150,19 +149,16 @@ class B4lancePong(object):
self.__players = []
self.__players.append(BalanceBoardPlayer(self.__playground, self.__playground.leftPaddle, balance_util_p1))
if self.__numplayers == 2:
self.__players.append(BalanceBoardPlayer(self.__playground, self.__playground.rightPaddle, balance_util_p2))
elif self.__numplayers is None:
for i in range(5):
frame = mk_logo_frame(self.__dimension, onePlayer)
self.__out.sendFrame(frame)
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))
break
time.sleep(1)
print('waiting for second player...')
if balance_util_p2.get_player_ready():
self.__players.append(BalanceBoardPlayer(self.__playground, self.__playground.rightPaddle,
balance_util_p2))
break
time.sleep(1)
frame = mk_logo_frame(self.__dimension, logo)
self.__out.sendFrame(frame)
@ -204,8 +200,6 @@ class B4lancePong(object): @@ -204,8 +200,6 @@ class B4lancePong(object):
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Blinkenbunt Pong!')
parser.add_argument('--players', dest='players', type=int,
help='number of players (autodetect if unspecified)')
parser.add_argument('--balance', dest='balance', type=str,
metavar='HOST:PORT', help='use balance input')
parser.add_argument('--out', dest='out', type=str, metavar='OUTPUT',
@ -215,7 +209,6 @@ if __name__ == '__main__': @@ -215,7 +209,6 @@ if __name__ == '__main__':
out = blup.output.getOutput(args.out)
bhost, bport = args.balance.split(':')
p0ng = B4lancePong(out, balanceserver=(bhost, int(bport)), color=True,
numplayers=args.players)
p0ng = B4lancePong(out, balanceserver=(bhost, int(bport)), color=True)
p0ng.runGame()

Loading…
Cancel
Save