-
Notifications
You must be signed in to change notification settings - Fork 0
/
User.py
34 lines (33 loc) · 967 Bytes
/
User.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import threading
import tty
import sys
class User(threading.Thread):
def __init__(self,observer):
threading.Thread.__init__(self)
self.observer = observer
self.exit = False
def getObserver(self):
return self.observer
def run(self):
ob = self.getObserver()
tty.setraw(sys.stdin.fileno())
while not self.exit:
# if bal.getExit():
# bal.setUserExit();
# break;
# else:
ch = sys.stdin.read(1)
if (ch == 'w'):
ob.up()
elif (ch == 's'):
ob.down()
elif ch == 'a':
ob.left()
elif ch == 'd':
ob.right()
elif ch == 'b':
ob.end();
break;
# print("size: "+str(ob.snake.size));
# ob.end();
# ob.cleanup();