|
|
@ -198,7 +198,7 @@ class BalanceInput(AbstractInput, threading.Thread): |
|
|
|
self.addr = addr |
|
|
|
self.addr = addr |
|
|
|
self.player_id = player_id |
|
|
|
self.player_id = player_id |
|
|
|
self.evt = None |
|
|
|
self.evt = None |
|
|
|
self.oldevt = None |
|
|
|
self.lastevt = None |
|
|
|
self.player_present = False |
|
|
|
self.player_present = False |
|
|
|
threading.Thread.__init__(self, daemon=True) |
|
|
|
threading.Thread.__init__(self, daemon=True) |
|
|
|
self.start() |
|
|
|
self.start() |
|
|
@ -259,9 +259,9 @@ class BalanceInput(AbstractInput, threading.Thread): |
|
|
|
print('player_id=%d debounce %s' % (self.player_id, evt)) |
|
|
|
print('player_id=%d debounce %s' % (self.player_id, evt)) |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
if self.lastevent != evt: |
|
|
|
if self.lastevt != evt: |
|
|
|
self.evt = evt |
|
|
|
self.evt = evt |
|
|
|
self.lastevent = evt |
|
|
|
self.lastevt = evt |
|
|
|
print('player_id=%d event=%s' % (self.player_id, self.evt)) |
|
|
|
print('player_id=%d event=%s' % (self.player_id, self.evt)) |
|
|
|
|
|
|
|
|
|
|
|
else: |
|
|
|
else: |
|
|
@ -318,10 +318,13 @@ if __name__ == '__main__': |
|
|
|
time.sleep(2) |
|
|
|
time.sleep(2) |
|
|
|
games = Game.__subclasses__() |
|
|
|
games = Game.__subclasses__() |
|
|
|
game_idx = 0 |
|
|
|
game_idx = 0 |
|
|
|
|
|
|
|
old_idx = -1 |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
gamecls = games[game_idx] |
|
|
|
if old_idx != game_idx: |
|
|
|
game = gamecls() |
|
|
|
gamecls = games[game_idx] |
|
|
|
out.sendFrame(create_menu_frame(dim, game)) |
|
|
|
game = gamecls() |
|
|
|
|
|
|
|
out.sendFrame(create_menu_frame(dim, game)) |
|
|
|
|
|
|
|
old_idx = game_idx |
|
|
|
|
|
|
|
|
|
|
|
evt = inp1.get_event() |
|
|
|
evt = inp1.get_event() |
|
|
|
if evt == InputEvent.LEFT: |
|
|
|
if evt == InputEvent.LEFT: |
|
|
@ -346,8 +349,12 @@ if __name__ == '__main__': |
|
|
|
start = time.time() |
|
|
|
start = time.time() |
|
|
|
while time.time() < start+wait_time: |
|
|
|
while time.time() < start+wait_time: |
|
|
|
if inp2.get_event() == InputEvent.STEP_ON: |
|
|
|
if inp2.get_event() == InputEvent.STEP_ON: |
|
|
|
|
|
|
|
inp1.running = False |
|
|
|
|
|
|
|
inp2.running = False |
|
|
|
start_game(game, 2) |
|
|
|
start_game(game, 2) |
|
|
|
time.sleep(0.1) |
|
|
|
time.sleep(0.1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inp1.running = False |
|
|
|
|
|
|
|
inp2.running = False |
|
|
|
start_game(game, 1) |
|
|
|
start_game(game, 1) |
|
|
|
|
|
|
|
|
|
|
|