Added a new player "Turn Right Killer", and made a new tournament mode.
[troncode.git] / player_human.py
blob74a6f7cc23ad22d1b4cb69bbbdb985d1494e1777
1 from troncode_values import *
3 class HumanPlayer( object ):
5 def __init__( self, event_up, event_right, event_down, event_left ):
6 self._event_up = event_up
7 self._event_right = event_right
8 self._event_down = event_down
9 self._event_left = event_left
11 def GetColour( self ):
12 return ( 128, 255, 128 )
14 def IsHuman():
15 return True
16 IsHuman = staticmethod( IsHuman )
18 def GetName():
19 return "Human Player"
20 GetName = staticmethod( GetName )
22 def GetDirWithInput( self, direction, key_events ):
23 for evt in key_events:
24 if direction != DIR_DOWN and self._event_up.matches( evt ):
25 return DIR_UP
26 elif direction != DIR_LEFT and self._event_right.matches( evt ):
27 return DIR_RIGHT
28 elif direction != DIR_UP and self._event_down.matches( evt ):
29 return DIR_DOWN
30 elif direction != DIR_RIGHT and self._event_left.matches( evt ):
31 return DIR_LEFT
32 return direction