From 8cb7470d229fd89a7ef659d41842633990795164 Mon Sep 17 00:00:00 2001 From: informaniac Date: Fri, 1 Dec 2017 18:14:40 +0100 Subject: [PATCH] added direction to event evaluation --- games/ttrs.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/games/ttrs.py b/games/ttrs.py index 4e8a36a..6cff27a 100755 --- a/games/ttrs.py +++ b/games/ttrs.py @@ -249,13 +249,23 @@ class BalanceTtrsPlayer(TtrsPlayer, threading.Thread): oldevt = None lastchange = 0 while self.running: + THRESHOLD = 40 + direction = self.balance_util.get_4dir(THRESHOLD) - #print('player_id=%d xbal=%d ybal=%d' % (self.player_id, xbal, ybal)) + if direction == blup.balance_util.Direction.QUIT: self.evt = PlayerEvent.QUIT - - THRESHOLD = 40 + elif direction == blup.balance_util.Direction.LEFT: + evt = PlayerEvent.MOVE_LEFT + elif direction == blup.balance_util.Direction.RIGHT: + evt = PlayerEvent.MOVE_RIGHT + elif direction == blup.balance_util.Direction.UP: + evt = PlayerEvent.ROTATE + elif direction == blup.balance_util.Direction.DOWN: + evt = PlayerEvent.DOWN else: + evt = None + #print('player_id=%d xbal=%d ybal=%d' % (self.player_id, xbal, ybal)) MIN_TIMES = { PlayerEvent.MOVE_LEFT: 0.1, PlayerEvent.MOVE_RIGHT: 0.1,