Browse Source

added direction to event evaluation

feature/balanceutils
informaniac 7 years ago
parent
commit
8cb7470d22
  1. 16
      games/ttrs.py

16
games/ttrs.py

@ -249,13 +249,23 @@ class BalanceTtrsPlayer(TtrsPlayer, threading.Thread): @@ -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,

Loading…
Cancel
Save